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
path: root/core/Menu
diff options
context:
space:
mode:
authormattab <matthieu.aubry@gmail.com>2013-10-09 13:44:03 +0400
committermattab <matthieu.aubry@gmail.com>2013-10-09 13:44:03 +0400
commite9817e9143b0cd0c080dc106938f75e489e0cbf7 (patch)
treefbe41740aa7f6e8d213eff036eec073889829de0 /core/Menu
parentdd3b7490cd207b7f91b3f51f103079f5d927b49e (diff)
Refs #4202 Menu refactor GO. This one is tricky...
Diffstat (limited to 'core/Menu')
-rw-r--r--core/Menu/MenuAdmin.php (renamed from core/Menu/Admin.php)30
-rw-r--r--core/Menu/MenuMain.php (renamed from core/Menu/Main.php)10
-rw-r--r--core/Menu/MenuTop.php (renamed from core/Menu/Top.php)12
3 files changed, 33 insertions, 19 deletions
diff --git a/core/Menu/Admin.php b/core/Menu/MenuAdmin.php
index 2c9bf93393..f34aa15865 100644
--- a/core/Menu/Admin.php
+++ b/core/Menu/MenuAdmin.php
@@ -15,12 +15,12 @@ use Piwik\Piwik;
/**
* @package Piwik_Menu
*/
-class Admin extends MenuAbstract
+class MenuAdmin extends MenuAbstract
{
static private $instance = null;
/**
- * @return \Piwik\Menu\Admin
+ * @return \Piwik\Menu\MenuAdmin
*/
static public function getInstance()
{
@@ -31,11 +31,25 @@ class Admin extends MenuAbstract
}
/**
- * Triggers the Menu.Admin.addItems hook and returns the menu.
+ * Adds a new AdminMenu entry.
+ *
+ * @param string $adminMenuName
+ * @param string $url
+ * @param boolean $displayedForCurrentUser
+ * @param int $order
+ * @api
+ */
+ public static function addEntry($adminMenuName, $url, $displayedForCurrentUser = true, $order = 20)
+ {
+ self::getInstance()->add('General_Settings', 'General_Settings', $adminMenuName, $url, $displayedForCurrentUser, $order);
+ }
+
+ /**
+ * Triggers the Menu.MenuAdmin.addItems hook and returns the admin menu.
*
* @return Array
*/
- public function get()
+ public function getMenu()
{
if (!$this->menu) {
@@ -49,7 +63,7 @@ class Admin extends MenuAbstract
* ```
* public function addMenuItems()
* {
- * Piwik_AddAdminSubMenu(
+ * \Piwik\Menu\MenuAdmin::getInstance()->add(
* 'MenuName',
* 'SubmenuName',
* array('module' => 'MyPlugin', 'action' => 'index'),
@@ -59,9 +73,9 @@ class Admin extends MenuAbstract
* }
* ```
*/
- Piwik::postEvent('Menu.Admin.addItems');
+ Piwik::postEvent('Menu.MenuAdmin.addItems');
}
- return parent::get();
+ return parent::getMenu();
}
/**
@@ -71,7 +85,7 @@ class Admin extends MenuAbstract
*/
function getCurrentAdminMenuName()
{
- $menu = Piwik_GetAdminMenu();
+ $menu = \Piwik\Menu\MenuAdmin::getInstance();
$currentModule = Piwik::getModule();
$currentAction = Piwik::getAction();
foreach ($menu as $submenu) {
diff --git a/core/Menu/Main.php b/core/Menu/MenuMain.php
index db858f8c74..2485f18294 100644
--- a/core/Menu/Main.php
+++ b/core/Menu/MenuMain.php
@@ -15,7 +15,7 @@ use Piwik\Piwik;
/**
* @package Piwik_Menu
*/
-class Main extends MenuAbstract
+class MenuMain extends MenuAbstract
{
static private $instance = null;
@@ -38,7 +38,7 @@ class Main extends MenuAbstract
*/
public function isUrlFound($url)
{
- $menu = Main::getInstance()->get();
+ $menu = MenuMain::getInstance()->getMenu();
foreach ($menu as $subMenus) {
foreach ($subMenus as $subMenuName => $menuUrl) {
@@ -55,7 +55,7 @@ class Main extends MenuAbstract
*
* @return Array
*/
- public function get()
+ public function getMenu()
{
// We trigger the Event only once!
if (!$this->menu) {
@@ -70,7 +70,7 @@ class Main extends MenuAbstract
* ```
* public function addMenuItems()
* {
- * Piwik_AddMenu(
+ * \Piwik\Menu\Main::getInstance()->add(
* 'CustomMenuName',
* 'CustomSubmenuName',
* array('module' => 'MyPlugin', 'action' => 'index'),
@@ -82,7 +82,7 @@ class Main extends MenuAbstract
*/
Piwik::postEvent('Menu.Reporting.addItems');
}
- return parent::get();
+ return parent::getMenu();
}
}
diff --git a/core/Menu/Top.php b/core/Menu/MenuTop.php
index 52d6f7ef31..8573e527fd 100644
--- a/core/Menu/Top.php
+++ b/core/Menu/MenuTop.php
@@ -15,12 +15,12 @@ use Piwik\Piwik;
/**
* @package Piwik_Menu
*/
-class Top extends MenuAbstract
+class MenuTop extends MenuAbstract
{
static private $instance = null;
/**
- * @return \Piwik\Menu\Top
+ * @return \Piwik\Menu\MenuTop
*/
static public function getInstance()
{
@@ -52,11 +52,11 @@ class Top extends MenuAbstract
}
/**
- * Triggers the Menu.Top.addItems hook and returns the menu.
+ * Triggers the Menu.MenuTop.addItems hook and returns the menu.
*
* @return Array
*/
- public function get()
+ public function getMenu()
{
if (!$this->menu) {
@@ -80,8 +80,8 @@ class Top extends MenuAbstract
* }
* ```
*/
- Piwik::postEvent('Menu.Top.addItems');
+ Piwik::postEvent('Menu.MenuTop.addItems');
}
- return parent::get();
+ return parent::getMenu();
}
}