-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.php
More file actions
222 lines (185 loc) · 7.17 KB
/
init.php
File metadata and controls
222 lines (185 loc) · 7.17 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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
<?php
// Kleeja Plugin
// Developer: Kleeja team
// Prevent illegal run
if (! defined('IN_PLUGINS_SYSTEM'))
{
exit();
}
// Plugin Basic Information
$kleeja_plugin['menu_toggle']['information'] = [
// The casucal name of this plugin, anything can a human being understands
'plugin_title' => [
'en' => 'Menu Toggle',
'ar' => 'عرض/إخفاء القوائم'
],
// Who wrote this plugin?
'plugin_developer' => 'Kleeja.com',
// This plugin version
'plugin_version' => '1.1.1',
// Explain what is this plugin, why should I use it?
'plugin_description' => [
'en' => 'Ability to hide/show Kleeja Menu items',
'ar' => 'القدرة على عرض/إخفاء عناصر قائمة كليجا'
],
//settings page, if there is one (what after ? like cp=j_plugins)
'settings_page' => 'cp=menus_toggle',
// Min version of Kleeja that's requiered to run this plugin
'plugin_kleeja_version_min' => '2.0',
// Max version of Kleeja that support this plugin, use 0 for unlimited
'plugin_kleeja_version_max' => '3.9',
// Should this plugin run before others?, 0 is normal, and higher number has high priority
'plugin_priority' => 0
];
//after installation message, you can remove it, it's not requiered
$kleeja_plugin['menu_toggle']['first_run']['ar'] = '
شكراً لاستخدامك هذه الإضافة قم بمراسلتنا بالأخطاء عند ظهورها على البريد: <br>
info@kleeja.com
';
$kleeja_plugin['menu_toggle']['first_run']['en'] = '
Thanks for using this plugin, to report bugs contact us:
<br>
info@kleeja.com
';
// Plugin Installation function
$kleeja_plugin['menu_toggle']['install'] = function ($plg_id) {
add_config_r([
// 'menu_toggle_hide_all' =>
// array(
// 'value' => '0',
// 'plg_id' => $plg_id,
// 'type' => 'menu_toggle'
// ),
'menu_toggle_hidden_topmenu_items' =>
[
'value' => '',
'plg_id' => $plg_id,
'type' => 'menu_toggle'
],
'menu_toggle_hidden_sidemenu_items' =>
[
'value' => '',
'plg_id' => $plg_id,
'type' => 'menu_toggle'
],
'menu_toggle_hidden_adminmenu_items' =>
[
'value' => '',
'plg_id' => $plg_id,
'type' => 'menu_toggle'
],
]);
//new language variables
add_olang([
'R_MENUS_TOGGLE' => 'تحكم بقوائم كليجا',
'MENU_TOGGLE_EXP' => 'يمكنك التحكم بالعناصر التي تريد عرضها أو إخفائها من قوائم كليجا.',
'MENU_TOGGLE_TOP_MENU' => 'القائمة العلوية',
'MENU_TOGGLE_SIDE_MENU' => 'القائمة الجانبية',
'MENU_TOGGLE_ADMIN_MENU' => 'قائمة لوحة التحكم',
'MENU_TOGGLE_ADMIN_MENU_EXP' => 'يجب أن تكون عضو في مجموعة المسؤولين، وتملك صلاحية مؤسس لتستطيع التحكم بقائمة لوحة التحكم.',
'MENU_TOGGLE_HIDE' => 'إخفاء',
'MENU_TOGGLE_SHOW' => 'عرض',
],
'ar',
$plg_id);
add_olang([
'R_MENUS_TOGGLE' => 'Menus Toggle',
'MENU_TOGGLE_EXP' => 'You can control which items you want to hide/show of Kleeja menus.',
'MENU_TOGGLE_TOP_MENU' => 'Top Menu',
'MENU_TOGGLE_SIDE_MENU' => 'Side Menu',
'MENU_TOGGLE_ADMIN_MENU' => 'Admin Panel Menu',
'MENU_TOGGLE_ADMIN_MENU_EXP' => 'You have to be a member in Administrators group and have the founder permissions to be able to control Admin panel menu items.',
'MENU_TOGGLE_HIDE' => 'hide',
'MENU_TOGGLE_SHOW' => 'show',
],
'en',
$plg_id);
};
//Plugin update function, called if plugin is already installed but version is different than current
$kleeja_plugin['menu_toggle']['update'] = function ($old_version, $new_version) {
// if(version_compare($old_version, '0.5', '<')){
// //... update to 0.5
// }
//
// if(version_compare($old_version, '0.6', '<')){
// //... update to 0.6
// }
//you could use update_config, update_olang
};
// Plugin Uninstallation, function to be called at unistalling
$kleeja_plugin['menu_toggle']['uninstall'] = function ($plg_id) {
//delete language variables
delete_olang(null, null, $plg_id);
//delete options
delete_config([
'menu_toggle_hidden_topmenu_items',
'menu_toggle_hidden_sidemenu_items',
'menu_toggle_hidden_adminmenu_items'
]);
};
// Plugin functions
$kleeja_plugin['menu_toggle']['functions'] = [
//add to admin menu
'require_admin_page_end_a_configs' => function($args) {
global $olang;
$go_menu = $args['go_menu'];
$last_item = $go_menu['all'];
unset($go_menu['all']);
$go_menu['menus_toggle'] = [
'name' => $olang['R_MENUS_TOGGLE'],
'link' => './?cp=menus_toggle',
'goto' => 'menus_toggle',
'current' => g('cp') == 'menus_toggle'
];
$go_menu['all'] = $last_item;
return compact('go_menu');
},
'begin_admin_page' => function ($args) {
global $config;
$adm_extensions = $args['adm_extensions'];
$adm_extensions[] = 'menus_toggle';
$hidden_admin_menu_items = explode(':', $config['menu_toggle_hidden_adminmenu_items'] . ':menus_toggle');
$hidden_admin_menu_items = array_filter($hidden_admin_menu_items);
$ext_expt = array_merge($args['ext_expt'], $hidden_admin_menu_items);
return compact('adm_extensions', 'ext_expt');
},
'endforeach_ext_admin_page' => function($args) {
if (g('cp') == 'menus_toggle')
{
$adm_extensions_menu = $args['adm_extensions_menu'];
$adm_extensions_menu[1]['current'] = true;
return compact('adm_extensions_menu');
}
},
//add as admin page to reach when click on admin menu item we added.
'not_exists_menus_toggle' => function () {
$include_alternative = dirname(__FILE__) . '/menus_toggle.php';
return compact('include_alternative');
},
'Saaheader_links_func' => function($args) {
global $config;
$return = [];
foreach (['top', 'side'] as $menu)
{
if (trim($config['menu_toggle_hidden_' . $menu . 'menu_items']) != '')
{
$current_menu = $args[$menu . '_menu'];
$hidden_items = explode(':', $config['menu_toggle_hidden_' . $menu . 'menu_items']);
$hidden_items = array_filter($hidden_items);
$new_menu = [];
foreach ($current_menu as $order => $item)
{
if (! in_array($item['name'], $hidden_items))
{
$new_menu[$order] = $item;
}
}
$return[$menu . '_menu'] = $new_menu;
}
}
if (sizeof($return))
{
return $return;
}
},
];