diff options
author | Thomas Steur <thomas.steur@googlemail.com> | 2014-05-20 02:07:40 +0400 |
---|---|---|
committer | Thomas Steur <thomas.steur@googlemail.com> | 2014-05-20 02:07:40 +0400 |
commit | 009a6f21177e8cb6366577d8f54024e896bb0d8e (patch) | |
tree | 70edeaf31d0b59acff6f22f47e1847349bc6728c /plugins | |
parent | 84a7e582a45a8c65b34035819a23c6e1b59794be (diff) |
refs #5192 starting a little Menu refactoring
Diffstat (limited to 'plugins')
31 files changed, 149 insertions, 126 deletions
diff --git a/plugins/API/API.php b/plugins/API/API.php index 6d2b0e4e46..dd0d2f9aeb 100644 --- a/plugins/API/API.php +++ b/plugins/API/API.php @@ -699,17 +699,17 @@ class Plugin extends \Piwik\Plugin ); } - public function addTopMenu() + public function addTopMenu(MenuTop $menu) { $apiUrlParams = array('module' => 'API', 'action' => 'listAllAPI', 'segment' => false); - $tooltip = Piwik::translate('API_TopLinkTooltip'); + $tooltip = Piwik::translate('API_TopLinkTooltip'); - MenuTop::addEntry('General_API', $apiUrlParams, true, 7, $isHTML = false, $tooltip); + $menu->add('General_API', null, $apiUrlParams, true, 7, $tooltip); - $this->addTopMenuMobileApp(); + $this->addTopMenuMobileApp($menu); } - protected function addTopMenuMobileApp() + protected function addTopMenuMobileApp(MenuTop $menu) { if (empty($_SERVER['HTTP_USER_AGENT'])) { return; @@ -722,7 +722,7 @@ class Plugin extends \Piwik\Plugin $ua->parse(); $os = $ua->getOs('short_name'); if ($os && in_array($os, array('AND', 'IOS'))) { - MenuTop::addEntry('Piwik Mobile App', array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4); + $menu->add('Piwik Mobile App', null, array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4); } } diff --git a/plugins/Actions/Actions.php b/plugins/Actions/Actions.php index 08e1d682a5..38e4f56519 100644 --- a/plugins/Actions/Actions.php +++ b/plugins/Actions/Actions.php @@ -12,6 +12,7 @@ use Piwik\API\Request; use Piwik\ArchiveProcessor; use Piwik\Common; use Piwik\Db; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\MetricsFormatter; use Piwik\Piwik; @@ -485,18 +486,18 @@ class Actions extends \Piwik\Plugin } } - function addMenus() + function addMenus(MenuAbstract $menu) { - MenuMain::getInstance()->add('General_Actions', '', array('module' => 'Actions', 'action' => 'indexPageUrls'), true, 15); - MenuMain::getInstance()->add('General_Actions', 'General_Pages', array('module' => 'Actions', 'action' => 'indexPageUrls'), true, 1); - MenuMain::getInstance()->add('General_Actions', 'Actions_SubmenuPagesEntry', array('module' => 'Actions', 'action' => 'indexEntryPageUrls'), true, 2); - MenuMain::getInstance()->add('General_Actions', 'Actions_SubmenuPagesExit', array('module' => 'Actions', 'action' => 'indexExitPageUrls'), true, 3); - MenuMain::getInstance()->add('General_Actions', 'Actions_SubmenuPageTitles', array('module' => 'Actions', 'action' => 'indexPageTitles'), true, 4); - MenuMain::getInstance()->add('General_Actions', 'General_Outlinks', array('module' => 'Actions', 'action' => 'indexOutlinks'), true, 6); - MenuMain::getInstance()->add('General_Actions', 'General_Downloads', array('module' => 'Actions', 'action' => 'indexDownloads'), true, 7); + $menu->add('General_Actions', '', array('module' => 'Actions', 'action' => 'indexPageUrls'), true, 15); + $menu->add('General_Actions', 'General_Pages', array('module' => 'Actions', 'action' => 'indexPageUrls'), true, 1); + $menu->add('General_Actions', 'Actions_SubmenuPagesEntry', array('module' => 'Actions', 'action' => 'indexEntryPageUrls'), true, 2); + $menu->add('General_Actions', 'Actions_SubmenuPagesExit', array('module' => 'Actions', 'action' => 'indexExitPageUrls'), true, 3); + $menu->add('General_Actions', 'Actions_SubmenuPageTitles', array('module' => 'Actions', 'action' => 'indexPageTitles'), true, 4); + $menu->add('General_Actions', 'General_Outlinks', array('module' => 'Actions', 'action' => 'indexOutlinks'), true, 6); + $menu->add('General_Actions', 'General_Downloads', array('module' => 'Actions', 'action' => 'indexDownloads'), true, 7); if ($this->isSiteSearchEnabled()) { - MenuMain::getInstance()->add('General_Actions', 'Actions_SubmenuSitesearch', array('module' => 'Actions', 'action' => 'indexSiteSearch'), true, 5); + $menu->add('General_Actions', 'Actions_SubmenuSitesearch', array('module' => 'Actions', 'action' => 'indexSiteSearch'), true, 5); } } diff --git a/plugins/CoreAdminHome/CoreAdminHome.php b/plugins/CoreAdminHome/CoreAdminHome.php index f750f449b2..9291bc948f 100644 --- a/plugins/CoreAdminHome/CoreAdminHome.php +++ b/plugins/CoreAdminHome/CoreAdminHome.php @@ -12,6 +12,7 @@ use Piwik\DataAccess\ArchiveSelector; use Piwik\DataAccess\ArchiveTableCreator; use Piwik\Date; use Piwik\Db; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuAdmin; use Piwik\Piwik; use Piwik\ScheduledTask; @@ -86,21 +87,21 @@ class CoreAdminHome extends \Piwik\Plugin $jsFiles[] = "plugins/CoreAdminHome/javascripts/pluginSettings.js"; } - function addMenu() + function addMenu(MenuAbstract $menu) { - MenuAdmin::getInstance()->add('CoreAdminHome_MenuManage', null, "", Piwik::isUserHasSomeAdminAccess(), $order = 1); - MenuAdmin::getInstance()->add('CoreAdminHome_MenuDiagnostic', null, "", Piwik::isUserHasSomeAdminAccess(), $order = 10); - MenuAdmin::getInstance()->add('General_Settings', null, "", Piwik::isUserHasSomeAdminAccess(), $order = 5); - MenuAdmin::getInstance()->add('General_Settings', 'CoreAdminHome_MenuGeneralSettings', + $menu->add('CoreAdminHome_MenuManage', null, "", Piwik::isUserHasSomeAdminAccess(), $order = 1); + $menu->add('CoreAdminHome_MenuDiagnostic', null, "", Piwik::isUserHasSomeAdminAccess(), $order = 10); + $menu->add('General_Settings', null, "", Piwik::isUserHasSomeAdminAccess(), $order = 5); + $menu->add('General_Settings', 'CoreAdminHome_MenuGeneralSettings', array('module' => 'CoreAdminHome', 'action' => 'generalSettings'), Piwik::isUserHasSomeAdminAccess(), $order = 6); - MenuAdmin::getInstance()->add('CoreAdminHome_MenuManage', 'CoreAdminHome_TrackingCode', + $menu->add('CoreAdminHome_MenuManage', 'CoreAdminHome_TrackingCode', array('module' => 'CoreAdminHome', 'action' => 'trackingCodeGenerator'), Piwik::isUserHasSomeAdminAccess(), $order = 4); - MenuAdmin::getInstance()->add('General_Settings', 'CoreAdminHome_PluginSettings', + $menu->add('General_Settings', 'CoreAdminHome_PluginSettings', array('module' => 'CoreAdminHome', 'action' => 'pluginSettings'), SettingsManager::hasPluginsSettingsForCurrentUser(), $order = 7); diff --git a/plugins/CorePluginsAdmin/CorePluginsAdmin.php b/plugins/CorePluginsAdmin/CorePluginsAdmin.php index cd38921093..1e8f9537a2 100644 --- a/plugins/CorePluginsAdmin/CorePluginsAdmin.php +++ b/plugins/CorePluginsAdmin/CorePluginsAdmin.php @@ -9,6 +9,7 @@ namespace Piwik\Plugins\CorePluginsAdmin; use Piwik\Config; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuAdmin; use Piwik\Piwik; use Piwik\Plugin; @@ -71,7 +72,7 @@ class CorePluginsAdmin extends \Piwik\Plugin $stylesheets[] = "plugins/CorePluginsAdmin/stylesheets/plugins_admin.less"; } - function addMenu() + function addMenu(MenuAbstract $menu) { $pluginsUpdateMessage = ''; $themesUpdateMessage = ''; @@ -89,19 +90,19 @@ class CorePluginsAdmin extends \Piwik\Plugin } } - MenuAdmin::getInstance()->add('CorePluginsAdmin_MenuPlatform', null, "", !Piwik::isUserIsAnonymous(), $order = 7); - MenuAdmin::getInstance()->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('General_Plugins') . $pluginsUpdateMessage, + $menu->add('CorePluginsAdmin_MenuPlatform', null, "", !Piwik::isUserIsAnonymous(), $order = 7); + $menu->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('General_Plugins') . $pluginsUpdateMessage, array('module' => 'CorePluginsAdmin', 'action' => 'plugins', 'activated' => ''), Piwik::hasUserSuperUserAccess(), $order = 1); - MenuAdmin::getInstance()->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('CorePluginsAdmin_Themes') . $themesUpdateMessage, + $menu->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('CorePluginsAdmin_Themes') . $themesUpdateMessage, array('module' => 'CorePluginsAdmin', 'action' => 'themes', 'activated' => ''), Piwik::hasUserSuperUserAccess(), $order = 3); if (static::isMarketplaceEnabled()) { - MenuAdmin::getInstance()->add('CorePluginsAdmin_MenuPlatform', 'CorePluginsAdmin_Marketplace', + $menu->add('CorePluginsAdmin_MenuPlatform', 'CorePluginsAdmin_Marketplace', array('module' => 'CorePluginsAdmin', 'action' => 'extend', 'activated' => ''), !Piwik::isUserIsAnonymous(), $order = 5); diff --git a/plugins/CustomVariables/CustomVariables.php b/plugins/CustomVariables/CustomVariables.php index 8efed3ce7b..fc1642ef71 100644 --- a/plugins/CustomVariables/CustomVariables.php +++ b/plugins/CustomVariables/CustomVariables.php @@ -9,6 +9,7 @@ namespace Piwik\Plugins\CustomVariables; use Piwik\ArchiveProcessor; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; @@ -48,9 +49,9 @@ class CustomVariables extends \Piwik\Plugin WidgetsList::add('General_Visitors', 'CustomVariables_CustomVariables', 'CustomVariables', 'getCustomVariables'); } - public function addMenus() + public function addMenus(MenuAbstract $menu) { - MenuMain::getInstance()->add('General_Visitors', 'CustomVariables_CustomVariables', array('module' => 'CustomVariables', 'action' => 'index'), $display = true, $order = 50); + $menu->add('General_Visitors', 'CustomVariables_CustomVariables', array('module' => 'CustomVariables', 'action' => 'index'), $display = true, $order = 50); } public function install() diff --git a/plugins/DBStats/DBStats.php b/plugins/DBStats/DBStats.php index d2a843e690..4b95c95f1c 100644 --- a/plugins/DBStats/DBStats.php +++ b/plugins/DBStats/DBStats.php @@ -9,6 +9,7 @@ namespace Piwik\Plugins\DBStats; use Piwik\Date; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuAdmin; use Piwik\Option; use Piwik\Piwik; @@ -41,9 +42,9 @@ class DBStats extends \Piwik\Plugin ); } - function addMenu() + function addMenu(MenuAbstract $menu) { - MenuAdmin::getInstance()->add('CoreAdminHome_MenuDiagnostic', 'DBStats_DatabaseUsage', + $menu->add('CoreAdminHome_MenuDiagnostic', 'DBStats_DatabaseUsage', array('module' => 'DBStats', 'action' => 'index'), Piwik::hasUserSuperUserAccess(), $order = 6); diff --git a/plugins/Dashboard/Dashboard.php b/plugins/Dashboard/Dashboard.php index 4fe9d81f2b..ee62279110 100644 --- a/plugins/Dashboard/Dashboard.php +++ b/plugins/Dashboard/Dashboard.php @@ -12,6 +12,7 @@ use Exception; use Piwik\Common; use Piwik\Db; use Piwik\DbHelper; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\Menu\MenuTop; use Piwik\Piwik; @@ -196,9 +197,9 @@ class Dashboard extends \Piwik\Plugin return Common::json_encode($layout); } - public function addMenus() + public function addMenus(MenuAbstract $menu) { - MenuMain::getInstance()->add('Dashboard_Dashboard', '', array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => 1), true, 5); + $menu->add('Dashboard_Dashboard', '', array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => 1), true, 5); if (!Piwik::isUserIsAnonymous()) { $login = Piwik::getCurrentUserLogin(); @@ -207,13 +208,13 @@ class Dashboard extends \Piwik\Plugin $pos = 0; foreach ($dashboards as $dashboard) { - MenuMain::getInstance()->add('Dashboard_Dashboard', $dashboard['name'], array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => $dashboard['iddashboard']), true, $pos); + $menu->add('Dashboard_Dashboard', $dashboard['name'], array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => $dashboard['iddashboard']), true, $pos); $pos++; } } } - public function addTopMenu() + public function addTopMenu(MenuTop $menu) { $tooltip = false; try { @@ -224,7 +225,7 @@ class Dashboard extends \Piwik\Plugin } $urlParams = array('module' => 'CoreHome', 'action' => 'index'); - MenuTop::addEntry('Dashboard_Dashboard', $urlParams, true, 1, $isHTML = false, $tooltip); + $menu->add('Dashboard_Dashboard', null, $urlParams, true, 1, $isHTML = false, $tooltip); } public function getJsFiles(&$jsFiles) diff --git a/plugins/DevicesDetection/DevicesDetection.php b/plugins/DevicesDetection/DevicesDetection.php index a6b8b45149..4993b19841 100644 --- a/plugins/DevicesDetection/DevicesDetection.php +++ b/plugins/DevicesDetection/DevicesDetection.php @@ -15,6 +15,7 @@ use Piwik\ArchiveProcessor; use Piwik\CacheFile; use Piwik\Common; use Piwik\Db; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuAdmin; use Piwik\Menu\MenuMain; use Piwik\Piwik; @@ -99,9 +100,9 @@ class DevicesDetection extends \Piwik\Plugin ); } - public function addAdminMenu() + public function addAdminMenu(MenuAbstract $menu) { - MenuAdmin::getInstance()->add( + $menu->add( 'CoreAdminHome_MenuDiagnostic', 'DevicesDetection_DeviceDetection', array('module' => 'DevicesDetection', 'action' => 'deviceDetection'), Piwik::isUserHasSomeAdminAccess(), @@ -272,9 +273,9 @@ class DevicesDetection extends \Piwik\Plugin Common::printDebug($deviceInfo); } - public function addMenu() + public function addMenu(MenuAbstract $menu) { - MenuMain::getInstance()->add('General_Visitors', 'DevicesDetection_submenu', array('module' => 'DevicesDetection', 'action' => 'index')); + $menu->add('General_Visitors', 'DevicesDetection_submenu', array('module' => 'DevicesDetection', 'action' => 'index')); } public function configureViewDataTable(ViewDataTable $view) diff --git a/plugins/Events/Events.php b/plugins/Events/Events.php index 86f5c4d337..f5c87b5983 100644 --- a/plugins/Events/Events.php +++ b/plugins/Events/Events.php @@ -9,6 +9,7 @@ namespace Piwik\Plugins\Events; use Piwik\Common; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; @@ -43,9 +44,9 @@ class Events extends \Piwik\Plugin } } - public function addMenus() + public function addMenus(MenuAbstract $menu) { - MenuMain::getInstance()->add('General_Actions', 'Events_Events', array('module' => 'Events', 'action' => 'index'), true, 30); + $menu->add('General_Actions', 'Events_Events', array('module' => 'Events', 'action' => 'index'), true, 30); } public function addMetricTranslations(&$translations) diff --git a/plugins/ExampleUI/ExampleUI.php b/plugins/ExampleUI/ExampleUI.php index a9b3a83104..d9204abca8 100644 --- a/plugins/ExampleUI/ExampleUI.php +++ b/plugins/ExampleUI/ExampleUI.php @@ -8,6 +8,7 @@ */ namespace Piwik\Plugins\ExampleUI; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\Menu\MenuTop; @@ -26,30 +27,30 @@ class ExampleUI extends \Piwik\Plugin ); } - function addReportingMenuItems() + function addReportingMenuItems(MenuAbstract $menu) { - MenuMain::getInstance()->add('UI Framework', '', array('module' => 'ExampleUI', 'action' => 'dataTables'), true, 30); + $menu->add('UI Framework', '', array('module' => 'ExampleUI', 'action' => 'dataTables'), true, 30); - $this->addSubMenu('Data tables', 'dataTables', 1); - $this->addSubMenu('Bar graph', 'barGraph', 2); - $this->addSubMenu('Pie graph', 'pieGraph', 3); - $this->addSubMenu('Tag clouds', 'tagClouds', 4); - $this->addSubMenu('Sparklines', 'sparklines', 5); - $this->addSubMenu('Evolution Graph', 'evolutionGraph', 6); + $this->addSubMenu($menu, 'Data tables', 'dataTables', 1); + $this->addSubMenu($menu, 'Bar graph', 'barGraph', 2); + $this->addSubMenu($menu, 'Pie graph', 'pieGraph', 3); + $this->addSubMenu($menu, 'Tag clouds', 'tagClouds', 4); + $this->addSubMenu($menu, 'Sparklines', 'sparklines', 5); + $this->addSubMenu($menu, 'Evolution Graph', 'evolutionGraph', 6); if (\Piwik\Plugin\Manager::getInstance()->isPluginActivated('TreemapVisualization')) { - $this->addSubMenu('Treemap', 'treemap', 7); + $this->addSubMenu($menu, 'Treemap', 'treemap', 7); } } - function addTopMenuItems() + function addTopMenuItems(MenuTop $menu) { $urlParams = array('module' => 'ExampleUI', 'action' => 'notifications'); - MenuTop::getInstance()->addEntry('UI Notifications', $urlParams, $displayedForCurrentUser = true, $order = 3); + $menu->addEntry('UI Notifications', null, $urlParams, $displayedForCurrentUser = true, $order = 3); } - private function addSubMenu($subMenu, $action, $order) + private function addSubMenu(MenuAbstract $menu, $subMenu, $action, $order) { - MenuMain::getInstance()->add('UI Framework', $subMenu, array('module' => 'ExampleUI', 'action' => $action), true, $order); + $menu->add('UI Framework', $subMenu, array('module' => 'ExampleUI', 'action' => $action), true, $order); } } diff --git a/plugins/Feedback/Feedback.php b/plugins/Feedback/Feedback.php index 2d68c0019b..c0f2600b8e 100644 --- a/plugins/Feedback/Feedback.php +++ b/plugins/Feedback/Feedback.php @@ -30,14 +30,14 @@ class Feedback extends \Piwik\Plugin ); } - public function addTopMenu() + public function addTopMenu(MenuTop $menu) { - MenuTop::addEntry( + $menu->add( 'General_Help', + null, array('module' => 'Feedback', 'action' => 'index', 'segment' => false), true, $order = 20, - $isHTML = false, $tooltip = Piwik::translate('Feedback_TopLinkTooltip') ); } diff --git a/plugins/Goals/Goals.php b/plugins/Goals/Goals.php index cf0de46ab5..eb037238f5 100644 --- a/plugins/Goals/Goals.php +++ b/plugins/Goals/Goals.php @@ -11,6 +11,7 @@ namespace Piwik\Plugins\Goals; use Piwik\ArchiveProcessor; use Piwik\Common; use Piwik\Db; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; @@ -494,37 +495,35 @@ class Goals extends \Piwik\Plugin } } - function addMenus() + function addMenus(MenuAbstract $menu) { $idSite = Common::getRequestVar('idSite', null, 'int'); $goals = API::getInstance()->getGoals($idSite); $mainGoalMenu = $this->getGoalCategoryName($idSite); $site = new Site($idSite); if (count($goals) == 0) { - MenuMain::getInstance()->add($mainGoalMenu, '', array( - 'module' => 'Goals', - 'action' => ($site->isEcommerceEnabled() ? 'ecommerceReport' : 'addNewGoal'), - 'idGoal' => ($site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null)), + $menu->add($mainGoalMenu, '', array('module' => 'Goals', + 'action' => ($site->isEcommerceEnabled() ? 'ecommerceReport' : 'addNewGoal'), + 'idGoal' => ($site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null)), true, 25); if ($site->isEcommerceEnabled()) { - MenuMain::getInstance()->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1); + $menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1); } - MenuMain::getInstance()->add($mainGoalMenu, 'Goals_AddNewGoal', array('module' => 'Goals', 'action' => 'addNewGoal')); + $menu->add($mainGoalMenu, 'Goals_AddNewGoal', array('module' => 'Goals', 'action' => 'addNewGoal')); } else { - MenuMain::getInstance()->add($mainGoalMenu, '', array( - 'module' => 'Goals', - 'action' => ($site->isEcommerceEnabled() ? 'ecommerceReport' : 'index'), - 'idGoal' => ($site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null)), + $menu->add($mainGoalMenu, '', array('module' => 'Goals', + 'action' => ($site->isEcommerceEnabled() ? 'ecommerceReport' : 'index'), + 'idGoal' => ($site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null)), true, 25); if ($site->isEcommerceEnabled()) { - MenuMain::getInstance()->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1); + $menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1); } - MenuMain::getInstance()->add($mainGoalMenu, 'Goals_GoalsOverview', array('module' => 'Goals', 'action' => 'index'), true, 2); + $menu->add($mainGoalMenu, 'Goals_GoalsOverview', array('module' => 'Goals', 'action' => 'index'), true, 2); foreach ($goals as $goal) { - MenuMain::getInstance()->add($mainGoalMenu, str_replace('%', '%%', Translate::clean($goal['name'])), array('module' => 'Goals', 'action' => 'goalReport', 'idGoal' => $goal['idgoal'])); + $menu->add($mainGoalMenu, str_replace('%', '%%', Translate::clean($goal['name'])), array('module' => 'Goals', 'action' => 'goalReport', 'idGoal' => $goal['idgoal'])); } } } diff --git a/plugins/Installation/Installation.php b/plugins/Installation/Installation.php index eff0fde648..90e07944d1 100644 --- a/plugins/Installation/Installation.php +++ b/plugins/Installation/Installation.php @@ -11,6 +11,7 @@ namespace Piwik\Plugins\Installation; use Piwik\Common; use Piwik\Config; use Piwik\FrontController; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuAdmin; use Piwik\Piwik; use Piwik\Translate; @@ -95,9 +96,9 @@ class Installation extends \Piwik\Plugin /** * Adds the 'System Check' admin page if the user is the Super User. */ - public function addMenu() + public function addMenu(MenuAbstract $menu) { - MenuAdmin::addEntry('Installation_SystemCheck', + $menu->add('Installation_SystemCheck', array('module' => 'Installation', 'action' => 'systemCheckPage'), Piwik::hasUserSuperUserAccess(), $order = 15); diff --git a/plugins/LanguagesManager/LanguagesManager.php b/plugins/LanguagesManager/LanguagesManager.php index fbb9dcf39a..122a3eedcf 100644 --- a/plugins/LanguagesManager/LanguagesManager.php +++ b/plugins/LanguagesManager/LanguagesManager.php @@ -52,10 +52,10 @@ class LanguagesManager extends \Piwik\Plugin $jsFiles[] = "plugins/LanguagesManager/javascripts/languageSelector.js"; } - public function showLanguagesSelector() + public function showLanguagesSelector(MenuTop $menu) { if (Piwik::isUserIsAnonymous() || !SettingsPiwik::isPiwikInstalled()) { - MenuTop::addEntry('LanguageSelector', $this->getLanguagesSelector(), true, $order = 30, true); + $menu->addHtml('LanguageSelector', $this->getLanguagesSelector(), true, $order = 30, false); } } diff --git a/plugins/Live/Live.php b/plugins/Live/Live.php index 5b390dd506..e6c6b1c745 100644 --- a/plugins/Live/Live.php +++ b/plugins/Live/Live.php @@ -8,6 +8,7 @@ */ namespace Piwik\Plugins\Live; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\Plugins\CoreVisualizations\Visualizations\HtmlTable; use Piwik\WidgetsList; @@ -48,9 +49,9 @@ class Live extends \Piwik\Plugin $jsFiles[] = "plugins/Live/javascripts/visitorLog.js"; } - public function addMenu() + public function addMenu(MenuAbstract $menu) { - MenuMain::getInstance()->add('General_Visitors', 'Live_VisitorLog', array('module' => 'Live', 'action' => 'indexVisitorLog'), true, $order = 5); + $menu->add('General_Visitors', 'Live_VisitorLog', array('module' => 'Live', 'action' => 'indexVisitorLog'), true, $order = 5); } public function addWidget() diff --git a/plugins/MobileMessaging/MobileMessaging.php b/plugins/MobileMessaging/MobileMessaging.php index f36a6c6c70..9e7034baf7 100644 --- a/plugins/MobileMessaging/MobileMessaging.php +++ b/plugins/MobileMessaging/MobileMessaging.php @@ -8,6 +8,7 @@ */ namespace Piwik\Plugins\MobileMessaging; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuAdmin; use Piwik\Option; use Piwik\Piwik; @@ -82,9 +83,9 @@ class MobileMessaging extends \Piwik\Plugin ); } - function addMenu() + function addMenu(MenuAbstract $menu) { - MenuAdmin::addEntry('MobileMessaging_SettingsMenu', + $menu->add('MobileMessaging_SettingsMenu', array('module' => 'MobileMessaging', 'action' => 'index'), true, $order = 12 diff --git a/plugins/MultiSites/MultiSites.php b/plugins/MultiSites/MultiSites.php index 284001d496..6b4dc9d082 100644 --- a/plugins/MultiSites/MultiSites.php +++ b/plugins/MultiSites/MultiSites.php @@ -93,11 +93,11 @@ class MultiSites extends \Piwik\Plugin ); } - public function addTopMenu() + public function addTopMenu(MenuTop $menu) { $urlParams = array('module' => 'MultiSites', 'action' => 'index', 'segment' => false); $tooltip = Piwik::translate('MultiSites_TopLinkTooltip'); - MenuTop::addEntry('General_MultiSitesSummary', $urlParams, true, 3, $isHTML = false, $tooltip); + $menu->add('General_MultiSitesSummary', null, $urlParams, true, 3, $tooltip); } public function getJsFiles(&$jsFiles) diff --git a/plugins/PrivacyManager/PrivacyManager.php b/plugins/PrivacyManager/PrivacyManager.php index 10b05cac5c..b626aaff28 100644 --- a/plugins/PrivacyManager/PrivacyManager.php +++ b/plugins/PrivacyManager/PrivacyManager.php @@ -13,6 +13,7 @@ use Piwik\Config as PiwikConfig; use Piwik\DataTable\DataTableInterface; use Piwik\Date; use Piwik\Db; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuAdmin; use Piwik\Metrics; use Piwik\Option; @@ -174,12 +175,12 @@ class PrivacyManager extends \Piwik\Plugin $jsFiles[] = "plugins/PrivacyManager/javascripts/privacySettings.js"; } - function addMenu() + function addMenu(MenuAbstract $menu) { - MenuAdmin::addEntry('PrivacyManager_MenuPrivacySettings', - array('module' => 'PrivacyManager', 'action' => 'privacySettings'), - Piwik::isUserHasSomeAdminAccess(), - $order = 7); + $menu->add('PrivacyManager_MenuPrivacySettings', + array('module' => 'PrivacyManager', 'action' => 'privacySettings'), + Piwik::isUserHasSomeAdminAccess(), + $order = 7); } /** diff --git a/plugins/Provider/Provider.php b/plugins/Provider/Provider.php index 9a10b89a27..10c2fe5bde 100644 --- a/plugins/Provider/Provider.php +++ b/plugins/Provider/Provider.php @@ -14,6 +14,7 @@ use Piwik\Common; use Piwik\Db; use Piwik\FrontController; use Piwik\IP; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; @@ -93,10 +94,10 @@ class Provider extends \Piwik\Plugin WidgetsList::add('General_Visitors', 'Provider_WidgetProviders', 'Provider', 'getProvider'); } - public function addMenu() + public function addMenu(MenuAbstract $menu) { - MenuMain::getInstance()->rename('General_Visitors', 'UserCountry_SubmenuLocations', - 'General_Visitors', 'Provider_SubmenuLocationsProvider'); + $menu->rename('General_Visitors', 'UserCountry_SubmenuLocations', + 'General_Visitors', 'Provider_SubmenuLocationsProvider'); } public function postLoad() diff --git a/plugins/Referrers/Referrers.php b/plugins/Referrers/Referrers.php index 9a567b16d6..c24946e029 100644 --- a/plugins/Referrers/Referrers.php +++ b/plugins/Referrers/Referrers.php @@ -10,6 +10,7 @@ namespace Piwik\Plugins\Referrers; use Piwik\ArchiveProcessor; use Piwik\Common; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; @@ -248,13 +249,13 @@ class Referrers extends \Piwik\Plugin /** * Adds Web Analytics menus */ - function addMenus() + function addMenus(MenuAbstract $menu) { - MenuMain::getInstance()->add('Referrers_Referrers', '', array('module' => 'Referrers', 'action' => 'index'), true, 20); - MenuMain::getInstance()->add('Referrers_Referrers', 'General_Overview', array('module' => 'Referrers', 'action' => 'index'), true, 1); - MenuMain::getInstance()->add('Referrers_Referrers', 'Referrers_SubmenuSearchEngines', array('module' => 'Referrers', 'action' => 'getSearchEnginesAndKeywords'), true, 2); - MenuMain::getInstance()->add('Referrers_Referrers', 'Referrers_SubmenuWebsites', array('module' => 'Referrers', 'action' => 'indexWebsites'), true, 3); - MenuMain::getInstance()->add('Referrers_Referrers', 'Referrers_Campaigns', array('module' => 'Referrers', 'action' => 'indexCampaigns'), true, 4); + $menu->add('Referrers_Referrers', '', array('module' => 'Referrers', 'action' => 'index'), true, 20); + $menu->add('Referrers_Referrers', 'General_Overview', array('module' => 'Referrers', 'action' => 'index'), true, 1); + $menu->add('Referrers_Referrers', 'Referrers_SubmenuSearchEngines', array('module' => 'Referrers', 'action' => 'getSearchEnginesAndKeywords'), true, 2); + $menu->add('Referrers_Referrers', 'Referrers_SubmenuWebsites', array('module' => 'Referrers', 'action' => 'indexWebsites'), true, 3); + $menu->add('Referrers_Referrers', 'Referrers_Campaigns', array('module' => 'Referrers', 'action' => 'indexCampaigns'), true, 4); } /** diff --git a/plugins/ScheduledReports/ScheduledReports.php b/plugins/ScheduledReports/ScheduledReports.php index 580056aca7..f56de16e2d 100644 --- a/plugins/ScheduledReports/ScheduledReports.php +++ b/plugins/ScheduledReports/ScheduledReports.php @@ -504,14 +504,14 @@ class ScheduledReports extends \Piwik\Plugin } } - function addTopMenu() + function addTopMenu(MenuTop $menu) { - MenuTop::addEntry( + $menu->add( $this->getTopMenuTranslationKey(), + null, array('module' => 'ScheduledReports', 'action' => 'index', 'segment' => false), true, 13, - $isHTML = false, $tooltip = Piwik::translate( \Piwik\Plugin\Manager::getInstance()->isPluginActivated('MobileMessaging') ? 'MobileMessaging_TopLinkTooltip' : 'ScheduledReports_TopLinkTooltip' diff --git a/plugins/SitesManager/SitesManager.php b/plugins/SitesManager/SitesManager.php index 6c649c15b0..47fc57d9f6 100644 --- a/plugins/SitesManager/SitesManager.php +++ b/plugins/SitesManager/SitesManager.php @@ -8,6 +8,7 @@ */ namespace Piwik\Plugins\SitesManager; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuAdmin; use Piwik\Piwik; @@ -34,9 +35,9 @@ class SitesManager extends \Piwik\Plugin ); } - function addMenu() + function addMenu(MenuAbstract $menu) { - MenuAdmin::getInstance()->add('CoreAdminHome_MenuManage', 'SitesManager_Sites', + $menu->add('CoreAdminHome_MenuManage', 'SitesManager_Sites', array('module' => 'SitesManager', 'action' => 'index'), Piwik::isUserHasSomeAdminAccess(), $order = 1); diff --git a/plugins/UserCountry/UserCountry.php b/plugins/UserCountry/UserCountry.php index ddeb61521f..e494b80270 100644 --- a/plugins/UserCountry/UserCountry.php +++ b/plugins/UserCountry/UserCountry.php @@ -12,6 +12,7 @@ use Piwik\ArchiveProcessor; use Piwik\Common; use Piwik\Config; use Piwik\IP; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuAdmin; use Piwik\Menu\MenuMain; use Piwik\Piwik; @@ -194,18 +195,18 @@ class UserCountry extends \Piwik\Plugin WidgetsList::add('General_Visitors', $widgetCityLabel, 'UserCountry', 'getCity'); } - public function addMenu() + public function addMenu(MenuAbstract $menu) { - MenuMain::getInstance()->add('General_Visitors', 'UserCountry_SubmenuLocations', array('module' => 'UserCountry', 'action' => 'index')); + $menu->add('General_Visitors', 'UserCountry_SubmenuLocations', array('module' => 'UserCountry', 'action' => 'index')); } /** * Event handler. Adds menu items to the MenuAdmin menu. */ - public function addAdminMenu() + public function addAdminMenu(MenuAbstract $menu) { if($this->isGeoLocationAdminEnabled()) { - MenuAdmin::getInstance()->add('General_Settings', 'UserCountry_Geolocation', + $menu->add('General_Settings', 'UserCountry_Geolocation', array('module' => 'UserCountry', 'action' => 'adminIndex'), Piwik::hasUserSuperUserAccess(), $order = 8); diff --git a/plugins/UserCountryMap/UserCountryMap.php b/plugins/UserCountryMap/UserCountryMap.php index d93f5a2930..eef7af7e84 100644 --- a/plugins/UserCountryMap/UserCountryMap.php +++ b/plugins/UserCountryMap/UserCountryMap.php @@ -9,6 +9,7 @@ namespace Piwik\Plugins\UserCountryMap; use Piwik\FrontController; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\Piwik; use Piwik\Version; @@ -57,9 +58,9 @@ class UserCountryMap extends \Piwik\Plugin return $hooks; } - public function addMenu() + public function addMenu(MenuAbstract $menu) { - MenuMain::getInstance()->add('General_Visitors', 'UserCountryMap_RealTimeMap', + $menu->add('General_Visitors', 'UserCountryMap_RealTimeMap', array('module' => 'UserCountryMap', 'action' => 'realtimeWorldMap'), true, $order = 70); } diff --git a/plugins/UserSettings/UserSettings.php b/plugins/UserSettings/UserSettings.php index a1a44401e0..75da403f6e 100644 --- a/plugins/UserSettings/UserSettings.php +++ b/plugins/UserSettings/UserSettings.php @@ -8,6 +8,7 @@ */ namespace Piwik\Plugins\UserSettings; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\Piwik; use Piwik\Plugin\ViewDataTable; @@ -461,9 +462,9 @@ class UserSettings extends \Piwik\Plugin /** * Adds the User Settings menu */ - function addMenu() + function addMenu(MenuAbstract $menu) { - MenuMain::getInstance()->add('General_Visitors', 'General_Settings', array('module' => 'UserSettings', 'action' => 'index')); + $menu->add('General_Visitors', 'General_Settings', array('module' => 'UserSettings', 'action' => 'index')); } } diff --git a/plugins/UsersManager/UsersManager.php b/plugins/UsersManager/UsersManager.php index cbe89fa041..b7aab89915 100644 --- a/plugins/UsersManager/UsersManager.php +++ b/plugins/UsersManager/UsersManager.php @@ -10,6 +10,7 @@ namespace Piwik\Plugins\UsersManager; use Exception; use Piwik\Db; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuAdmin; use Piwik\Option; use Piwik\Piwik; @@ -97,13 +98,13 @@ class UsersManager extends \Piwik\Plugin /** * Add admin menu items */ - public function addMenu() + public function addMenu(MenuAbstract $menu) { - MenuAdmin::getInstance()->add('CoreAdminHome_MenuManage', 'UsersManager_MenuUsers', + $menu->add('CoreAdminHome_MenuManage', 'UsersManager_MenuUsers', array('module' => 'UsersManager', 'action' => 'index'), Piwik::isUserHasSomeAdminAccess(), $order = 2); - MenuAdmin::getInstance()->add('CoreAdminHome_MenuManage', 'UsersManager_MenuUserSettings', + $menu->add('CoreAdminHome_MenuManage', 'UsersManager_MenuUserSettings', array('module' => 'UsersManager', 'action' => 'userSettings'), Piwik::isUserHasSomeViewAccess(), $order = 3); diff --git a/plugins/VisitFrequency/VisitFrequency.php b/plugins/VisitFrequency/VisitFrequency.php index efda5914b2..6f1b27c48c 100644 --- a/plugins/VisitFrequency/VisitFrequency.php +++ b/plugins/VisitFrequency/VisitFrequency.php @@ -8,6 +8,7 @@ */ namespace Piwik\Plugins\VisitFrequency; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\Piwik; use Piwik\WidgetsList; @@ -62,9 +63,9 @@ class VisitFrequency extends \Piwik\Plugin array('columns' => array('nb_visits_returning'))); } - function addMenu() + function addMenu(MenuAbstract $menu) { - MenuMain::getInstance()->add('General_Visitors', 'VisitFrequency_SubmenuFrequency', + $menu->add('General_Visitors', 'VisitFrequency_SubmenuFrequency', array('module' => 'VisitFrequency', 'action' => 'index'), true, $order = 55); } } diff --git a/plugins/VisitTime/VisitTime.php b/plugins/VisitTime/VisitTime.php index a3201fc3f9..bb93f0903f 100644 --- a/plugins/VisitTime/VisitTime.php +++ b/plugins/VisitTime/VisitTime.php @@ -11,6 +11,7 @@ namespace Piwik\Plugins\VisitTime; use Exception; use Piwik\ArchiveProcessor; use Piwik\Common; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\Period; use Piwik\Piwik; @@ -85,10 +86,10 @@ class VisitTime extends \Piwik\Plugin WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitTime_VisitsByDayOfWeek', 'VisitTime', 'getByDayOfWeek'); } - function addMenu() + function addMenu(MenuAbstract $menu) { - MenuMain::getInstance()->add('General_Visitors', 'VisitTime_SubmenuTimes', - array('module' => 'VisitTime', 'action' => 'index'), true, $order = 65); + $menu->add('General_Visitors', 'VisitTime_SubmenuTimes', + array('module' => 'VisitTime', 'action' => 'index'), true, $order = 65); } public function getReportsWithGoalMetrics(&$dimensions) diff --git a/plugins/VisitorInterest/VisitorInterest.php b/plugins/VisitorInterest/VisitorInterest.php index c94fa7227f..4661b34437 100644 --- a/plugins/VisitorInterest/VisitorInterest.php +++ b/plugins/VisitorInterest/VisitorInterest.php @@ -10,6 +10,7 @@ namespace Piwik\Plugins\VisitorInterest; use Piwik\ArchiveProcessor; use Piwik\FrontController; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\Metrics; use Piwik\Piwik; @@ -107,10 +108,10 @@ class VisitorInterest extends \Piwik\Plugin WidgetsList::add('General_Visitors', 'VisitorInterest_WidgetVisitsByDaysSinceLast', 'VisitorInterest', 'getNumberOfVisitsByDaysSinceLast'); } - public function addMenu() + public function addMenu(MenuAbstract $menu) { - MenuMain::getInstance()->rename('General_Visitors', 'VisitFrequency_SubmenuFrequency', - 'General_Visitors', 'VisitorInterest_Engagement'); + $menu->rename('General_Visitors', 'VisitFrequency_SubmenuFrequency', + 'General_Visitors', 'VisitorInterest_Engagement'); } function postLoad() diff --git a/plugins/VisitsSummary/VisitsSummary.php b/plugins/VisitsSummary/VisitsSummary.php index ae1da5709c..dfa923e39d 100644 --- a/plugins/VisitsSummary/VisitsSummary.php +++ b/plugins/VisitsSummary/VisitsSummary.php @@ -8,6 +8,7 @@ */ namespace Piwik\Plugins\VisitsSummary; +use Piwik\Menu\MenuAbstract; use Piwik\Menu\MenuMain; use Piwik\Piwik; use Piwik\WidgetsList; @@ -70,10 +71,10 @@ class VisitsSummary extends \Piwik\Plugin WidgetsList::add('VisitsSummary_VisitsSummary', 'VisitsSummary_WidgetOverviewGraph', 'VisitsSummary', 'index'); } - function addMenu() + function addMenu(MenuAbstract $menu) { - MenuMain::getInstance()->add('General_Visitors', '', array('module' => 'VisitsSummary', 'action' => 'index'), true, 10); - MenuMain::getInstance()->add('General_Visitors', 'General_Overview', array('module' => 'VisitsSummary', 'action' => 'index'), true, 1); + $menu->add('General_Visitors', '', array('module' => 'VisitsSummary', 'action' => 'index'), true, 10); + $menu->add('General_Visitors', 'General_Overview', array('module' => 'VisitsSummary', 'action' => 'index'), true, 1); } } diff --git a/plugins/Widgetize/Widgetize.php b/plugins/Widgetize/Widgetize.php index f0abcfb87a..aa199a5207 100644 --- a/plugins/Widgetize/Widgetize.php +++ b/plugins/Widgetize/Widgetize.php @@ -30,12 +30,12 @@ class Widgetize extends \Piwik\Plugin ); } - public function addTopMenu() + public function addTopMenu(MenuTop $menu) { - $tooltip = Piwik::translate('Widgetize_TopLinkTooltip'); + $tooltip = Piwik::translate('Widgetize_TopLinkTooltip'); $urlParams = array('module' => 'Widgetize', 'action' => 'index', 'segment' => false); - MenuTop::addEntry('General_Widgets', $urlParams, true, 5, $isHTML = false, $tooltip); + $menu->add('General_Widgets', null, $urlParams, true, 5, $tooltip); } public function getJsFiles(&$jsFiles) |