From 3346a0c90fe083d48836f6af3d6b0841adb17689 Mon Sep 17 00:00:00 2001 From: Dmitriy Simushev Date: Tue, 3 Jun 2014 13:13:35 +0000 Subject: [PATCH] Remove "setup_settings_tabs" function --- .../Settings/AbstractController.php | 59 +++++++++++++++++++ .../Controller/Settings/CommonController.php | 3 +- .../Settings/FeaturesController.php | 3 +- .../Settings/PerformanceController.php | 3 +- src/mibew/libs/init.php | 1 - src/mibew/libs/settings.php | 45 -------------- 6 files changed, 62 insertions(+), 52 deletions(-) create mode 100644 src/mibew/libs/classes/Mibew/Controller/Settings/AbstractController.php delete mode 100644 src/mibew/libs/settings.php diff --git a/src/mibew/libs/classes/Mibew/Controller/Settings/AbstractController.php b/src/mibew/libs/classes/Mibew/Controller/Settings/AbstractController.php new file mode 100644 index 00000000..010a6327 --- /dev/null +++ b/src/mibew/libs/classes/Mibew/Controller/Settings/AbstractController.php @@ -0,0 +1,59 @@ +attributes->get('_route'); + + $common = $route == 'settings_common' || $route == 'settings_common_save'; + $features = $route == 'settings_features' || $route == 'settings_features_save'; + $performance = $route == 'settings_performance' || $route == 'settings_performance_save'; + + + $tabs[getlocal('page_settings.tab.main')] = (!$common) + ? $this->generateUrl('settings_common') + : ''; + + $tabs[getlocal('page_settings.tab.features')] = (!$features) + ? $this->generateUrl('settings_features') + : ''; + + $tabs[getlocal('page_settings.tab.performance')] = (!$performance) + ? $this->generateUrl('settings_performance') + : ''; + + return $tabs; + } +} diff --git a/src/mibew/libs/classes/Mibew/Controller/Settings/CommonController.php b/src/mibew/libs/classes/Mibew/Controller/Settings/CommonController.php index dfbfb747..fabec1fe 100644 --- a/src/mibew/libs/classes/Mibew/Controller/Settings/CommonController.php +++ b/src/mibew/libs/classes/Mibew/Controller/Settings/CommonController.php @@ -17,7 +17,6 @@ namespace Mibew\Controller\Settings; -use Mibew\Controller\AbstractController; use Mibew\Http\Exception\BadRequestException; use Mibew\Settings; use Mibew\Style\ChatStyle; @@ -104,7 +103,7 @@ class CommonController extends AbstractController $page['menuid'] = 'settings'; $page = array_merge($page, prepare_menu($operator)); - $page['tabs'] = setup_settings_tabs(0); + $page['tabs'] = $this->buildTabs($request); return $this->render('settings_common', $page); } diff --git a/src/mibew/libs/classes/Mibew/Controller/Settings/FeaturesController.php b/src/mibew/libs/classes/Mibew/Controller/Settings/FeaturesController.php index a323e93a..5ca6d644 100644 --- a/src/mibew/libs/classes/Mibew/Controller/Settings/FeaturesController.php +++ b/src/mibew/libs/classes/Mibew/Controller/Settings/FeaturesController.php @@ -17,7 +17,6 @@ namespace Mibew\Controller\Settings; -use Mibew\Controller\AbstractController; use Mibew\Settings; use Symfony\Component\HttpFoundation\Request; @@ -58,7 +57,7 @@ class FeaturesController extends AbstractController $page['title'] = getlocal('settings.title'); $page['menuid'] = 'settings'; $page = array_merge($page, prepare_menu($operator)); - $page['tabs'] = setup_settings_tabs(1); + $page['tabs'] = $this->buildTabs($request); return $this->render('settings_features', $page); } diff --git a/src/mibew/libs/classes/Mibew/Controller/Settings/PerformanceController.php b/src/mibew/libs/classes/Mibew/Controller/Settings/PerformanceController.php index 0cc7133d..38ff6db4 100644 --- a/src/mibew/libs/classes/Mibew/Controller/Settings/PerformanceController.php +++ b/src/mibew/libs/classes/Mibew/Controller/Settings/PerformanceController.php @@ -17,7 +17,6 @@ namespace Mibew\Controller\Settings; -use Mibew\Controller\AbstractController; use Mibew\Settings; use Symfony\Component\HttpFoundation\Request; @@ -91,7 +90,7 @@ class PerformanceController extends AbstractController $page['menuid'] = "settings"; $page = array_merge($page, prepare_menu($operator)); - $page['tabs'] = setup_settings_tabs(2); + $page['tabs'] = $this->buildTabs($request); return $this->render('settings_performance', $page); } diff --git a/src/mibew/libs/init.php b/src/mibew/libs/init.php index 568e1f90..b9dd60fd 100644 --- a/src/mibew/libs/init.php +++ b/src/mibew/libs/init.php @@ -107,6 +107,5 @@ require_once(MIBEW_FS_ROOT . '/libs/notify.php'); require_once(MIBEW_FS_ROOT . '/libs/operator.php'); require_once(MIBEW_FS_ROOT . '/libs/pagination.php'); require_once(MIBEW_FS_ROOT . '/libs/statistics.php'); -require_once(MIBEW_FS_ROOT . '/libs/settings.php'); require_once(MIBEW_FS_ROOT . '/libs/track.php'); require_once(MIBEW_FS_ROOT . '/libs/userinfo.php'); diff --git a/src/mibew/libs/settings.php b/src/mibew/libs/settings.php deleted file mode 100644 index d927d2bc..00000000 --- a/src/mibew/libs/settings.php +++ /dev/null @@ -1,45 +0,0 @@ - ($active != 0 - ? (MIBEW_WEB_ROOT . "/operator/settings") - : ""), - getlocal("page_settings.tab.features") => ($active != 1 - ? (MIBEW_WEB_ROOT . "/operator/settings/features") - : ""), - getlocal("page_settings.tab.performance") => ($active != 2 - ? (MIBEW_WEB_ROOT . "/operator/settings/performance") - : ""), - ); - - return $tabs; -}