aboutsummaryrefslogtreecommitdiffstats
path: root/plugins/AdminTools
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--plugins/AdminTools/include/MultiView.class.php32
-rw-r--r--plugins/AdminTools/include/events.inc.php44
-rw-r--r--plugins/AdminTools/main.inc.php1
-rw-r--r--plugins/AdminTools/template/admin_controller.js118
-rw-r--r--plugins/AdminTools/template/admin_controller.tpl39
-rw-r--r--plugins/AdminTools/template/admin_style.css67
-rw-r--r--plugins/AdminTools/template/public_controller.tpl2
-rw-r--r--plugins/AdminTools/template/public_style.css (renamed from plugins/AdminTools/template/style.css)0
8 files changed, 300 insertions, 3 deletions
diff --git a/plugins/AdminTools/include/MultiView.class.php b/plugins/AdminTools/include/MultiView.class.php
index 889ba457f..56240b811 100644
--- a/plugins/AdminTools/include/MultiView.class.php
+++ b/plugins/AdminTools/include/MultiView.class.php
@@ -101,6 +101,31 @@ class MultiView
return $url;
}
+
+ /**
+ * Returns the current url minus MultiView params
+ *
+ * @param bool $with_amp - adds ? or & at the end of the url
+ * @return string
+ */
+ public function get_clean_admin_url($with_amp=false)
+ {
+ $url = PHPWG_ROOT_PATH.'admin.php';
+
+ $get = $_GET;
+ unset($get['page'], $get['section'], $get['tag']);
+ if (count($get) == 0 and !empty($_SERVER['QUERY_STRING']))
+ {
+ $url.= '?' . str_replace('&', '&', $_SERVER['QUERY_STRING']);
+ }
+
+ if ($with_amp)
+ {
+ $url.= strpos($url, '?')!==false ? '&' : '?';
+ }
+
+ return $url;
+ }
/**
* Triggered on "user_init", change current view depending of URL params.
@@ -277,8 +302,11 @@ class MultiView
$query = '
SELECT
'.$conf['user_fields']['id'].' AS id,
- '.$conf['user_fields']['username'].' AS username
-FROM '.USERS_TABLE.'
+ '.$conf['user_fields']['username'].' AS username,
+ status
+FROM '.USERS_TABLE.' AS u
+ INNER JOIN '.USER_INFOS_TABLE.' AS i
+ ON '.$conf['user_fields']['id'].' = user_id
ORDER BY CONVERT('.$conf['user_fields']['username'].', CHAR)
;';
$out['users'] = array_from_query($query);
diff --git a/plugins/AdminTools/include/events.inc.php b/plugins/AdminTools/include/events.inc.php
index 77c6a8c67..5bdfa1baa 100644
--- a/plugins/AdminTools/include/events.inc.php
+++ b/plugins/AdminTools/include/events.inc.php
@@ -175,6 +175,50 @@ SELECT * FROM '.IMAGES_TABLE.'
}
/**
+ * Add main toolbar to current page
+ * @trigger loc_after_page_header
+ */
+function admintools_add_admin_controller()
+{
+ global $MultiView, $conf, $template, $page, $user;
+
+ $url_root = get_root_url();
+ $tpl_vars = array();
+
+ $tpl_vars['MULTIVIEW'] = $MultiView->get_data();
+ $tpl_vars['DELETE_CACHE'] = isset($conf['multiview_invalidate_cache']);
+ $tpl_vars['U_SELF'] = $MultiView->get_clean_admin_url(true);
+
+ if (($admin_lang = $MultiView->get_user_language()) !== false)
+ {
+ include_once(PHPWG_ROOT_PATH . 'include/functions_mail.inc.php');
+ switch_lang_to($admin_lang);
+ }
+
+ $template->assign(array(
+ 'ADMINTOOLS_PATH' => './plugins/' . ADMINTOOLS_ID .'/',
+ 'ato' => $tpl_vars,
+ ));
+
+ $template->set_filename('ato_admin_controller', realpath(ADMINTOOLS_PATH . 'template/admin_controller.tpl'));
+ $template->parse('ato_admin_controller');
+
+ if ($MultiView->is_admin() && @$admin_lang !== false)
+ {
+ switch_lang_back();
+ }
+
+ $template->set_prefilter('header', 'admintools_admin_prefilter');
+}
+
+function admintools_admin_prefilter($content)
+{
+ $search = '<a class="icon-brush tiptip" href="{$U_CHANGE_THEME}" title="{\'Switch to clear or dark colors for administration\'|translate}">{\'Change Admin Colors\'|translate}</a>';
+ $replace = '<span id="ato_container"><a class="icon-cog-alt" href="#">{\'Tools\'|translate}</a></span>';
+ return str_replace($search, $replace, $content);
+}
+
+/**
* Disable privacy level switchbox
*/
function admintools_remove_privacy($content)
diff --git a/plugins/AdminTools/main.inc.php b/plugins/AdminTools/main.inc.php
index c84e46521..692ca5d27 100644
--- a/plugins/AdminTools/main.inc.php
+++ b/plugins/AdminTools/main.inc.php
@@ -38,6 +38,7 @@ if (!defined('IN_ADMIN'))
}
else
{
+ add_event_handler('loc_begin_page_header', 'admintools_add_admin_controller');
add_event_handler('get_admin_plugin_menu_links', 'admintools_admin_link');
}
diff --git a/plugins/AdminTools/template/admin_controller.js b/plugins/AdminTools/template/admin_controller.js
new file mode 100644
index 000000000..73f7b1096
--- /dev/null
+++ b/plugins/AdminTools/template/admin_controller.js
@@ -0,0 +1,118 @@
+var AdminTools = function($) {
+ var __this = this;
+
+ this.urlWS;
+ this.urlSelf;
+ this.multiView;
+
+ var $ato = $('#ato_container');
+
+ // fill multiview selects
+ // data came from AJAX request or sessionStorage
+ function populateMultiView() {
+ var $multiview = $ato.find('.multiview');
+
+ if ($multiview.data('init')) return;
+
+ var render = function(data) {
+ var html = '';
+ $.each(data.users, function(i, user) {
+ if (user.status == 'webmaster' || user.status == 'admin') {
+ html+= '<option value="'+ user.id +'">'+ user.username +'</option>';
+ }
+ });
+ $multiview.find('select[data-type="view_as"]').html(html)
+ .val(__this.multiView.view_as);
+
+ html = '';
+ $.each(['clear','roma'], function(i, theme) {
+ html+= '<option value="'+ theme +'">'+ theme +'</option>';
+ });
+ $multiview.find('select[data-type="theme"]').html(html)
+ .val(__this.multiView.theme);
+
+ html = '';
+ $.each(data.languages, function(i, language) {
+ html+= '<option value="'+ language.id +'">'+ language.name +'</option>';
+ });
+ $multiview.find('select[data-type="lang"]').html(html)
+ .val(__this.multiView.lang);
+
+ $multiview.data('init', true);
+
+ $multiview.find('.switcher').show();
+ };
+
+ if ('sessionStorage' in window && window.sessionStorage.multiView != undefined) {
+ render(JSON.parse(window.sessionStorage.multiView));
+ }
+ else {
+ $.ajax({
+ method: 'POST',
+ url: __this.urlWS + 'multiView.getData',
+ dataType: 'json',
+ success: function(data) {
+ render(data.result);
+ if ('sessionStorage' in window) {
+ window.sessionStorage.multiView = JSON.stringify(data.result);
+ }
+ },
+ error: function(xhr, text, error) {
+ alert(text + ' ' + error);
+ }
+ });
+ }
+ }
+
+ // delete session cache
+ this.deleteCache = function() {
+ if ('sessionStorage' in window) {
+ window.sessionStorage.removeItem('multiView');
+ }
+ };
+
+ // attach jquery handlers
+ this.init = function(open) {
+ $('.multiview').appendTo($ato);
+
+ /* <!-- sub menus --> */
+ $ato.on({
+ 'click': function(e) {
+ populateMultiView();
+ $(this).find('ul').toggle();
+ },
+ 'mouseleave': function(e) {
+ if (e.target.tagName.toLowerCase() != "select") {
+ $(this).find('ul').hide();
+ }
+ }
+ });
+ $ato.find('>a').on('click', function(e) {
+ e.preventDefault();
+ });
+ $ato.find('ul').on('mouseleave', function(e) {
+ if (e.target.tagName.toLowerCase() != "select") {
+ $(this).hide();
+ }
+ });
+
+ /* <!-- select boxes --> */
+ $ato.find('.switcher').on({
+ 'change': function() {
+ if ($(this).data('type') == 'theme') {
+ if ($(this).val() != __this.multiView.theme) {
+ window.location.href = __this.urlSelf + 'change_theme=1';
+ }
+ }
+ else {
+ window.location.href = __this.urlSelf + 'ato_'+ $(this).data('type') +'='+ $(this).val();
+ }
+ },
+ 'click': function(e) {
+ e.stopPropagation();
+ }
+ });
+ };
+
+ return this;
+}(jQuery); \ No newline at end of file
diff --git a/plugins/AdminTools/template/admin_controller.tpl b/plugins/AdminTools/template/admin_controller.tpl
new file mode 100644
index 000000000..ddc0bc2c9
--- /dev/null
+++ b/plugins/AdminTools/template/admin_controller.tpl
@@ -0,0 +1,39 @@
+{strip}
+{combine_css path=$ADMINTOOLS_PATH|cat:'template/admin_style.css'}
+{combine_css path=$ADMINTOOLS_PATH|cat:'template/fontello/css/fontello-ato.css'}
+{combine_script id='admintools.controller' load='footer' require='jquery' path=$ADMINTOOLS_PATH|cat:'template/admin_controller.js'}
+{/strip}
+
+{footer_script require='admintools.controller'}
+AdminTools.urlWS = '{$ROOT_URL}ws.php?format=json&method=';
+AdminTools.urlSelf = '{$ato.U_SELF}';
+
+AdminTools.multiView = {
+ view_as: {$ato.MULTIVIEW.view_as},
+ theme: '{$themeconf.name}',
+ lang: '{$ato.MULTIVIEW.lang}'
+};
+
+{if $ato.DELETE_CACHE}
+ AdminTools.deleteCache();
+{/if}
+ AdminTools.init();
+{/footer_script}
+
+<ul class="multiview">
+ <li><label>{'View as'|translate}</label>
+ <select class="switcher" data-type="view_as"></select>
+ </li>
+ <li><label>{'Theme'|translate}</label>
+ <select class="switcher" data-type="theme"></select>
+ </li>
+ <li><label>{'Language'|translate}</label>
+ <select class="switcher" data-type="lang"></select>
+ </li>
+ <li><a class="icon-check{if !$ato.MULTIVIEW.show_queries}-empty{/if}" href="{$ato.U_SELF}ato_show_queries={(int)!$ato.MULTIVIEW.show_queries}">{'Show SQL queries'|translate}</a></li>
+ <li><a class="icon-check{if !$ato.MULTIVIEW.debug_l10n}-empty{/if}" href="{$ato.U_SELF}ato_debug_l10n={(int)!$ato.MULTIVIEW.debug_l10n}">{'Debug languages'|translate}</a></li>
+ <li><a class="icon-check{if !$ato.MULTIVIEW.debug_template}-empty{/if}" href="{$ato.U_SELF}ato_debug_template={(int)!$ato.MULTIVIEW.debug_template}">{'Debug template'|translate}</a></li>
+ <li><a class="icon-check{if !$ato.MULTIVIEW.template_combine_files}-empty{/if}" href="{$ato.U_SELF}ato_template_combine_files={(int)!$ato.MULTIVIEW.template_combine_files}">{'Combine JS&CSS'|translate}</a></li>
+ <li><a class="icon-check{if $ato.MULTIVIEW.no_history}-empty{/if}" href="{$ato.U_SELF}ato_no_history={(int)!$ato.MULTIVIEW.no_history}">{'Save visit in history'|translate}</a></li>
+ <li><a class="icon-ato-null" href="{$ato.U_SELF}ato_purge_template=1">{'Purge compiled templates'|translate}</a></li>
+</ul> \ No newline at end of file
diff --git a/plugins/AdminTools/template/admin_style.css b/plugins/AdminTools/template/admin_style.css
new file mode 100644
index 000000000..e15f4aead
--- /dev/null
+++ b/plugins/AdminTools/template/admin_style.css
@@ -0,0 +1,67 @@
+.icon-ato-null:before { content:' '; }
+
+#ato_container {
+ display:inline-block;
+ position:relative;
+}
+
+.multiview {
+ display:none;
+}
+
+#ato_container>ul {
+ position:absolute;
+ top:27px;
+ left:auto;
+ right:0;
+ background:#fefefe;
+ padding:0;
+ margin:0;
+ box-shadow:3px 3px 5px rgba(0,0,0,0.5);
+}
+ #ato_container>ul li {
+ list-style:none;
+ line-height:16px;
+ font-size:13px;
+ white-space:nowrap;
+ }
+ #ato_container>ul li>* {
+ display:inline-block;
+ padding:5px 10px;
+ border:none;
+ text-decoration:none;
+ color:#444;
+ text-shadow:1px 1px 0px #eee;
+ }
+ #ato_container>ul li>*:before {
+ font-size:16px;
+ margin-right:0.5em;
+ }
+ #ato_container>ul li:hover {
+ background:#dedede;
+ }
+ #ato_container>ul label {
+ font-weight:bold;
+ color:#777;
+ display:inline-block;
+ width:80px;
+ padding:5px;
+ text-align:right;
+ font-size:11px;
+ }
+ #ato_container>ul select, #ato_container>ul option {
+ font-size:13px;
+ line-height:15px;
+ color:#444;
+ background:#fefefe;
+ border-radius:2px;
+ text-shadow:none;
+ }
+ #ato_container>ul select {
+ border:1px solid #777;
+ height:22px;
+ padding:2px 3px;
+ }
+ #ato_container .switcher {
+ display:none;
+ } \ No newline at end of file
diff --git a/plugins/AdminTools/template/public_controller.tpl b/plugins/AdminTools/template/public_controller.tpl
index 8fd12dcf0..f234880df 100644
--- a/plugins/AdminTools/template/public_controller.tpl
+++ b/plugins/AdminTools/template/public_controller.tpl
@@ -1,5 +1,5 @@
{strip}
-{combine_css path=$ADMINTOOLS_PATH|cat:'template/style.css'}
+{combine_css path=$ADMINTOOLS_PATH|cat:'template/public_style.css'}
{combine_css path='admin/themes/default/fontello/css/fontello.css'}
{combine_css path=$ADMINTOOLS_PATH|cat:'template/fontello/css/fontello-ato.css'}
diff --git a/plugins/AdminTools/template/style.css b/plugins/AdminTools/template/public_style.css
index 9b10158c2..9b10158c2 100644
--- a/plugins/AdminTools/template/style.css
+++ b/plugins/AdminTools/template/public_style.css