From 3766aa9935b1cc4b069744c313c9b667c9061ec0 Mon Sep 17 00:00:00 2001 From: mistic100 Date: Mon, 4 Aug 2014 21:07:41 +0000 Subject: add MultiView controller on admin page (replaces the "switch theme" button) git-svn-id: http://piwigo.org/svn/trunk@29168 68402e56-0260-453c-a942-63ccdbb3a9ee --- plugins/AdminTools/include/MultiView.class.php | 32 +++++++++++++++++-- plugins/AdminTools/include/events.inc.php | 44 ++++++++++++++++++++++++++ 2 files changed, 74 insertions(+), 2 deletions(-) (limited to 'plugins/AdminTools/include') 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 @@ -174,6 +174,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 = '{\'Change Admin Colors\'|translate}'; + $replace = '{\'Tools\'|translate}'; + return str_replace($search, $replace, $content); +} + /** * Disable privacy level switchbox */ -- cgit v1.2.3