Skip to content
Extraits de code Groupes Projets
Valider eee6ed99 rédigé par Thomas Steur's avatar Thomas Steur
Parcourir les fichiers

refs #6140 easier way to define URLs for menu items and introducing a method...

refs #6140 easier way to define URLs for menu items and introducing a method to addItem without boolean parameter
parent 099c969c
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
Affichage de
avec 196 ajouts et 81 suppressions
...@@ -2,6 +2,15 @@ ...@@ -2,6 +2,15 @@
This is a changelog for Piwik platform developers. All changes for our HTTP API's, Plugins, Themes, etc will be listed here. This is a changelog for Piwik platform developers. All changes for our HTTP API's, Plugins, Themes, etc will be listed here.
## Piwik 2.7.0
### Deprecations
* The `Piwik\Menu\MenuAbstract::add()` method is deprecated in favor of `addItem()`. Read more about this here: [#6140](https://github.com/piwik/piwik/issues/6140). We do not plan to remove the deprecated method before Piwik 3.0.
### New APIs
* It is now easier to generate the URL for a menu item see [#6140](https://github.com/piwik/piwik/issues/6140), [urlForDefaultAction()](http://developer.piwik.org/api-reference/Piwik/Menu/MenuAbstract#urlfordefaultaction):, [urlForAction()](http://developer.piwik.org/api-reference/Piwik/Menu/MenuAbstract#urlforaction), [urlForModuleAction()](http://developer.piwik.org/api-reference/Piwik/Menu/MenuAbstract#urlformoduleaction)
## Piwik 2.6.0 ## Piwik 2.6.0
### New features ### New features
......
...@@ -77,16 +77,32 @@ abstract class MenuAbstract extends Singleton ...@@ -77,16 +77,32 @@ abstract class MenuAbstract extends Singleton
* current user. If false, the entry will not be added. * current user. If false, the entry will not be added.
* @param int $order The order hint. * @param int $order The order hint.
* @param bool|string $tooltip An optional tooltip to display or false to display the tooltip. * @param bool|string $tooltip An optional tooltip to display or false to display the tooltip.
* @api *
* @deprecated since 2.7.0 Use {@link addItem() instead}. Method will be removed in Piwik 3.0
*/ */
public function add($menuName, $subMenuName, $url, $displayedForCurrentUser = true, $order = 50, $tooltip = false) public function add($menuName, $subMenuName, $url, $displayedForCurrentUser = true, $order = 50, $tooltip = false)
{ {
if (!$displayedForCurrentUser) { if (!$displayedForCurrentUser) {
// TODO this parameter should be removed and instead menu items should be only added if it is supposed to be
// displayed. Won't do it now to stay backward compatible. For Piwik 3.0 we should do it.
return; return;
} }
$this->addItem($menuName, $subMenuName, $url, $order, $tooltip);
}
/**
* Adds a new entry to the menu.
*
* @param string $menuName The menu's category name. Can be a translation token.
* @param string $subMenuName The menu item's name. Can be a translation token.
* @param string|array $url The URL the admin menu entry should link to, or an array of query parameters
* that can be used to build the URL.
* @param int $order The order hint.
* @param bool|string $tooltip An optional tooltip to display or false to display the tooltip.
* @since 2.7.0
* @api
*/
public function addItem($menuName, $subMenuName, $url, $order = 50, $tooltip = false)
{
// make sure the idSite value used is numeric (hack-y fix for #3426) // make sure the idSite value used is numeric (hack-y fix for #3426)
if (!is_numeric(Common::getRequestVar('idSite', false))) { if (!is_numeric(Common::getRequestVar('idSite', false))) {
$idSites = API::getInstance()->getSitesIdWithAtLeastViewAccess(); $idSites = API::getInstance()->getSitesIdWithAtLeastViewAccess();
......
...@@ -12,6 +12,7 @@ use Piwik\Menu\MenuAdmin; ...@@ -12,6 +12,7 @@ use Piwik\Menu\MenuAdmin;
use Piwik\Menu\MenuReporting; use Piwik\Menu\MenuReporting;
use Piwik\Menu\MenuTop; use Piwik\Menu\MenuTop;
use Piwik\Menu\MenuUser; use Piwik\Menu\MenuUser;
use Piwik\Plugin\Manager as PluginManager;
/** /**
* Base class of all plugin menu providers. Plugins that define their own menu items can extend this class to easily * Base class of all plugin menu providers. Plugins that define their own menu items can extend this class to easily
...@@ -27,6 +28,102 @@ use Piwik\Menu\MenuUser; ...@@ -27,6 +28,102 @@ use Piwik\Menu\MenuUser;
*/ */
class Menu class Menu
{ {
protected $module = '';
/**
* @ignore
*/
public function __construct()
{
$this->module = $this->getModule();
}
private function getModule()
{
$className = get_class($this);
$className = explode('\\', $className);
return $className[2];
}
/**
* Generates a URL for the default action of the plugin controller.
*
* Example:
* ```
* $menu->addItem('UI Framework', '', $this->urlForDefaultAction(), $orderId = 30);
* // will add a menu item that leads to the default action of the plugin controller when a user clicks on it.
* // The default action is usually the `index` action - meaning the `index()` method the controller -
* // but the default action can be customized within a controller
* ```
*
* @param array $additionalParams Optional URL parameters that will be appended to the URL
* @return array
*
* @since 2.7.0
* @api
*/
protected function urlForDefaultAction($additionalParams = array())
{
$params = (array) $additionalParams;
$params['action'] = '';
$params['module'] = $this->module;
return $params;
}
/**
* Generates a URL for the given action. In your plugin controller you have to create a method with the same name
* as this method will be executed when a user clicks on the menu item. If you want to generate a URL for the
* action of another module, meaning not your plugin, you should use the method {@link urlForModuleAction()}.
*
* @param string $controllerAction The name of the action that should be executed within your controller
* @param array $additionalParams Optional URL parameters that will be appended to the URL
* @return array
*
* @since 2.7.0
* @api
*/
protected function urlForAction($controllerAction, $additionalParams = array())
{
$params = (array) $additionalParams;
$params['action'] = $controllerAction;
$params['module'] = $this->module;
return $params;
}
/**
* Generates a URL for the given action of the given module. We usually do not recommend to use this method as you
* should make sure the method of that module actually exists. If the plugin owner of that module changes the method
* in a future version your link might no longer work. If you want to link to an action of your controller use the
* method {@link urlForAction()}. Note: We will generate a link only if the given module is installed and activated.
*
* @param string $module The name of the module/plugin the action belongs to. The module name is case sensitive.
* @param string $controllerAction The name of the action that should be executed within your controller
* @param array $additionalParams Optional URL parameters that will be appended to the URL
* @return array|null Returns null if the given module is either not installed or not activated. Returns the URL
* to the given module action otherwise.
*
* @since 2.7.0
* // not API for now
*/
protected function urlForModuleAction($module, $controllerAction, $additionalParams = array())
{
$pluginManager = PluginManager::getInstance();
if (!$pluginManager->isPluginLoaded($module) ||
!$pluginManager->isPluginActivated($module)) {
return null;
}
$params = (array) $additionalParams;
$params['action'] = $controllerAction;
$params['module'] = $module;
return $params;
}
/** /**
* Configures the reporting menu which should only contain links to reports of a specific site such as * Configures the reporting menu which should only contain links to reports of a specific site such as
* "Search Engines", "Page Titles" or "Locations & Provider". * "Search Engines", "Page Titles" or "Locations & Provider".
......
...@@ -26,7 +26,7 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -26,7 +26,7 @@ class Menu extends \Piwik\Plugin\Menu
public function configureUserMenu(MenuUser $menu) public function configureUserMenu(MenuUser $menu)
{ {
$apiUrlParams = array('module' => 'API', 'action' => 'listAllAPI', 'segment' => false); $apiUrlParams = $this->urlForAction('listAllAPI', array('segment' => false));
$tooltip = Piwik::translate('API_TopLinkTooltip'); $tooltip = Piwik::translate('API_TopLinkTooltip');
$menu->addPlatformItem('General_API', $apiUrlParams, 6, $tooltip); $menu->addPlatformItem('General_API', $apiUrlParams, 6, $tooltip);
...@@ -45,8 +45,14 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -45,8 +45,14 @@ class Menu extends \Piwik\Plugin\Menu
$ua = new OperatingSystem($_SERVER['HTTP_USER_AGENT']); $ua = new OperatingSystem($_SERVER['HTTP_USER_AGENT']);
$ua->setCache(new DeviceDetectorCache('tracker', 86400)); $ua->setCache(new DeviceDetectorCache('tracker', 86400));
$parsedOS = $ua->parse(); $parsedOS = $ua->parse();
if (!empty($parsedOS['short_name']) && in_array($parsedOS['short_name'], array(self::DD_SHORT_NAME_ANDROID, self::DD_SHORT_NAME_IOS))) { if (!empty($parsedOS['short_name']) && in_array($parsedOS['short_name'], array(self::DD_SHORT_NAME_ANDROID, self::DD_SHORT_NAME_IOS))) {
$menu->add('Piwik Mobile App', null, array('module' => 'Proxy', 'action' => 'redirect', 'url' => 'http://piwik.org/mobile/'), true, 4);
$url = $this->urlForModuleAction('Proxy', 'redirect', array('url' => 'http://piwik.org/mobile/'));
if ($url) {
$menu->addItem('Piwik Mobile App', null, $url, 4);
}
} }
} }
......
...@@ -14,16 +14,11 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -14,16 +14,11 @@ class Menu extends \Piwik\Plugin\Menu
{ {
public function configureReportingMenu(MenuReporting $menu) public function configureReportingMenu(MenuReporting $menu)
{ {
$urlParams = array( $menu->addActionsItem('', $this->urlForAction('menuGetPageUrls'), 15);
'module' => 'Actions',
'action' => 'menuGetPageUrls'
);
$menu->addActionsItem('', $urlParams, 15);
$actions = new Actions(); $actions = new Actions();
if ($actions->isSiteSearchEnabled()) { if ($actions->isSiteSearchEnabled()) {
$menu->addActionsItem('Actions_SubmenuSitesearch', array('module' => 'Actions', 'action' => 'indexSiteSearch'), 5); $menu->addActionsItem('Actions_SubmenuSitesearch', $this->urlForAction('indexSiteSearch'), 5);
} }
} }
......
...@@ -27,16 +27,16 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -27,16 +27,16 @@ class Menu extends \Piwik\Plugin\Menu
$menu->addDevelopmentItem(null, "", $order = 15); $menu->addDevelopmentItem(null, "", $order = 15);
$menu->addSettingsItem('CoreAdminHome_MenuGeneralSettings', $menu->addSettingsItem('CoreAdminHome_MenuGeneralSettings',
array('module' => 'CoreAdminHome', 'action' => 'generalSettings'), $this->urlForAction('generalSettings'),
$order = 6); $order = 6);
$menu->addManageItem('CoreAdminHome_TrackingCode', $menu->addManageItem('CoreAdminHome_TrackingCode',
array('module' => 'CoreAdminHome', 'action' => 'trackingCodeGenerator'), $this->urlForAction('trackingCodeGenerator'),
$order = 4); $order = 4);
} }
if (SettingsManager::hasPluginsSettingsForCurrentUser()) { if (SettingsManager::hasPluginsSettingsForCurrentUser()) {
$menu->addSettingsItem('CoreAdminHome_PluginSettings', $menu->addSettingsItem('CoreAdminHome_PluginSettings',
array('module' => 'CoreAdminHome', 'action' => 'pluginSettings'), $this->urlForAction('pluginSettings'),
$order = 7); $order = 7);
} }
} }
......
...@@ -46,16 +46,16 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -46,16 +46,16 @@ class Menu extends \Piwik\Plugin\Menu
if ($hasSuperUserAcess) { if ($hasSuperUserAcess) {
$menu->addPlatformItem(Piwik::translate('General_Plugins') . $pluginsUpdateMessage, $menu->addPlatformItem(Piwik::translate('General_Plugins') . $pluginsUpdateMessage,
array('module' => 'CorePluginsAdmin', 'action' => 'plugins', 'activated' => ''), $this->urlForAction('plugins', array('activated' => '')),
$order = 1); $order = 1);
$menu->addPlatformItem(Piwik::translate('CorePluginsAdmin_Themes') . $themesUpdateMessage, $menu->addPlatformItem(Piwik::translate('CorePluginsAdmin_Themes') . $themesUpdateMessage,
array('module' => 'CorePluginsAdmin', 'action' => 'themes', 'activated' => ''), $this->urlForAction('themes', array('activated' => '')),
$order = 3); $order = 3);
} }
if ($this->isAllowedToSeeMarketPlace()) { if ($this->isAllowedToSeeMarketPlace()) {
$menu->addPlatformItem('CorePluginsAdmin_Marketplace', $menu->addPlatformItem('CorePluginsAdmin_Marketplace',
array('module' => 'CorePluginsAdmin', 'action' => 'extend', 'activated' => ''), $this->urlForAction('extend', array('activated' => '')),
$order = 5); $order = 5);
} }
...@@ -73,8 +73,8 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -73,8 +73,8 @@ class Menu extends \Piwik\Plugin\Menu
{ {
if ($this->isAllowedToSeeMarketPlace()) { if ($this->isAllowedToSeeMarketPlace()) {
$menu->addPlatformItem('CorePluginsAdmin_Marketplace', $menu->addPlatformItem('CorePluginsAdmin_Marketplace',
array('module' => 'CorePluginsAdmin', 'action' => 'browsePlugins', 'activated' => ''), $this->urlForAction('browsePlugins', array('activated' => '')),
$order = 5); $order = 5);
} }
} }
} }
...@@ -19,7 +19,7 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -19,7 +19,7 @@ class Menu extends \Piwik\Plugin\Menu
{ {
if (Piwik::hasUserSuperUserAccess()) { if (Piwik::hasUserSuperUserAccess()) {
$menu->addDiagnosticItem('DBStats_DatabaseUsage', $menu->addDiagnosticItem('DBStats_DatabaseUsage',
array('module' => 'DBStats', 'action' => 'index'), $this->urlForAction('index'),
$order = 6); $order = 6);
} }
} }
......
...@@ -21,7 +21,7 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -21,7 +21,7 @@ class Menu extends \Piwik\Plugin\Menu
{ {
public function configureReportingMenu(MenuReporting $menu) public function configureReportingMenu(MenuReporting $menu)
{ {
$menu->add('Dashboard_Dashboard', '', array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => 1), true, 5); $menu->addItem('Dashboard_Dashboard', '', $this->urlForAction('embeddedIndex', array('idDashboard' => 1)), 5);
if (!Piwik::isUserIsAnonymous()) { if (!Piwik::isUserIsAnonymous()) {
$login = Piwik::getCurrentUserLogin(); $login = Piwik::getCurrentUserLogin();
...@@ -31,7 +31,7 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -31,7 +31,7 @@ class Menu extends \Piwik\Plugin\Menu
$pos = 0; $pos = 0;
foreach ($dashboards as $dashboard) { foreach ($dashboards as $dashboard) {
$menu->add('Dashboard_Dashboard', $dashboard['name'], array('module' => 'Dashboard', 'action' => 'embeddedIndex', 'idDashboard' => $dashboard['iddashboard']), true, $pos); $menu->addItem('Dashboard_Dashboard', $dashboard['name'], $this->urlForAction('embeddedIndex', array('idDashboard' => $dashboard['iddashboard'])), $pos);
$pos++; $pos++;
} }
} }
...@@ -44,13 +44,9 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -44,13 +44,9 @@ class Menu extends \Piwik\Plugin\Menu
$tooltip = Piwik::translate('Dashboard_TopLinkTooltip', Site::getNameFor($idSite)); $tooltip = Piwik::translate('Dashboard_TopLinkTooltip', Site::getNameFor($idSite));
$urlParams = array( $urlParams = $this->urlForModuleAction('CoreHome', 'index', array('idSite' => $idSite)) ;
'module' => 'CoreHome',
'action' => 'index',
'idSite' => $idSite,
);
$menu->add('Dashboard_Dashboard', null, $urlParams, true, 1, $tooltip); $menu->addItem('Dashboard_Dashboard', null, $urlParams, 1, $tooltip);
} }
} }
...@@ -20,13 +20,13 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -20,13 +20,13 @@ class Menu extends \Piwik\Plugin\Menu
{ {
if (Piwik::isUserHasSomeAdminAccess()) { if (Piwik::isUserHasSomeAdminAccess()) {
$menu->addDiagnosticItem('DevicesDetection_DeviceDetection', $menu->addDiagnosticItem('DevicesDetection_DeviceDetection',
array('module' => 'DevicesDetection', 'action' => 'deviceDetection'), $this->urlForAction('deviceDetection'),
$order = 40); $order = 40);
} }
} }
public function configureReportingMenu(MenuReporting $menu) public function configureReportingMenu(MenuReporting $menu)
{ {
$menu->addVisitorsItem('DevicesDetection_submenu', array('module' => 'DevicesDetection', 'action' => 'index')); $menu->addVisitorsItem('DevicesDetection_submenu', $this->urlForAction('index'));
} }
} }
...@@ -16,6 +16,6 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -16,6 +16,6 @@ class Menu extends \Piwik\Plugin\Menu
{ {
public function configureReportingMenu(MenuReporting $menu) public function configureReportingMenu(MenuReporting $menu)
{ {
$menu->addActionsItem('Events_Events', array('module' => 'Events', 'action' => 'index'), 30); $menu->addActionsItem('Events_Events', $this->urlForAction('index'), 30);
} }
} }
...@@ -22,34 +22,37 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -22,34 +22,37 @@ class Menu extends \Piwik\Plugin\Menu
{ {
public function configureReportingMenu(MenuReporting $menu) public function configureReportingMenu(MenuReporting $menu)
{ {
// with custom category 'UI Framework' // reuse an existing category
// $menu->add('UI Framework', '', array('module' => 'ExamplePlugin', 'action' => ''), true, $orderId = 30); // $menu->addVisitorsItem('Report 1', $this->urlForAction('report1'), $orderId = 30);
// $menu->add('UI Framework', 'Report 1', array('module' => 'ExamplePlugin', 'action' => 'report1'), true, $orderId = 30); // $menu->addActionsItem('Report 1', $this->urlForAction('report1'), $orderId = 30);
// or reusing an existing category
// $menu->addVisitorsItem('Report 1', array('module' => 'ExamplePlugin', 'action' => 'report1'), $orderId = 30); // or create a custom category 'UI Framework'
// $menu->addActionsItem('Report 1', array('module' => 'ExamplePlugin', 'action' => 'report1'), $orderId = 30); // $menu->addItem('UI Framework', '', $this->urlForDefaultAction(), $orderId = 30);
// $menu->addItem('UI Framework', 'Report 1', $this->urlForAction('report1'), $orderId = 30);
} }
public function configureAdminMenu(MenuAdmin $menu) public function configureAdminMenu(MenuAdmin $menu)
{ {
// with custom category // reuse an existing category
// $menu->add('General_Settings', 'My Admin Item', array('module' => 'ExamplePlugin', 'action' => ''), true, $orderId = 30); // $menu->addSettingsItem('My Admin Item', $this->urlForDefaultAction(), $orderId = 30);
// or reusing an existing category // $menu->addPlatformItem('My Admin Item', $this->urlForDefaultAction(), $orderId = 30);
// $menu->addSettingsItem('My Admin Item', array('module' => 'ExamplePlugin', 'action' => ''), $orderId = 30);
// $menu->addPlatformItem('My Admin Item', array('module' => 'ExamplePlugin', 'action' => ''), $orderId = 30); // or create a custom category
// $menu->addItem('General_Settings', 'My Admin Item', $this->urlForDefaultAction(), $orderId = 30);
} }
public function configureTopMenu(MenuTop $menu) public function configureTopMenu(MenuTop $menu)
{ {
// $menu->add('My Top Item', null, array('module' => 'ExamplePlugin', 'action' => ''), true, $orderId = 30); // $menu->addItem('My Top Item', null, $this->urlForDefaultAction(), $orderId = 30);
} }
public function configureUserMenu(MenuUser $menu) public function configureUserMenu(MenuUser $menu)
{ {
// with custom category // reuse an existing category
// $menu->add('CoreAdminHome_MenuManage', 'My User Item', array('module' => 'ExamplePlugin', 'action' => ''), true, $orderId = 30); // $menu->addManageItem('My User Item', $this->urlForDefaultAction(), $orderId = 30);
// or reusing an existing category // $menu->addPlatformItem('My User Item', $this->urlForDefaultAction(), $orderId = 30);
// $menu->addManageItem('My User Item', array('module' => 'ExamplePlugin', 'action' => ''), $orderId = 30);
// $menu->addPlatformItem('My User Item', array('module' => 'ExamplePlugin', 'action' => ''), $orderId = 30); // or create a custom category
// $menu->addItem('CoreAdminHome_MenuManage', 'My User Item', $this->urlForDefaultAction(), $orderId = 30);
} }
} }
...@@ -18,7 +18,7 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -18,7 +18,7 @@ class Menu extends \Piwik\Plugin\Menu
{ {
public function configureReportingMenu(MenuReporting $menu) public function configureReportingMenu(MenuReporting $menu)
{ {
$menu->add('UI Framework', '', array('module' => 'ExampleUI', 'action' => 'dataTables'), true, 30); $menu->addItem('UI Framework', '', array('module' => 'ExampleUI', 'action' => 'dataTables'), 30);
$this->addSubMenu($menu, 'Data tables', 'dataTables', 1); $this->addSubMenu($menu, 'Data tables', 'dataTables', 1);
$this->addSubMenu($menu, 'Bar graph', 'barGraph', 2); $this->addSubMenu($menu, 'Bar graph', 'barGraph', 2);
...@@ -34,12 +34,11 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -34,12 +34,11 @@ class Menu extends \Piwik\Plugin\Menu
public function configureUserMenu(MenuUser $menu) public function configureUserMenu(MenuUser $menu)
{ {
$urlParams = array('module' => 'ExampleUI', 'action' => 'notifications'); $menu->addPlatformItem('UI Notifications', $this->urlForAction('notifications'), $order = 3);
$menu->addPlatformItem('UI Notifications', $urlParams, $order = 3);
} }
private function addSubMenu(MenuReporting $menu, $subMenu, $action, $order) private function addSubMenu(MenuReporting $menu, $subMenu, $action, $order)
{ {
$menu->add('UI Framework', $subMenu, array('module' => 'ExampleUI', 'action' => $action), true, $order); $menu->addItem('UI Framework', $subMenu, $this->urlForAction($action), $order);
} }
} }
...@@ -15,11 +15,10 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -15,11 +15,10 @@ class Menu extends \Piwik\Plugin\Menu
{ {
public function configureUserMenu(MenuUser $menu) public function configureUserMenu(MenuUser $menu)
{ {
$menu->add( $menu->addItem(
'General_Help', 'General_Help',
null, null,
array('module' => 'Feedback', 'action' => 'index', 'segment' => false), $this->urlForAction('index', array('segment' => false)),
true,
$order = 99, $order = 99,
$tooltip = Piwik::translate('Feedback_TopLinkTooltip') $tooltip = Piwik::translate('Feedback_TopLinkTooltip')
); );
......
...@@ -29,41 +29,40 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -29,41 +29,40 @@ class Menu extends \Piwik\Plugin\Menu
$site = new Site($idSite); $site = new Site($idSite);
if (count($goals) == 0) { if (count($goals) == 0) {
$action = $site->isEcommerceEnabled() ? 'ecommerceReport' : 'addNewGoal';
$url = $this->urlForAction($action, array(
'idGoal' => ($site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null
)));
$menu->add($mainGoalMenu, '', array('module' => 'Goals', $menu->addItem($mainGoalMenu, '', $url, 25);
'action' => ($site->isEcommerceEnabled() ? 'ecommerceReport' : 'addNewGoal'),
'idGoal' => ($site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null)),
true,
25);
if ($site->isEcommerceEnabled()) { if ($site->isEcommerceEnabled()) {
$menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1); $menu->addItem($mainGoalMenu, 'Goals_Ecommerce', $this->urlForAction('ecommerceReport', array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER)), 1);
} }
$menu->add($mainGoalMenu, 'Goals_AddNewGoal', array('module' => 'Goals', 'action' => 'addNewGoal')); $menu->addItem($mainGoalMenu, 'Goals_AddNewGoal', $this->urlForAction('addNewGoal'));
} else { } else {
$menu->add($mainGoalMenu, '', array('module' => 'Goals', $action = $site->isEcommerceEnabled() ? 'ecommerceReport' : 'index';
'action' => ($site->isEcommerceEnabled() ? 'ecommerceReport' : 'index'), $url = $this->urlForAction($action, array('idGoal' => ($site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null)));
'idGoal' => ($site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null)),
true, $menu->addItem($mainGoalMenu, '', $url, 25);
25);
if ($site->isEcommerceEnabled()) { if ($site->isEcommerceEnabled()) {
$menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1); $menu->addItem($mainGoalMenu, 'Goals_Ecommerce', $this->urlForAction('ecommerceReport', array('idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER)), 1);
} }
$menu->add($mainGoalMenu, 'Goals_GoalsOverview', array('module' => 'Goals', 'action' => 'index'), true, 2); $menu->addItem($mainGoalMenu, 'Goals_GoalsOverview', array('module' => 'Goals', 'action' => 'index'), 2);
$group = new Group(); $group = new Group();
foreach ($goals as $goal) { foreach ($goals as $goal) {
$subMenuName = str_replace('%', '%%', Translate::clean($goal['name'])); $subMenuName = str_replace('%', '%%', Translate::clean($goal['name']));
$params = array('module' => 'Goals', 'action' => 'goalReport', 'idGoal' => $goal['idgoal']); $params = $this->urlForAction('goalReport', array('idGoal' => $goal['idgoal']));
$tooltip = sprintf('%s (id = %d)', $subMenuName, $goal['idgoal']); $tooltip = sprintf('%s (id = %d)', $subMenuName, $goal['idgoal']);
if (count($goals) <= 3) { if (count($goals) <= 3) {
$menu->add($mainGoalMenu, $subMenuName, $params, true, 50, $tooltip); $menu->addItem($mainGoalMenu, $subMenuName, $params, 50, $tooltip);
} else { } else {
$group->add($subMenuName, $params, $tooltip); $group->add($subMenuName, $params, $tooltip);
} }
......
...@@ -17,7 +17,7 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -17,7 +17,7 @@ class Menu extends \Piwik\Plugin\Menu
{ {
if (Piwik::hasUserSuperUserAccess()) { if (Piwik::hasUserSuperUserAccess()) {
$menu->addSettingsItem('Installation_SystemCheck', $menu->addSettingsItem('Installation_SystemCheck',
array('module' => 'Installation', 'action' => 'systemCheckPage'), $this->urlForAction('systemCheckPage'),
$order = 15); $order = 15);
} }
} }
......
...@@ -28,7 +28,7 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -28,7 +28,7 @@ class Menu extends \Piwik\Plugin\Menu
{ {
if (Development::isEnabled() && Piwik::isUserHasSomeAdminAccess()) { if (Development::isEnabled() && Piwik::isUserHasSomeAdminAccess()) {
$menu->addDevelopmentItem('LanguagesManager_TranslationSearch', $menu->addDevelopmentItem('LanguagesManager_TranslationSearch',
array('module' => 'LanguagesManager', 'action' => 'searchTranslation')); $this->urlForAction('searchTranslation'));
} }
} }
} }
...@@ -14,10 +14,6 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -14,10 +14,6 @@ class Menu extends \Piwik\Plugin\Menu
{ {
public function configureAdminMenu(MenuAdmin $menu) public function configureAdminMenu(MenuAdmin $menu)
{ {
$menu->addSettingsItem( $menu->addSettingsItem('MobileMessaging_SettingsMenu', $this->urlForAction('index'), $order = 12);
'MobileMessaging_SettingsMenu',
array('module' => 'MobileMessaging', 'action' => 'index'),
$order = 12
);
} }
} }
...@@ -15,7 +15,7 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -15,7 +15,7 @@ class Menu extends \Piwik\Plugin\Menu
{ {
public function configureTopMenu(MenuTop $menu) public function configureTopMenu(MenuTop $menu)
{ {
$urlParams = array('module' => 'MultiSites', 'action' => 'index', 'segment' => false); $urlParams = $this->urlForAction('index', array('segment' => false));
$tooltip = Piwik::translate('MultiSites_TopLinkTooltip'); $tooltip = Piwik::translate('MultiSites_TopLinkTooltip');
$menu->add('General_MultiSitesSummary', null, $urlParams, true, 3, $tooltip); $menu->add('General_MultiSitesSummary', null, $urlParams, true, 3, $tooltip);
......
...@@ -17,7 +17,7 @@ class Menu extends \Piwik\Plugin\Menu ...@@ -17,7 +17,7 @@ class Menu extends \Piwik\Plugin\Menu
{ {
if (Piwik::isUserHasSomeAdminAccess()) { if (Piwik::isUserHasSomeAdminAccess()) {
$menu->addSettingsItem('PrivacyManager_MenuPrivacySettings', $menu->addSettingsItem('PrivacyManager_MenuPrivacySettings',
array('module' => 'PrivacyManager', 'action' => 'privacySettings'), $this->urlForAction('privacySettings'),
$order = 7); $order = 7);
} }
} }
......
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter