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
......@@ -14,9 +14,9 @@ class Menu extends \Piwik\Plugin\Menu
{
public function configureReportingMenu(MenuReporting $menu)
{
$menu->addReferrersItem('', array('module' => 'Referrers', 'action' => 'index'), 20);
$menu->addReferrersItem('General_Overview', array('module' => 'Referrers', 'action' => 'index'), 1);
$menu->addReferrersItem('Referrers_SubmenuSearchEngines', array('module' => 'Referrers', 'action' => 'getSearchEnginesAndKeywords'), 2);
$menu->addReferrersItem('Referrers_SubmenuWebsites', array('module' => 'Referrers', 'action' => 'indexWebsites'), 3);
$menu->addReferrersItem('', $this->urlForAction('index'), 20);
$menu->addReferrersItem('General_Overview', $this->urlForAction('index'), 1);
$menu->addReferrersItem('Referrers_SubmenuSearchEngines', $this->urlForAction('getSearchEnginesAndKeywords'), 2);
$menu->addReferrersItem('Referrers_SubmenuWebsites', $this->urlForAction('indexWebsites'), 3);
}
}
......@@ -24,10 +24,10 @@ class Menu extends \Piwik\Plugin\Menu
\Piwik\Plugin\Manager::getInstance()->isPluginActivated('MobileMessaging')
? 'MobileMessaging_TopLinkTooltip' : 'ScheduledReports_TopLinkTooltip');
$menu->addManageItem(null, array('module' => '', 'action' => '', 'segment' => false), 10);
$menu->addManageItem(null, $this->urlForDefaultAction(array('segment' => false)), 10);
$menu->addManageItem(
$this->getTopMenuTranslationKey(),
array('module' => 'ScheduledReports', 'action' => 'index', 'segment' => false),
$this->urlForAction('index', array('segment' => false)),
13,
$tooltip
);
......
......@@ -17,7 +17,7 @@ class Menu extends \Piwik\Plugin\Menu
{
if (Piwik::isUserHasSomeAdminAccess()) {
$menu->addManageItem('SitesManager_Sites',
array('module' => 'SitesManager', 'action' => 'index'),
$this->urlForAction('index'),
$order = 1);
}
}
......
......@@ -18,13 +18,13 @@ class Menu extends \Piwik\Plugin\Menu
{
if (UserCountry::isGeoLocationAdminEnabled() && Piwik::hasUserSuperUserAccess()) {
$menu->addSettingsItem('UserCountry_Geolocation',
array('module' => 'UserCountry', 'action' => 'adminIndex'),
$this->urlForAction('adminIndex'),
$order = 8);
}
}
public function configureReportingMenu(MenuReporting $menu)
{
$menu->addVisitorsItem('UserCountry_SubmenuLocations', array('module' => 'UserCountry', 'action' => 'index'));
$menu->addVisitorsItem('UserCountry_SubmenuLocations', $this->urlForAction('index'));
}
}
......@@ -17,7 +17,7 @@ class Menu extends \Piwik\Plugin\Menu
{
if (PluginManager::getInstance()->isPluginActivated('UserCountry')) {
$menu->addVisitorsItem('UserCountryMap_RealTimeMap',
array('module' => 'UserCountryMap', 'action' => 'realtimeWorldMap'),
$this->urlForAction('realtimeWorldMap'),
$order = 70);
}
}
......
......@@ -14,6 +14,6 @@ class Menu extends \Piwik\Plugin\Menu
{
public function configureReportingMenu(MenuReporting $menu)
{
$menu->addVisitorsItem('General_Settings', array('module' => 'UserSettings', 'action' => 'index'));
$menu->addVisitorsItem('General_Settings', $this->urlForAction('index'));
}
}
......@@ -16,12 +16,8 @@ class Menu extends \Piwik\Plugin\Menu
public function configureAdminMenu(MenuAdmin $menu)
{
if (Piwik::isUserHasSomeAdminAccess()) {
$menu->addManageItem('UsersManager_MenuUsers',
array('module' => 'UsersManager', 'action' => 'index'),
$order = 2);
$menu->addManageItem('UsersManager_MenuUserSettings',
array('module' => 'UsersManager', 'action' => 'userSettings'),
$order = 3);
$menu->addManageItem('UsersManager_MenuUsers', $this->urlForAction('index'), $order = 2);
$menu->addManageItem('UsersManager_MenuUserSettings', $this->urlForAction('userSettings'), $order = 3);
}
}
}
......@@ -14,7 +14,6 @@ class Menu extends \Piwik\Plugin\Menu
{
public function configureReportingMenu(MenuReporting $menu)
{
$menu->addVisitorsItem('VisitFrequency_SubmenuFrequency',
array('module' => 'VisitFrequency', 'action' => 'index'), $order = 55);
$menu->addVisitorsItem('VisitFrequency_SubmenuFrequency', $this->urlForAction('index'), $order = 55);
}
}
......@@ -14,7 +14,6 @@ class Menu extends \Piwik\Plugin\Menu
{
public function configureReportingMenu(MenuReporting $menu)
{
$menu->addVisitorsItem('VisitTime_SubmenuTimes',
array('module' => 'VisitTime', 'action' => 'index'), $order = 65);
$menu->addVisitorsItem('VisitTime_SubmenuTimes', $this->urlForAction('index'), $order = 65);
}
}
......@@ -16,7 +16,7 @@ class Menu extends \Piwik\Plugin\Menu
public function configureUserMenu(MenuUser $menu)
{
$tooltip = Piwik::translate('Widgetize_TopLinkTooltip');
$urlParams = array('module' => 'Widgetize', 'action' => 'index', 'segment' => false);
$urlParams = $this->urlForAction('index', array('segment' => false));
$menu->addPlatformItem(null, $urlParams, 50, $tooltip);
$menu->addPlatformItem('General_Widgets', $urlParams, 5, $tooltip);
......
......@@ -29,6 +29,8 @@ class DeprecatedMethodsTest extends PHPUnit_Framework_TestCase
$validTill = '2014-10-15';
$this->assertDeprecatedMethodIsRemoved('\Piwik\SettingsPiwik', 'rewriteTmpPathWithHostname', $validTill);
$this->assertDeprecatedMethodIsRemovedInPiwik3('\Piwik\Menu\MenuAbstract', 'add');
}
private function assertDeprecatedMethodIsRemoved($className, $method, $removalDate)
......@@ -49,4 +51,22 @@ class DeprecatedMethodsTest extends PHPUnit_Framework_TestCase
$errorMessage = $className . '::' . $method . ' should be removed as the method is deprecated but it is not.';
$this->assertFalse($methodExists, $errorMessage);
}
private function assertDeprecatedMethodIsRemovedInPiwik3($className, $method)
{
$version = \Piwik\Version::VERSION;
$class = new ReflectionClass($className);
$methodExists = $class->hasMethod($method);
if (-1 === version_compare($version, '3.0.0')) {
$errorMessage = $className . '::' . $method . ' should still exists until 3.0 although it is deprecated.';
$this->assertTrue($methodExists, $errorMessage);
return;
}
$errorMessage = $className . '::' . $method . ' should be removed as the method is deprecated but it is not.';
$this->assertFalse($methodExists, $errorMessage);
}
}
\ No newline at end of file
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