mirror of
https://github.com/kleeja-official/kleeja.git
synced 2025-12-14 20:19:43 +01:00
new plugin: menus toggle
This commit is contained in:
83
plugins/menu_toggle/admin_menus_toggle.html
Normal file
83
plugins/menu_toggle/admin_menus_toggle.html
Normal file
@@ -0,0 +1,83 @@
|
||||
<script>
|
||||
function toggleMenuItem(name, menu, hide, current) {
|
||||
$.ajax({
|
||||
url: '{action}&toggle=' + hide + '&_ajax_=1&menu=' + menu + '&name=' + name + '&{H_FORM_KEYS_GET}',
|
||||
dataType: 'json',
|
||||
cache: false})
|
||||
.done(function (data) {
|
||||
if(data.content){
|
||||
$('#pageErrors>span').html(data.content);
|
||||
$('#pageErrors').removeClass('d-none alert-danger').addClass('alert-info');
|
||||
|
||||
} else {
|
||||
this.fail();
|
||||
}
|
||||
})
|
||||
.fail(function(data) {
|
||||
$('#pageErrors>span').html((data.content ? data.content : (data.responseJSON ? data.responseJSON.content : '{lang.ERROR_TRY_AGAIN}')));
|
||||
$('#pageErrors').removeClass('d-none alert-info').addClass('alert-danger');
|
||||
var itemRemoveClass = current == 1 ? 'cb-disable' : 'cb-enable';
|
||||
var itemAddClass = current == 0 ? 'cb-disable' : 'cb-enable';
|
||||
$('#' + menu + '_menu_'+name + ' .' + itemRemoveClass).addClass('selected');
|
||||
$('#' + menu + '_menu_'+name + ' .' + itemAddClass).removeClass('selected');
|
||||
});
|
||||
|
||||
return false;
|
||||
}
|
||||
</script>
|
||||
|
||||
<div class="alert alert-info alert-dismissible fixed-top m-3 p-0 text-center small d-none" id="pageErrors">
|
||||
<span>...</span>
|
||||
<button type="button" class="close py-0" data-dismiss="alert" aria-label="Close">
|
||||
<span aria-hidden="true" class="small" style="cursor:pointer">×</span>
|
||||
</button>
|
||||
</div>
|
||||
|
||||
<!-- Breadcrumbs -->
|
||||
<ol class="breadcrumb">
|
||||
<li class="breadcrumb-item"><a href="./">{lang.R_CPINDEX}</a></li>
|
||||
<li class="breadcrumb-item active">{olang.R_MENUS_TOGGLE}</li>
|
||||
</ol>
|
||||
|
||||
<div class="alert alert-light">{olang.MENU_TOGGLE_EXP}</div>
|
||||
|
||||
<div class="p-3">
|
||||
|
||||
<h4 class="mt-4">{olang.MENU_TOGGLE_TOP_MENU}</h4>
|
||||
|
||||
<ul class="list-group">
|
||||
<LOOP NAME="top_menu_items">
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<div class="col col-md-auto">
|
||||
<h5>{{title}}</h5>
|
||||
</div>
|
||||
<div class="col col-md-auto">
|
||||
<p class="field switch" id="top_menu_{{name}}">
|
||||
<label onclick="toggleMenuItem('{{name}}', 'top', 0, {{hidden}})" class="cb-enable<IF LOOP="hidden == 0"> selected</IF>"><span>{olang.MENU_TOGGLE_SHOW}</span></label>
|
||||
<label onclick="toggleMenuItem('{{name}}', 'top', 1, {{hidden}})" class="cb-disable<IF LOOP="hidden == 1"> selected</IF>"><span>{olang.MENU_TOGGLE_HIDE}</span></label>
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
</LOOP>
|
||||
</ul>
|
||||
|
||||
|
||||
|
||||
<h4 class="mt-5">{olang.MENU_TOGGLE_SIDE_MENU}</h4>
|
||||
|
||||
<ul class="list-group">
|
||||
<LOOP NAME="side_menu_items">
|
||||
<li class="list-group-item d-flex justify-content-between">
|
||||
<div class="col col-md-auto">
|
||||
<h5>{{title}}</h5>
|
||||
</div>
|
||||
<div class="col col-md-auto">
|
||||
<p class="field switch" id="top_menu_{{name}}">
|
||||
<label onclick="toggleMenuItem('{{name}}', 'side', 0, {{hidden}})" class="cb-enable<IF LOOP="hidden == 0"> selected</IF>"><span>{olang.MENU_TOGGLE_SHOW}</span></label>
|
||||
<label onclick="toggleMenuItem('{{name}}', 'side', 1, {{hidden}})" class="cb-disable<IF LOOP="hidden == 1"> selected</IF>"><span>{olang.MENU_TOGGLE_HIDE}</span></label>
|
||||
</p>
|
||||
</div>
|
||||
</li>
|
||||
</LOOP>
|
||||
</ul>
|
||||
</div>
|
||||
BIN
plugins/menu_toggle/icon.png
Normal file
BIN
plugins/menu_toggle/icon.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 86 KiB |
55
plugins/menu_toggle/index.html
Executable file
55
plugins/menu_toggle/index.html
Executable file
@@ -0,0 +1,55 @@
|
||||
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=windows-1256"/>
|
||||
<title>Powered by Kleeja</title>
|
||||
<style type="text/css">* {
|
||||
font-size: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
color: #CECFCE;
|
||||
}
|
||||
|
||||
body {
|
||||
font-family: Tahoma, Arial, sans-serif;
|
||||
font-size: 100%;
|
||||
color: #69788E;
|
||||
margin: 10px 30px;
|
||||
background: #F7F7F7;
|
||||
}
|
||||
|
||||
a:link, a:visited {
|
||||
text-decoration: none;
|
||||
color: #CECFCE;
|
||||
}
|
||||
|
||||
a:active, a:hover {
|
||||
text-decoration: underline;
|
||||
color: #111;
|
||||
}
|
||||
|
||||
h1 {
|
||||
font-family: "Trebuchet MS", Helvetica, sans-serif;
|
||||
font-size: 1.70em;
|
||||
font-weight: normal;
|
||||
color: #333333;
|
||||
margin-top: 0;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.content_box {
|
||||
border: 1px dashed #CECFCE;
|
||||
background: #FFFFFF;
|
||||
padding: 10px;
|
||||
margin-right: auto;
|
||||
margin-left: auto;
|
||||
}</style>
|
||||
</head>
|
||||
<body title="كليجا"><br/>
|
||||
<div class="content_box"><h1><span style="font-size:250%;color:#D80000;">403 - Access forbidden!</span></h1></div>
|
||||
<br/>
|
||||
<div class="content_box"><span style="font-size: 140%">Powered by <a target="_blank"
|
||||
href="http://www.kleeja.com">Kleeja</a></span>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
||||
179
plugins/menu_toggle/init.php
Normal file
179
plugins/menu_toggle/init.php
Normal file
@@ -0,0 +1,179 @@
|
||||
<?php
|
||||
# Kleeja Plugin
|
||||
# menu_toggle
|
||||
# Version: 1.0
|
||||
# Developer: Kleeja team
|
||||
|
||||
# Prevent illegal run
|
||||
if (!defined('IN_PLUGINS_SYSTEM')) {
|
||||
exit();
|
||||
}
|
||||
|
||||
|
||||
# Plugin Basic Information
|
||||
$kleeja_plugin['menu_toggle']['information'] = array(
|
||||
# The casucal name of this plugin, anything can a human being understands
|
||||
'plugin_title' => array(
|
||||
'en' => 'Menu Toggle',
|
||||
'ar' => 'عرض/إخفاء القوائم'
|
||||
),
|
||||
# Who wrote this plugin?
|
||||
'plugin_developer' => 'Kleeja.com',
|
||||
# This plugin version
|
||||
'plugin_version' => '1.1',
|
||||
# Explain what is this plugin, why should I use it?
|
||||
'plugin_description' => array(
|
||||
'en' => 'Ability to hide/show Kleeja Menu items',
|
||||
'ar' => 'القدرة على عرض/إخفاء عناصر قائمة كليجا'
|
||||
),
|
||||
# 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(array(
|
||||
// 'menu_toggle_hide_all' =>
|
||||
// array(
|
||||
// 'value' => '0',
|
||||
// 'plg_id' => $plg_id,
|
||||
// 'type' => 'menu_toggle'
|
||||
// ),
|
||||
'menu_toggle_hidden_topmenu_items' =>
|
||||
array(
|
||||
'value' => '',
|
||||
'plg_id' => $plg_id,
|
||||
'type' => 'menu_toggle'
|
||||
),
|
||||
'menu_toggle_hidden_sidemenu_items' =>
|
||||
array(
|
||||
'value' => '',
|
||||
'plg_id' => $plg_id,
|
||||
'type' => 'menu_toggle'
|
||||
),
|
||||
));
|
||||
|
||||
|
||||
//new language variables
|
||||
add_olang(array(
|
||||
'R_MENUS_TOGGLE' => 'تحكم بقوائم كليجا',
|
||||
'MENU_TOGGLE_EXP' => 'يمكنك التحكم بالعناصر التي تريد عرضها أو إخفائها من قوائم كليجا.',
|
||||
'MENU_TOGGLE_TOP_MENU' => 'القائمة العلوية',
|
||||
'MENU_TOGGLE_SIDE_MENU' => 'القائمة الجانبية',
|
||||
'MENU_TOGGLE_HIDE' => 'إخفاء',
|
||||
'MENU_TOGGLE_SHOW' => 'عرض',
|
||||
|
||||
),
|
||||
'ar',
|
||||
$plg_id);
|
||||
|
||||
add_olang(array(
|
||||
'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_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(array('menu_toggle_hidden_topmenu_items', 'menu_toggle_hidden_sidemenu_items'));
|
||||
};
|
||||
|
||||
|
||||
# Plugin functions
|
||||
$kleeja_plugin['menu_toggle']['functions'] = array(
|
||||
//add to admin menu
|
||||
'begin_admin_page' => function ($args) {
|
||||
$adm_extensions = $args['adm_extensions'];
|
||||
$ext_icons = $args['ext_icons'];
|
||||
|
||||
$adm_extensions[] = 'menus_toggle';
|
||||
$ext_icons['menus_toggle'] = 'list';
|
||||
return compact('adm_extensions', 'ext_icons');
|
||||
},
|
||||
|
||||
//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(array('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 = array();
|
||||
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;
|
||||
}
|
||||
},
|
||||
);
|
||||
|
||||
82
plugins/menu_toggle/menus_toggle.php
Normal file
82
plugins/menu_toggle/menus_toggle.php
Normal file
@@ -0,0 +1,82 @@
|
||||
<?php
|
||||
|
||||
// not for directly open
|
||||
if (! defined('IN_ADMIN'))
|
||||
{
|
||||
exit;
|
||||
}
|
||||
|
||||
#current template
|
||||
$stylee = 'admin_menus_toggle';
|
||||
|
||||
// template variables
|
||||
$styleePath = dirname(__FILE__);
|
||||
|
||||
$H_FORM_KEYS_GET = kleeja_add_form_key_get('adm_menus_toggle');
|
||||
|
||||
$action = basename(ADMIN_PATH) . '?cp=' . basename(__file__, '.php');
|
||||
|
||||
$hidden_side_menu_items = explode(':', $config['menu_toggle_hidden_sidemenu_items']);
|
||||
|
||||
$side_menu_items = array(
|
||||
array('name' => 'profile', 'title' => $lang['PROFILE'], 'hidden' => (int) in_array('profile', $hidden_side_menu_items)),
|
||||
array('name' => 'fileuser', 'title' => $lang['YOUR_FILEUSER'], 'hidden' => (int) in_array('fileuser', $hidden_side_menu_items)),
|
||||
array('name' => 'logout', 'title' => $lang['LOGOUT'], 'hidden' => (int) in_array('logout', $hidden_side_menu_items)),
|
||||
array('name' => 'login', 'title' => $lang['LOGIN'], 'hidden' => (int) in_array('login', $hidden_side_menu_items)),
|
||||
array('name' => 'register', 'title' => $lang['REGISTER'], 'hidden' => (int) in_array('register', $hidden_side_menu_items)),
|
||||
);
|
||||
|
||||
$hidden_top_menu_items = explode(':', $config['menu_toggle_hidden_topmenu_items']);
|
||||
|
||||
$top_menu_items = array(
|
||||
array('name' => 'index', 'title' => $lang['INDEX'], 'hidden' => (int) in_array('index', $hidden_top_menu_items)),
|
||||
array('name' => 'rules', 'title' => $lang['RULES'], 'hidden' => (int) in_array('rules', $hidden_top_menu_items)),
|
||||
array('name' => 'guide', 'title' => $lang['GUIDE'], 'hidden' => (int) in_array('guide', $hidden_top_menu_items)),
|
||||
array('name' => 'stats', 'title' => $lang['STATS'], 'hidden' => (int) in_array('stats', $hidden_top_menu_items)),
|
||||
array('name' => 'report', 'title' => $lang['REPORT'], 'hidden' => (int) in_array('report', $hidden_top_menu_items)),
|
||||
array('name' => 'call', 'title' => $lang['CALL'], 'hidden' => (int) in_array('call', $hidden_top_menu_items)),
|
||||
);
|
||||
|
||||
|
||||
if(ig('toggle'))
|
||||
{
|
||||
if (! kleeja_check_form_key_get('adm_menus_toggle', 3600))
|
||||
{
|
||||
header('HTTP/1.1 405 Method Not Allowed');
|
||||
$adminAjaxContent = $lang['INVALID_FORM_KEY'];
|
||||
}
|
||||
else
|
||||
{
|
||||
$name = g('name');
|
||||
$menu = g('menu');
|
||||
$hide = g('toggle', 'int') == 1;
|
||||
|
||||
toggleMenuItem($name, $menu, $hide);
|
||||
|
||||
$adminAjaxContent = $lang['CONFIGS_UPDATED'];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
function toggleMenuItem($name, $menu, $hide)
|
||||
{
|
||||
global $config;
|
||||
|
||||
$items = explode(':', $config['menu_toggle_hidden_'.$menu.'menu_items']);
|
||||
$items = array_filter($items);
|
||||
|
||||
if(in_array($name, $items) && ! $hide)
|
||||
{
|
||||
$new_items = array_diff($items, [$name]);
|
||||
}
|
||||
else if($hide)
|
||||
{
|
||||
$new_items = $items;
|
||||
$new_items[] = $name;
|
||||
}
|
||||
|
||||
if($new_items != $items)
|
||||
{
|
||||
update_config('menu_toggle_hidden_' . $menu . 'menu_items', implode(':', $new_items));
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user