Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/matomo-org/matomo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas Steur <thomas.steur@googlemail.com>2014-05-20 03:05:41 +0400
committerThomas Steur <thomas.steur@googlemail.com>2014-05-20 03:05:41 +0400
commitb2cb622bf1ea754a73ce06e165a083e3305aa807 (patch)
tree43bf1134201759cf73b88d53274fa87fdffebd0d
parent009a6f21177e8cb6366577d8f54024e896bb0d8e (diff)
refs #5192 continued menu refactoring. not sure yet how good this idea is but seems to be already better than before
-rw-r--r--core/Menu/MenuAbstract.php44
-rw-r--r--core/Menu/MenuAdmin.php5
-rw-r--r--core/Menu/MenuMain.php65
-rw-r--r--core/Menu/MenuReporting.php96
-rw-r--r--core/Menu/MenuTop.php6
-rwxr-xr-xcore/Menu/MenuUser.php52
-rw-r--r--core/Plugin/Menu.php34
-rw-r--r--plugins/API/API.php30
-rw-r--r--plugins/API/Menu.php47
-rw-r--r--plugins/Actions/Actions.php18
-rw-r--r--plugins/Actions/Menu.php39
-rw-r--r--plugins/CoreAdminHome/CoreAdminHome.php26
-rw-r--r--plugins/CoreAdminHome/Menu.php40
-rw-r--r--plugins/CorePluginsAdmin/CorePluginsAdmin.php39
-rw-r--r--plugins/CorePluginsAdmin/Menu.php61
-rw-r--r--plugins/CustomVariables/CustomVariables.php6
-rw-r--r--plugins/CustomVariables/Menu.php24
-rw-r--r--plugins/DBStats/DBStats.php9
-rw-r--r--plugins/DBStats/Menu.php32
-rw-r--r--plugins/Dashboard/Dashboard.php33
-rw-r--r--plugins/Dashboard/Menu.php56
-rw-r--r--plugins/DevicesDetection/DevicesDetection.php17
-rw-r--r--plugins/DevicesDetection/Menu.php33
-rw-r--r--plugins/Events/Events.php6
-rw-r--r--plugins/Events/Menu.php21
25 files changed, 596 insertions, 243 deletions
diff --git a/core/Menu/MenuAbstract.php b/core/Menu/MenuAbstract.php
index 781aed7b81..02d76b2ce5 100644
--- a/core/Menu/MenuAbstract.php
+++ b/core/Menu/MenuAbstract.php
@@ -11,6 +11,7 @@ namespace Piwik\Menu;
use Piwik\Common;
use Piwik\Plugins\SitesManager\API;
use Piwik\Singleton;
+use Piwik\Plugin\Manager as PluginManager;
/**
* Base class for classes that manage one of Piwik's menus.
@@ -30,6 +31,7 @@ abstract class MenuAbstract extends Singleton
protected $edits = array();
protected $renames = array();
protected $orderingApplied = false;
+ protected static $menus = array();
/**
* Builds the menu, applies edits, renames
@@ -48,6 +50,48 @@ abstract class MenuAbstract extends Singleton
}
/**
+ * Returns a list of available plugin menu instances.
+ *
+ * @return \Piwik\Plugin\Menu[]
+ */
+ protected function getAvailableMenus()
+ {
+ if (!empty(self::$menus)) {
+ return self::$menus;
+ }
+
+ $pluginNames = PluginManager::getInstance()->getLoadedPluginsName();
+
+ self::$menus = array();
+ foreach ($pluginNames as $pluginName) {
+ $menu = $this->findMenuInPlugin($pluginName);
+
+ if (!empty($menu)) {
+ self::$menus[] = $menu;
+ }
+ }
+
+ return self::$menus;
+ }
+
+ private function findMenuInPlugin($pluginName)
+ {
+ $menuFile = PIWIK_INCLUDE_PATH . '/plugins/' . $pluginName . '/Menu.php';
+
+ if (!file_exists($menuFile)) {
+ return;
+ }
+
+ $klassName = sprintf('Piwik\\Plugins\\%s\\Menu', $pluginName);
+
+ if (!class_exists($klassName) || !is_subclass_of($klassName, 'Piwik\\Plugin\\Menu')) {
+ return;
+ }
+
+ return new $klassName;
+ }
+
+ /**
* Adds a new entry to the menu.
*
* @param string $menuName The menu's category name. Can be a translation token.
diff --git a/core/Menu/MenuAdmin.php b/core/Menu/MenuAdmin.php
index b187d18eba..0b41bb33c5 100644
--- a/core/Menu/MenuAdmin.php
+++ b/core/Menu/MenuAdmin.php
@@ -85,7 +85,12 @@ class MenuAdmin extends MenuAbstract
* }
*/
Piwik::postEvent('Menu.Admin.addItems', array($this));
+
+ foreach ($this->getAvailableMenus() as $menu) {
+ $menu->configureAdminMenu($this);
+ }
}
+
return parent::getMenu();
}
diff --git a/core/Menu/MenuMain.php b/core/Menu/MenuMain.php
index 0421a33785..c078e2166d 100644
--- a/core/Menu/MenuMain.php
+++ b/core/Menu/MenuMain.php
@@ -7,15 +7,15 @@
*
*/
namespace Piwik\Menu;
-use Piwik\Piwik;
+
/**
* Contains menu entries for the Main menu (the menu displayed under the Piwik logo).
* Plugins can subscribe to the {@hook Menu.Reporting.addItems} event to add new pages to
* the main menu.
- *
+ *
* **Example**
- *
+ *
* // add a new page in an observer to Menu.Admin.addItems
* public function addMainMenuItem()
* {
@@ -27,65 +27,10 @@ use Piwik\Piwik;
* $order = 2
* );
* }
- *
+ *
* @api
* @method static \Piwik\Menu\MenuMain getInstance()
*/
-class MenuMain extends MenuAbstract
+class MenuMain extends MenuReporting
{
- /**
- * Returns if the URL was found in the menu.
- *
- * @param string $url
- * @return boolean
- */
- public function isUrlFound($url)
- {
- $menu = MenuMain::getInstance()->getMenu();
-
- foreach ($menu as $subMenus) {
- foreach ($subMenus as $subMenuName => $menuUrl) {
- if (strpos($subMenuName, '_') !== 0 && $menuUrl['_url'] == $url) {
- return true;
- }
- }
- }
- return false;
- }
-
- /**
- * Triggers the Menu.Reporting.addItems hook and returns the menu.
- *
- * @return Array
- */
- public function getMenu()
- {
- // We trigger the Event only once!
- if (!$this->menu) {
-
- /**
- * Triggered when collecting all available reporting menu items. Subscribe to this event if you
- * want to add one or more items to the Piwik reporting menu.
- *
- * Menu items should be added via the {@link add()} method.
- *
- * **Example**
- *
- * use Piwik\Menu\MenuMain;
- *
- * public function addMenuItems()
- * {
- * MenuMain::getInstance()->add(
- * 'CustomMenuName',
- * 'CustomSubmenuName',
- * array('module' => 'MyPlugin', 'action' => 'index'),
- * $showOnlyIf = Piwik::hasUserSuperUserAccess(),
- * $order = 6
- * );
- * }
- */
- Piwik::postEvent('Menu.Reporting.addItems', array($this));
- }
- return parent::getMenu();
- }
}
diff --git a/core/Menu/MenuReporting.php b/core/Menu/MenuReporting.php
new file mode 100644
index 0000000000..fa9e8f4b46
--- /dev/null
+++ b/core/Menu/MenuReporting.php
@@ -0,0 +1,96 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Menu;
+use Piwik\Piwik;
+
+/**
+ * Contains menu entries for the Main menu (the menu displayed under the Piwik logo).
+ * Plugins can subscribe to the {@hook Menu.Reporting.addItems} event to add new pages to
+ * the main menu.
+ *
+ * **Example**
+ *
+ * // add a new page in an observer to Menu.Admin.addItems
+ * public function addMainMenuItem()
+ * {
+ * MenuReporting::getInstance()->add(
+ * 'MyPlugin_MyTranslatedMenuCategory',
+ * 'MyPlugin_MyTranslatedMenuName',
+ * array('module' => 'MyPlugin', 'action' => 'index'),
+ * Piwik::isUserHasSomeAdminAccess(),
+ * $order = 2
+ * );
+ * }
+ *
+ * @api
+ * @method static \Piwik\Menu\MenuMain getInstance()
+ */
+class MenuReporting extends MenuAbstract
+{
+ /**
+ * Returns if the URL was found in the menu.
+ *
+ * @param string $url
+ * @return boolean
+ */
+ public function isUrlFound($url)
+ {
+ $menu = MenuMain::getInstance()->getMenu();
+
+ foreach ($menu as $subMenus) {
+ foreach ($subMenus as $subMenuName => $menuUrl) {
+ if (strpos($subMenuName, '_') !== 0 && $menuUrl['_url'] == $url) {
+ return true;
+ }
+ }
+ }
+ return false;
+ }
+
+ /**
+ * Triggers the Menu.Reporting.addItems hook and returns the menu.
+ *
+ * @return Array
+ */
+ public function getMenu()
+ {
+ // We trigger the Event only once!
+ if (!$this->menu) {
+
+ /**
+ * Triggered when collecting all available reporting menu items. Subscribe to this event if you
+ * want to add one or more items to the Piwik reporting menu.
+ *
+ * Menu items should be added via the {@link add()} method.
+ *
+ * **Example**
+ *
+ * use Piwik\Menu\MenuMain;
+ *
+ * public function addMenuItems()
+ * {
+ * MenuMain::getInstance()->add(
+ * 'CustomMenuName',
+ * 'CustomSubmenuName',
+ * array('module' => 'MyPlugin', 'action' => 'index'),
+ * $showOnlyIf = Piwik::hasUserSuperUserAccess(),
+ * $order = 6
+ * );
+ * }
+ */
+ Piwik::postEvent('Menu.Reporting.addItems', array($this));
+
+ foreach ($this->getAvailableMenus() as $menu) {
+ $menu->configureReportingMenu($this);
+ }
+ }
+
+ return parent::getMenu();
+ }
+}
diff --git a/core/Menu/MenuTop.php b/core/Menu/MenuTop.php
index dcec860ac4..307132a2fd 100644
--- a/core/Menu/MenuTop.php
+++ b/core/Menu/MenuTop.php
@@ -65,7 +65,6 @@ class MenuTop extends MenuAbstract
MenuTop::getInstance()->remove($menuName, $subMenuName);
}
-
/**
* Directly adds a menu entry containing html.
*
@@ -119,7 +118,12 @@ class MenuTop extends MenuAbstract
* }
*/
Piwik::postEvent('Menu.Top.addItems', array($this));
+
+ foreach ($this->getAvailableMenus() as $menu) {
+ $menu->configureTopMenu($this);
+ }
}
+
return parent::getMenu();
}
}
diff --git a/core/Menu/MenuUser.php b/core/Menu/MenuUser.php
new file mode 100755
index 0000000000..dd27fa4aef
--- /dev/null
+++ b/core/Menu/MenuUser.php
@@ -0,0 +1,52 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Menu;
+
+use Piwik\Piwik;
+
+/**
+ * Contains menu entries for the User menu (the menu at the very top of the page).
+ * Plugins can subscribe to the {@hook Menu.User.addItems} event to add new pages to
+ * the user menu.
+ *
+ * **Example**
+ *
+ * // add a new page in an observer to Menu.User.addItems
+ * public function addUserMenuItem()
+ * {
+ * MenuUser::getInstance()->add(
+ * 'MyPlugin_MyTranslatedMenuCategory',
+ * 'MyPlugin_MyTranslatedMenuName',
+ * array('module' => 'MyPlugin', 'action' => 'index'),
+ * Piwik::isUserHasSomeAdminAccess(),
+ * $order = 2
+ * );
+ * }
+ *
+ * @method static \Piwik\Menu\MenuUser getInstance()
+ */
+class MenuUser extends MenuTop
+{
+
+ /**
+ * Triggers the Menu.User.addItems hook and returns the menu.
+ *
+ * @return Array
+ */
+ public function getMenu()
+ {
+ if (!$this->menu) {
+ foreach ($this->getAvailableMenus() as $menu) {
+ $menu->configureUserMenu($this);
+ }
+ }
+
+ return parent::getMenu();
+ }
+}
diff --git a/core/Plugin/Menu.php b/core/Plugin/Menu.php
new file mode 100644
index 0000000000..b1c7ac6fe5
--- /dev/null
+++ b/core/Plugin/Menu.php
@@ -0,0 +1,34 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugin;
+
+use Piwik\Menu\MenuAdmin;
+use Piwik\Menu\MenuMain;
+use Piwik\Menu\MenuTop;
+use Piwik\Menu\MenuUser;
+
+class Menu
+{
+ public function configureReportingMenu(MenuMain $menu)
+ {
+ }
+
+ public function configureTopMenu(MenuTop $menu)
+ {
+ }
+
+ public function configureAdminMenu(MenuAdmin $menu)
+ {
+ }
+
+ public function configureUserMenu(MenuUser $menu)
+ {
+ }
+
+}
diff --git a/plugins/API/API.php b/plugins/API/API.php
index dd0d2f9aeb..0b972b9f61 100644
--- a/plugins/API/API.php
+++ b/plugins/API/API.php
@@ -694,38 +694,10 @@ class Plugin extends \Piwik\Plugin
public function getListHooksRegistered()
{
return array(
- 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
- 'Menu.Top.addItems' => 'addTopMenu',
+ 'AssetManager.getStylesheetFiles' => 'getStylesheetFiles'
);
}
- public function addTopMenu(MenuTop $menu)
- {
- $apiUrlParams = array('module' => 'API', 'action' => 'listAllAPI', 'segment' => false);
- $tooltip = Piwik::translate('API_TopLinkTooltip');
-
- $menu->add('General_API', null, $apiUrlParams, true, 7, $tooltip);
-
- $this->addTopMenuMobileApp($menu);
- }
-
- protected function addTopMenuMobileApp(MenuTop $menu)
- {
- if (empty($_SERVER['HTTP_USER_AGENT'])) {
- return;
- }
- if (!class_exists("DeviceDetector")) {
- throw new \Exception("DeviceDetector could not be found, maybe you are using Piwik from git and need to have update Composer. <br>php composer.phar update");
- }
-
- $ua = new \DeviceDetector($_SERVER['HTTP_USER_AGENT']);
- $ua->parse();
- $os = $ua->getOs('short_name');
- if ($os && in_array($os, array('AND', 'IOS'))) {
- $menu->add('Piwik Mobile App', null, array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4);
- }
- }
-
public function getStylesheetFiles(&$stylesheets)
{
$stylesheets[] = "plugins/API/stylesheets/listAllAPI.less";
diff --git a/plugins/API/Menu.php b/plugins/API/Menu.php
new file mode 100644
index 0000000000..61c2932b54
--- /dev/null
+++ b/plugins/API/Menu.php
@@ -0,0 +1,47 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\API;
+
+use Piwik\Menu\MenuTop;
+use Piwik\Piwik;
+
+/**
+ */
+class Menu extends \Piwik\Plugin\Menu
+{
+
+ public function configureTopMenu(MenuTop $menu)
+ {
+ $apiUrlParams = array('module' => 'API', 'action' => 'listAllAPI', 'segment' => false);
+ $tooltip = Piwik::translate('API_TopLinkTooltip');
+
+ $menu->add('General_API', null, $apiUrlParams, true, 7, $tooltip);
+
+ $this->addTopMenuMobileApp($menu);
+ }
+
+ protected function addTopMenuMobileApp(MenuTop $menu)
+ {
+ if (empty($_SERVER['HTTP_USER_AGENT'])) {
+ return;
+ }
+
+ if (!class_exists("DeviceDetector")) {
+ throw new \Exception("DeviceDetector could not be found, maybe you are using Piwik from git and need to have update Composer. <br>php composer.phar update");
+ }
+
+ $ua = new \DeviceDetector($_SERVER['HTTP_USER_AGENT']);
+ $ua->parse();
+ $os = $ua->getOs('short_name');
+ if ($os && in_array($os, array('AND', 'IOS'))) {
+ $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 38e4f56519..f4a0445380 100644
--- a/plugins/Actions/Actions.php
+++ b/plugins/Actions/Actions.php
@@ -38,7 +38,6 @@ class Actions extends \Piwik\Plugin
{
$hooks = array(
'WidgetsList.addWidgets' => 'addWidgets',
- 'Menu.Reporting.addItems' => 'addMenus',
'API.getReportMetadata' => 'getReportMetadata',
'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata',
'ViewDataTable.configure' => 'configureViewDataTable',
@@ -486,22 +485,7 @@ class Actions extends \Piwik\Plugin
}
}
- function addMenus(MenuAbstract $menu)
- {
- $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()) {
- $menu->add('General_Actions', 'Actions_SubmenuSitesearch', array('module' => 'Actions', 'action' => 'indexSiteSearch'), true, 5);
- }
- }
-
- protected function isSiteSearchEnabled()
+ public function isSiteSearchEnabled()
{
$idSite = Common::getRequestVar('idSite', 0, 'int');
$idSites = Common::getRequestVar('idSites', '', 'string');
diff --git a/plugins/Actions/Menu.php b/plugins/Actions/Menu.php
new file mode 100644
index 0000000000..10cd70f812
--- /dev/null
+++ b/plugins/Actions/Menu.php
@@ -0,0 +1,39 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\Actions;
+
+use Exception;
+use Piwik\Common;
+use Piwik\Db;
+use Piwik\Menu\MenuAbstract;
+use Piwik\Menu\MenuReporting;
+use Piwik\Piwik;
+use Piwik\Site;
+
+/**
+ */
+class Menu extends \Piwik\Plugin\Menu
+{
+ public function configureReportingMenu(MenuReporting $menu)
+ {
+ $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);
+
+ $actions = new Actions();
+ if ($actions->isSiteSearchEnabled()) {
+ $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 9291bc948f..846aec6f3c 100644
--- a/plugins/CoreAdminHome/CoreAdminHome.php
+++ b/plugins/CoreAdminHome/CoreAdminHome.php
@@ -12,12 +12,8 @@ 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;
use Piwik\ScheduledTime;
-use Piwik\Settings\Manager as SettingsManager;
use Piwik\Settings\UserSetting;
/**
@@ -33,7 +29,6 @@ class CoreAdminHome extends \Piwik\Plugin
return array(
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'AssetManager.getJavaScriptFiles' => 'getJsFiles',
- 'Menu.Admin.addItems' => 'addMenu',
'TaskScheduler.getScheduledTasks' => 'getScheduledTasks',
'UsersManager.deleteUser' => 'cleanupUser'
);
@@ -87,27 +82,6 @@ class CoreAdminHome extends \Piwik\Plugin
$jsFiles[] = "plugins/CoreAdminHome/javascripts/pluginSettings.js";
}
- function addMenu(MenuAbstract $menu)
- {
- $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);
- $menu->add('CoreAdminHome_MenuManage', 'CoreAdminHome_TrackingCode',
- array('module' => 'CoreAdminHome', 'action' => 'trackingCodeGenerator'),
- Piwik::isUserHasSomeAdminAccess(),
- $order = 4);
-
- $menu->add('General_Settings', 'CoreAdminHome_PluginSettings',
- array('module' => 'CoreAdminHome', 'action' => 'pluginSettings'),
- SettingsManager::hasPluginsSettingsForCurrentUser(),
- $order = 7);
-
- }
-
function purgeOutdatedArchives()
{
$archiveTables = ArchiveTableCreator::getTablesArchivesInstalled();
diff --git a/plugins/CoreAdminHome/Menu.php b/plugins/CoreAdminHome/Menu.php
new file mode 100644
index 0000000000..5fd4e624f5
--- /dev/null
+++ b/plugins/CoreAdminHome/Menu.php
@@ -0,0 +1,40 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\CoreAdminHome;
+
+use Piwik\Db;
+use Piwik\Menu\MenuAdmin;
+use Piwik\Piwik;
+use Piwik\Settings\Manager as SettingsManager;
+
+class Menu extends \Piwik\Plugin\Menu
+{
+
+ public function configureAdminMenu(MenuAdmin $menu)
+ {
+ $hasAdminAccess = Piwik::isUserHasSomeAdminAccess();
+
+ $menu->add('CoreAdminHome_MenuManage', null, "", $hasAdminAccess, $order = 1);
+ $menu->add('CoreAdminHome_MenuDiagnostic', null, "", $hasAdminAccess, $order = 10);
+ $menu->add('General_Settings', null, "", $hasAdminAccess, $order = 5);
+ $menu->add('General_Settings', 'CoreAdminHome_MenuGeneralSettings',
+ array('module' => 'CoreAdminHome', 'action' => 'generalSettings'),
+ $hasAdminAccess,
+ $order = 6);
+ $menu->add('CoreAdminHome_MenuManage', 'CoreAdminHome_TrackingCode',
+ array('module' => 'CoreAdminHome', 'action' => 'trackingCodeGenerator'),
+ $hasAdminAccess,
+ $order = 4);
+ $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 1e8f9537a2..4014b96bfe 100644
--- a/plugins/CorePluginsAdmin/CorePluginsAdmin.php
+++ b/plugins/CorePluginsAdmin/CorePluginsAdmin.php
@@ -27,7 +27,6 @@ class CorePluginsAdmin extends \Piwik\Plugin
public function getListHooksRegistered()
{
return array(
- 'Menu.Admin.addItems' => 'addMenu',
'AssetManager.getJavaScriptFiles' => 'getJsFiles',
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'TaskScheduler.getScheduledTasks' => 'getScheduledTasks',
@@ -72,44 +71,6 @@ class CorePluginsAdmin extends \Piwik\Plugin
$stylesheets[] = "plugins/CorePluginsAdmin/stylesheets/plugins_admin.less";
}
- function addMenu(MenuAbstract $menu)
- {
- $pluginsUpdateMessage = '';
- $themesUpdateMessage = '';
-
- if (Piwik::hasUserSuperUserAccess() && static::isMarketplaceEnabled()) {
- $marketplace = new Marketplace();
- $pluginsHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = false);
- $themesHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = true);
-
- if (!empty($pluginsHavingUpdate)) {
- $pluginsUpdateMessage = sprintf(' (%d)', count($pluginsHavingUpdate));
- }
- if (!empty($themesHavingUpdate)) {
- $themesUpdateMessage = sprintf(' (%d)', count($themesHavingUpdate));
- }
- }
-
- $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);
- $menu->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('CorePluginsAdmin_Themes') . $themesUpdateMessage,
- array('module' => 'CorePluginsAdmin', 'action' => 'themes', 'activated' => ''),
- Piwik::hasUserSuperUserAccess(),
- $order = 3);
-
- if (static::isMarketplaceEnabled()) {
-
- $menu->add('CorePluginsAdmin_MenuPlatform', 'CorePluginsAdmin_Marketplace',
- array('module' => 'CorePluginsAdmin', 'action' => 'extend', 'activated' => ''),
- !Piwik::isUserIsAnonymous(),
- $order = 5);
-
- }
- }
-
public static function isMarketplaceEnabled()
{
return (bool) Config::getInstance()->General['enable_marketplace'];
diff --git a/plugins/CorePluginsAdmin/Menu.php b/plugins/CorePluginsAdmin/Menu.php
new file mode 100644
index 0000000000..30267dd242
--- /dev/null
+++ b/plugins/CorePluginsAdmin/Menu.php
@@ -0,0 +1,61 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\CorePluginsAdmin;
+
+use Piwik\Db;
+use Piwik\Menu\MenuAdmin;
+use Piwik\Piwik;
+
+/**
+ */
+class Menu extends \Piwik\Plugin\Menu
+{
+
+ public function confiugreAdminMenu(MenuAdmin $menu)
+ {
+ $hasSuperUserAcess = Piwik::hasUserSuperUserAccess();
+ $isAnonymous = Piwik::isUserIsAnonymous();
+ $isMarketplaceEnabled = CorePluginsAdmin::isMarketplaceEnabled();
+
+ $pluginsUpdateMessage = '';
+ $themesUpdateMessage = '';
+
+ if ($hasSuperUserAcess && $isMarketplaceEnabled) {
+ $marketplace = new Marketplace();
+ $pluginsHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = false);
+ $themesHavingUpdate = $marketplace->getPluginsHavingUpdate($themesOnly = true);
+
+ if (!empty($pluginsHavingUpdate)) {
+ $pluginsUpdateMessage = sprintf(' (%d)', count($pluginsHavingUpdate));
+ }
+ if (!empty($themesHavingUpdate)) {
+ $themesUpdateMessage = sprintf(' (%d)', count($themesHavingUpdate));
+ }
+ }
+
+ $menu->add('CorePluginsAdmin_MenuPlatform', null, "", !$isAnonymous, $order = 7);
+ $menu->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('General_Plugins') . $pluginsUpdateMessage,
+ array('module' => 'CorePluginsAdmin', 'action' => 'plugins', 'activated' => ''),
+ $hasSuperUserAcess,
+ $order = 1);
+ $menu->add('CorePluginsAdmin_MenuPlatform', Piwik::translate('CorePluginsAdmin_Themes') . $themesUpdateMessage,
+ array('module' => 'CorePluginsAdmin', 'action' => 'themes', 'activated' => ''),
+ $hasSuperUserAcess,
+ $order = 3);
+
+ if ($isMarketplaceEnabled) {
+ $menu->add('CorePluginsAdmin_MenuPlatform', 'CorePluginsAdmin_Marketplace',
+ array('module' => 'CorePluginsAdmin', 'action' => 'extend', 'activated' => ''),
+ !$isAnonymous,
+ $order = 5);
+
+ }
+ }
+
+}
diff --git a/plugins/CustomVariables/CustomVariables.php b/plugins/CustomVariables/CustomVariables.php
index fc1642ef71..b3237e9a34 100644
--- a/plugins/CustomVariables/CustomVariables.php
+++ b/plugins/CustomVariables/CustomVariables.php
@@ -35,7 +35,6 @@ class CustomVariables extends \Piwik\Plugin
{
$hooks = array(
'WidgetsList.addWidgets' => 'addWidgets',
- 'Menu.Reporting.addItems' => 'addMenus',
'Goals.getReportsWithGoalMetrics' => 'getReportsWithGoalMetrics',
'API.getReportMetadata' => 'getReportMetadata',
'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata',
@@ -49,11 +48,6 @@ class CustomVariables extends \Piwik\Plugin
WidgetsList::add('General_Visitors', 'CustomVariables_CustomVariables', 'CustomVariables', 'getCustomVariables');
}
- public function addMenus(MenuAbstract $menu)
- {
- $menu->add('General_Visitors', 'CustomVariables_CustomVariables', array('module' => 'CustomVariables', 'action' => 'index'), $display = true, $order = 50);
- }
-
public function install()
{
Model::install();
diff --git a/plugins/CustomVariables/Menu.php b/plugins/CustomVariables/Menu.php
new file mode 100644
index 0000000000..161723b57c
--- /dev/null
+++ b/plugins/CustomVariables/Menu.php
@@ -0,0 +1,24 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\CustomVariables;
+
+use Piwik\Db;
+use Piwik\Menu\MenuReporting;
+
+/**
+ */
+class Menu extends \Piwik\Plugin\Menu
+{
+
+ public function confiugreReportingMenu(MenuReporting $menu)
+ {
+ $menu->add('General_Visitors', 'CustomVariables_CustomVariables', array('module' => 'CustomVariables', 'action' => 'index'), $display = true, $order = 50);
+ }
+
+}
diff --git a/plugins/DBStats/DBStats.php b/plugins/DBStats/DBStats.php
index 4b95c95f1c..e1b02aa5bd 100644
--- a/plugins/DBStats/DBStats.php
+++ b/plugins/DBStats/DBStats.php
@@ -34,7 +34,6 @@ class DBStats extends \Piwik\Plugin
{
return array(
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
- 'Menu.Admin.addItems' => 'addMenu',
'TaskScheduler.getScheduledTasks' => 'getScheduledTasks',
'ViewDataTable.configure' => 'configureViewDataTable',
'ViewDataTable.getDefaultType' => 'getDefaultTypeViewDataTable',
@@ -42,14 +41,6 @@ class DBStats extends \Piwik\Plugin
);
}
- function addMenu(MenuAbstract $menu)
- {
- $menu->add('CoreAdminHome_MenuDiagnostic', 'DBStats_DatabaseUsage',
- array('module' => 'DBStats', 'action' => 'index'),
- Piwik::hasUserSuperUserAccess(),
- $order = 6);
- }
-
/**
* Gets all scheduled tasks executed by this plugin.
*/
diff --git a/plugins/DBStats/Menu.php b/plugins/DBStats/Menu.php
new file mode 100644
index 0000000000..aa1c1693a4
--- /dev/null
+++ b/plugins/DBStats/Menu.php
@@ -0,0 +1,32 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\DBStats;
+
+use Exception;
+use Piwik\Common;
+use Piwik\Db;
+use Piwik\Menu\MenuAbstract;
+use Piwik\Menu\MenuAdmin;
+use Piwik\Menu\MenuReporting;
+use Piwik\Menu\MenuTop;
+use Piwik\Piwik;
+use Piwik\Site;
+
+/**
+ */
+class Menu extends \Piwik\Plugin\Menu
+{
+ public function configureAdminMenu(MenuAdmin $menu)
+ {
+ $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 ee62279110..7eacb90922 100644
--- a/plugins/Dashboard/Dashboard.php
+++ b/plugins/Dashboard/Dashboard.php
@@ -32,8 +32,6 @@ class Dashboard extends \Piwik\Plugin
'AssetManager.getJavaScriptFiles' => 'getJsFiles',
'AssetManager.getStylesheetFiles' => 'getStylesheetFiles',
'UsersManager.deleteUser' => 'deleteDashboardLayout',
- 'Menu.Reporting.addItems' => 'addMenus',
- 'Menu.Top.addItems' => 'addTopMenu',
'Translate.getClientSideTranslationKeys' => 'getClientSideTranslationKeys'
);
}
@@ -197,37 +195,6 @@ class Dashboard extends \Piwik\Plugin
return Common::json_encode($layout);
}
- public function addMenus(MenuAbstract $menu)
- {
- $menu->add('Dashboard_Dashboard', '', array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => 1), true, 5);
-
- if (!Piwik::isUserIsAnonymous()) {
- $login = Piwik::getCurrentUserLogin();
-
- $dashboards = $this->getAllDashboards($login);
-
- $pos = 0;
- foreach ($dashboards as $dashboard) {
- $menu->add('Dashboard_Dashboard', $dashboard['name'], array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => $dashboard['iddashboard']), true, $pos);
- $pos++;
- }
- }
- }
-
- public function addTopMenu(MenuTop $menu)
- {
- $tooltip = false;
- try {
- $idSite = Common::getRequestVar('idSite');
- $tooltip = Piwik::translate('Dashboard_TopLinkTooltip', Site::getNameFor($idSite));
- } catch (Exception $ex) {
- // if no idSite parameter, show no tooltip
- }
-
- $urlParams = array('module' => 'CoreHome', 'action' => 'index');
- $menu->add('Dashboard_Dashboard', null, $urlParams, true, 1, $isHTML = false, $tooltip);
- }
-
public function getJsFiles(&$jsFiles)
{
$jsFiles[] = "plugins/Dashboard/javascripts/widgetMenu.js";
diff --git a/plugins/Dashboard/Menu.php b/plugins/Dashboard/Menu.php
new file mode 100644
index 0000000000..8256c2b74c
--- /dev/null
+++ b/plugins/Dashboard/Menu.php
@@ -0,0 +1,56 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\Dashboard;
+
+use Exception;
+use Piwik\Common;
+use Piwik\Db;
+use Piwik\Menu\MenuAbstract;
+use Piwik\Menu\MenuReporting;
+use Piwik\Menu\MenuTop;
+use Piwik\Piwik;
+use Piwik\Site;
+
+/**
+ */
+class Menu extends \Piwik\Plugin\Menu
+{
+ public function configureReportingMenu(MenuReporting $menu)
+ {
+ $menu->add('Dashboard_Dashboard', '', array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => 1), true, 5);
+
+ if (!Piwik::isUserIsAnonymous()) {
+ $login = Piwik::getCurrentUserLogin();
+
+ $dashboard = new Dashboard();
+ $dashboards = $dashboard->getAllDashboards($login);
+
+ $pos = 0;
+ foreach ($dashboards as $dashboard) {
+ $menu->add('Dashboard_Dashboard', $dashboard['name'], array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => $dashboard['iddashboard']), true, $pos);
+ $pos++;
+ }
+ }
+ }
+
+ public function configureTopMenu(MenuTop $menu)
+ {
+ $tooltip = false;
+ try {
+ $idSite = Common::getRequestVar('idSite');
+ $tooltip = Piwik::translate('Dashboard_TopLinkTooltip', Site::getNameFor($idSite));
+ } catch (Exception $ex) {
+ // if no idSite parameter, show no tooltip
+ }
+
+ $urlParams = array('module' => 'CoreHome', 'action' => 'index');
+
+ $menu->add('Dashboard_Dashboard', null, $urlParams, true, 1, $tooltip);
+ }
+}
diff --git a/plugins/DevicesDetection/DevicesDetection.php b/plugins/DevicesDetection/DevicesDetection.php
index 4993b19841..d6ded700e8 100644
--- a/plugins/DevicesDetection/DevicesDetection.php
+++ b/plugins/DevicesDetection/DevicesDetection.php
@@ -90,8 +90,6 @@ class DevicesDetection extends \Piwik\Plugin
public function getListHooksRegistered()
{
return array(
- 'Menu.Reporting.addItems' => 'addMenu',
- 'Menu.Admin.addItems' => 'addAdminMenu',
'Tracker.newVisitorInformation' => 'parseMobileVisitData',
'WidgetsList.addWidgets' => 'addWidgets',
'API.getReportMetadata' => 'getReportMetadata',
@@ -100,16 +98,6 @@ class DevicesDetection extends \Piwik\Plugin
);
}
- public function addAdminMenu(MenuAbstract $menu)
- {
- $menu->add(
- 'CoreAdminHome_MenuDiagnostic', 'DevicesDetection_DeviceDetection',
- array('module' => 'DevicesDetection', 'action' => 'deviceDetection'),
- Piwik::isUserHasSomeAdminAccess(),
- $order = 40
- );
- }
-
/**
* Defines API reports.
* Also used to define Widgets, and Segment(s)
@@ -273,11 +261,6 @@ class DevicesDetection extends \Piwik\Plugin
Common::printDebug($deviceInfo);
}
- public function addMenu(MenuAbstract $menu)
- {
- $menu->add('General_Visitors', 'DevicesDetection_submenu', array('module' => 'DevicesDetection', 'action' => 'index'));
- }
-
public function configureViewDataTable(ViewDataTable $view)
{
switch ($view->requestConfig->apiMethodToRequestDataTable) {
diff --git a/plugins/DevicesDetection/Menu.php b/plugins/DevicesDetection/Menu.php
new file mode 100644
index 0000000000..c67778a5b4
--- /dev/null
+++ b/plugins/DevicesDetection/Menu.php
@@ -0,0 +1,33 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\DevicesDetection;
+
+use Piwik\Menu\MenuAdmin;
+use Piwik\Menu\MenuReporting;
+use Piwik\Piwik;
+
+/**
+ */
+class Menu extends \Piwik\Plugin\Menu
+{
+ public function configureAdminMenu(MenuAdmin $menu)
+ {
+ $menu->add(
+ 'CoreAdminHome_MenuDiagnostic', 'DevicesDetection_DeviceDetection',
+ array('module' => 'DevicesDetection', 'action' => 'deviceDetection'),
+ Piwik::isUserHasSomeAdminAccess(),
+ $order = 40
+ );
+ }
+
+ public function configureReporingMenu(MenuReporting $menu)
+ {
+ $menu->add('General_Visitors', 'DevicesDetection_submenu', array('module' => 'DevicesDetection', 'action' => 'index'));
+ }
+}
diff --git a/plugins/Events/Events.php b/plugins/Events/Events.php
index f5c87b5983..ee4132ddf3 100644
--- a/plugins/Events/Events.php
+++ b/plugins/Events/Events.php
@@ -28,7 +28,6 @@ class Events extends \Piwik\Plugin
'API.getSegmentDimensionMetadata' => 'getSegmentsMetadata',
'Metrics.getDefaultMetricTranslations' => 'addMetricTranslations',
'API.getReportMetadata' => 'getReportMetadata',
- 'Menu.Reporting.addItems' => 'addMenus',
'WidgetsList.addWidgets' => 'addWidgets',
'ViewDataTable.configure' => 'configureViewDataTable',
@@ -44,11 +43,6 @@ class Events extends \Piwik\Plugin
}
}
- public function addMenus(MenuAbstract $menu)
- {
- $menu->add('General_Actions', 'Events_Events', array('module' => 'Events', 'action' => 'index'), true, 30);
- }
-
public function addMetricTranslations(&$translations)
{
$translations = array_merge($translations, $this->getMetricTranslations());
diff --git a/plugins/Events/Menu.php b/plugins/Events/Menu.php
new file mode 100644
index 0000000000..1a0585a5cd
--- /dev/null
+++ b/plugins/Events/Menu.php
@@ -0,0 +1,21 @@
+<?php
+/**
+ * Piwik - Open source web analytics
+ *
+ * @link http://piwik.org
+ * @license http://www.gnu.org/licenses/gpl-3.0.html GPL v3 or later
+ *
+ */
+namespace Piwik\Plugins\Events;
+
+use Piwik\Menu\MenuReporting;
+
+/**
+ */
+class Menu extends \Piwik\Plugin\Menu
+{
+ public function configureReporingMenu(MenuReporting $menu)
+ {
+ $menu->add('General_Actions', 'Events_Events', array('module' => 'Events', 'action' => 'index'), true, 30);
+ }
+}