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:45:41 +0400
committermattab <matthieu.aubry@gmail.com>2013-10-09 13:45:41 +0400
commit500373c8f5bb32fa8c3488c551f357570c80e78d (patch)
tree12d4ea151445a1849e9ed4a06583a4fa956d3da5 /core/Menu
parent88a1d58d355430416f352c22ca3e4a6d56032bcc (diff)
Refs #4202 Menu refactor GO. This one is tricky...
Diffstat (limited to 'core/Menu')
-rw-r--r--core/Menu/MenuAbstract.php4
-rw-r--r--core/Menu/MenuAdmin.php8
-rw-r--r--core/Menu/MenuTop.php30
3 files changed, 32 insertions, 10 deletions
diff --git a/core/Menu/MenuAbstract.php b/core/Menu/MenuAbstract.php
index a0fa8c4c2b..fc4eddb0ca 100644
--- a/core/Menu/MenuAbstract.php
+++ b/core/Menu/MenuAbstract.php
@@ -36,7 +36,7 @@ abstract class MenuAbstract
*
* @return Array
*/
- public function get()
+ public function getMenu()
{
$this->buildMenu();
$this->applyEdits();
@@ -55,7 +55,7 @@ abstract class MenuAbstract
* @param int $order
* @param bool|string $tooltip Tooltip to display.
*/
- public function add($menuName, $subMenuName, $url, $displayedForCurrentUser, $order = 50, $tooltip = false)
+ public function add($menuName, $subMenuName, $url, $displayedForCurrentUser = true, $order = 50, $tooltip = false)
{
if ($displayedForCurrentUser) {
// make sure the idSite value used is numeric (hack-y fix for #3426)
diff --git a/core/Menu/MenuAdmin.php b/core/Menu/MenuAdmin.php
index f34aa15865..852e252e64 100644
--- a/core/Menu/MenuAdmin.php
+++ b/core/Menu/MenuAdmin.php
@@ -20,7 +20,7 @@ class MenuAdmin extends MenuAbstract
static private $instance = null;
/**
- * @return \Piwik\Menu\MenuAdmin
+ * @return MenuAdmin
*/
static public function getInstance()
{
@@ -63,7 +63,7 @@ class MenuAdmin extends MenuAbstract
* ```
* public function addMenuItems()
* {
- * \Piwik\Menu\MenuAdmin::getInstance()->add(
+ * MenuAdmin::getInstance()->add(
* 'MenuName',
* 'SubmenuName',
* array('module' => 'MyPlugin', 'action' => 'index'),
@@ -73,7 +73,7 @@ class MenuAdmin extends MenuAbstract
* }
* ```
*/
- Piwik::postEvent('Menu.MenuAdmin.addItems');
+ Piwik::postEvent('Menu.Admin.addItems');
}
return parent::getMenu();
}
@@ -85,7 +85,7 @@ class MenuAdmin extends MenuAbstract
*/
function getCurrentAdminMenuName()
{
- $menu = \Piwik\Menu\MenuAdmin::getInstance();
+ $menu = MenuAdmin::getInstance()->getMenu();
$currentModule = Piwik::getModule();
$currentAction = Piwik::getAction();
foreach ($menu as $submenu) {
diff --git a/core/Menu/MenuTop.php b/core/Menu/MenuTop.php
index 8573e527fd..29f056367a 100644
--- a/core/Menu/MenuTop.php
+++ b/core/Menu/MenuTop.php
@@ -20,7 +20,7 @@ class MenuTop extends MenuAbstract
static private $instance = null;
/**
- * @return \Piwik\Menu\MenuTop
+ * @return MenuTop
*/
static public function getInstance()
{
@@ -30,6 +30,28 @@ class MenuTop extends MenuAbstract
return self::$instance;
}
+
+ /**
+ * Adds a new entry to the TopMenu.
+ *
+ * @param string $topMenuName
+ * @param string $data
+ * @param boolean $displayedForCurrentUser
+ * @param int $order
+ * @param bool $isHTML
+ * @param bool|string $tooltip Tooltip to display.
+ * @api
+ */
+ public static function addEntry($topMenuName, $data, $displayedForCurrentUser = true, $order = 10, $isHTML = false, $tooltip = false)
+ {
+ if ($isHTML) {
+ MenuTop::getInstance()->addHtml($topMenuName, $data, $displayedForCurrentUser, $order, $tooltip);
+ } else {
+ MenuTop::getInstance()->add($topMenuName, null, $data, $displayedForCurrentUser, $order, $tooltip);
+ }
+ }
+
+
/**
* Directly adds a menu entry containing html.
*
@@ -52,7 +74,7 @@ class MenuTop extends MenuAbstract
}
/**
- * Triggers the Menu.MenuTop.addItems hook and returns the menu.
+ * Triggers the Menu.Top.addItems hook and returns the menu.
*
* @return Array
*/
@@ -71,7 +93,7 @@ class MenuTop extends MenuAbstract
* ```
* public function addMenuItems()
* {
- * Piwik_AddTopMenu(
+ * MenuTop::addEntry(
* 'TopMenuName',
* array('module' => 'MyPlugin', 'action' => 'index'),
* Piwik::isUserIsSuperUser(),
@@ -80,7 +102,7 @@ class MenuTop extends MenuAbstract
* }
* ```
*/
- Piwik::postEvent('Menu.MenuTop.addItems');
+ Piwik::postEvent('Menu.Top.addItems');
}
return parent::getMenu();
}