Repository navigation
Expand file tree
/
Copy pathapi_data_builder_sample.php
More file actions
132 lines (114 loc) · 4.56 KB
/
Copy pathapi_data_builder_sample.php
File metadata and controls
132 lines (114 loc) · 4.56 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
<?php
defined('BASEPATH') or exit('No direct script access allowed');
/*
Module Name: API Data Builder Sample
Description: Sample/showcase module demonstrating how to use Data Builder REST API, GraphQL, MCP Server (AI Agents: Claude, Gemini, DeepSeek, Cursor, n8n), and Webhooks 2.0 to perform CRUD and BI operations on Perfex CRM data.
Version: 1.1.0
Requires at least: 3.0.0
Author: PolyXGO
Author URI: https://codecanyon.net/user/polyxgo
*/
define('API_SAMPLE_MODULE', 'api_data_builder_sample');
define('API_SAMPLE_VERSION', '1.1.0');
/**
* Register activation hook
*/
register_activation_hook(API_SAMPLE_MODULE, 'api_sample_activation_hook');
function api_sample_activation_hook()
{
$CI = &get_instance();
require_once(__DIR__ . '/install.php');
}
/**
* Register language files
*/
register_language_files(API_SAMPLE_MODULE, [API_SAMPLE_MODULE]);
/**
* Main Module Class
*/
class Api_data_builder_sample_module
{
private $ci;
public function __construct()
{
$this->ci = &get_instance();
$this->init_hooks();
}
private function init_hooks()
{
hooks()->add_action('admin_init', [$this, 'init_admin']);
hooks()->add_filter('module_' . API_SAMPLE_MODULE . '_action_links', [$this, 'module_action_links']);
}
public function init_admin()
{
if (is_admin() || has_permission(API_SAMPLE_MODULE, '', 'view')) {
$CI = &get_instance();
if ($CI->db->table_exists(db_prefix() . 'modules')) {
$row = $CI->db->select('installed_version')
->where('module_name', API_SAMPLE_MODULE)
->get(db_prefix() . 'modules')
->row();
if ($row && $row->installed_version !== API_SAMPLE_VERSION) {
require_once(__DIR__ . '/install.php');
$CI->db->where('module_name', API_SAMPLE_MODULE)->update(db_prefix() . 'modules', [
'installed_version' => API_SAMPLE_VERSION,
]);
}
}
$CI->app_menu->add_sidebar_menu_item(API_SAMPLE_MODULE, [
'name' => _l('api_sample_menu_title'),
'icon' => 'fa fa-plug',
'position' => 8,
]);
$CI->app_menu->add_sidebar_children_item(API_SAMPLE_MODULE, [
'slug' => 'api_sample_dashboard',
'name' => _l('api_sample_dashboard'),
'icon' => 'fa fa-tachometer',
'href' => admin_url('api_data_builder_sample'),
'position' => 1,
]);
$CI->app_menu->add_sidebar_children_item(API_SAMPLE_MODULE, [
'slug' => 'api_sample_rest',
'name' => _l('api_sample_rest'),
'icon' => 'fa fa-exchange',
'href' => admin_url('api_data_builder_sample/rest'),
'position' => 2,
]);
$CI->app_menu->add_sidebar_children_item(API_SAMPLE_MODULE, [
'slug' => 'api_sample_graphql',
'name' => _l('api_sample_graphql'),
'icon' => 'fa fa-share-alt',
'href' => admin_url('api_data_builder_sample/graphql'),
'position' => 3,
]);
$CI->app_menu->add_sidebar_children_item(API_SAMPLE_MODULE, [
'slug' => 'api_sample_mcp',
'name' => _l('api_sample_mcp'),
'icon' => 'fa fa-microchip',
'href' => admin_url('api_data_builder_sample/mcp'),
'position' => 4,
]);
$CI->app_menu->add_sidebar_children_item(API_SAMPLE_MODULE, [
'slug' => 'api_sample_webhooks',
'name' => _l('api_sample_webhooks'),
'icon' => 'fa fa-rss',
'href' => admin_url('api_data_builder_sample/webhooks'),
'position' => 5,
]);
$CI->app_menu->add_sidebar_children_item(API_SAMPLE_MODULE, [
'slug' => 'api_sample_settings',
'name' => _l('settings'),
'icon' => 'fa fa-cog',
'href' => admin_url('api_data_builder_sample/settings'),
'position' => 10,
]);
}
}
public function module_action_links($actions)
{
$actions[] = '<a href="' . admin_url('api_data_builder_sample/settings') . '">' . _l('settings') . '</a>';
return $actions;
}
}
// Boot module
new Api_data_builder_sample_module();