public function configureReportingMenu(MenuReporting $menu) { $idSite = $this->getIdSite(); $goals = API::getInstance()->getGoals($idSite); $mainGoalMenu = 'Goals_Goals'; if (count($goals) == 0) { $linkToAddNewGoal = $this->urlForAction('addNewGoal', array('idGoal' => null)); $menu->addItem($mainGoalMenu, '', $linkToAddNewGoal, 25); $menu->addItem($mainGoalMenu, 'Goals_AddNewGoal', $linkToAddNewGoal, 1); return; } $order = 1; $url = $this->urlForAction('index', array('idGoal' => null)); $menu->addItem($mainGoalMenu, '', $url, 25); $menu->addItem($mainGoalMenu, 'General_Overview', $url, ++$order); $group = new Group(); foreach ($goals as $goal) { $subMenuName = str_replace('%', '%%', Translate::clean($goal['name'])); $params = $this->urlForAction('goalReport', array('idGoal' => $goal['idgoal'])); $tooltip = sprintf('%s (id = %d)', $subMenuName, $goal['idgoal']); if (count($goals) > 3) { $group->add($subMenuName, $params, $tooltip); } else { $menu->addItem($mainGoalMenu, $subMenuName, $params, ++$order, $tooltip); } } if (count($goals) > 3) { $menu->addGroup($mainGoalMenu, 'Goals_ChooseGoal', $group, ++$order, $tooltip = false); } $menu->addItem($mainGoalMenu, 'Goals_ManageGoals', $this->urlForAction('editGoals'), ++$order); }
public function configureReportingMenu(MenuReporting $menu) { $idSite = Common::getRequestVar('idSite', null, 'int'); $goals = API::getInstance()->getGoals($idSite); $mainGoalMenu = $this->getGoalCategoryName($idSite); $site = new Site($idSite); if (count($goals) == 0) { $menu->add($mainGoalMenu, '', array('module' => 'Goals', 'action' => $site->isEcommerceEnabled() ? 'ecommerceReport' : 'addNewGoal', 'idGoal' => $site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null), true, 25); if ($site->isEcommerceEnabled()) { $menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1); } $menu->add($mainGoalMenu, 'Goals_AddNewGoal', array('module' => 'Goals', 'action' => 'addNewGoal')); } else { $menu->add($mainGoalMenu, '', array('module' => 'Goals', 'action' => $site->isEcommerceEnabled() ? 'ecommerceReport' : 'index', 'idGoal' => $site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null), true, 25); if ($site->isEcommerceEnabled()) { $menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1); } $menu->add($mainGoalMenu, 'Goals_GoalsOverview', array('module' => 'Goals', 'action' => 'index'), true, 2); $group = new Group(); foreach ($goals as $goal) { $subMenuName = str_replace('%', '%%', Translate::clean($goal['name'])); $params = array('module' => 'Goals', 'action' => 'goalReport', 'idGoal' => $goal['idgoal']); $tooltip = sprintf('%s (id = %d)', $subMenuName, $goal['idgoal']); if (count($goals) <= 3) { $menu->add($mainGoalMenu, $subMenuName, $params, true, 50, $tooltip); } else { $group->add($subMenuName, $params, $tooltip); } } if (count($goals) > 3) { $menu->addGroup($mainGoalMenu, 'Goals_ChooseGoal', $group, $orderId = 50, $tooltip = false); } } }
/** * Decodes all encoded entities in the given translations * * @param array $translations * * @return array filtered translations */ public function filter($translations) { foreach ($translations as $pluginName => $pluginTranslations) { foreach ($pluginTranslations as $key => $translation) { // remove encoded entities $decoded = Translate::clean($translation); if ($translation != $decoded) { $this->filteredData[$pluginName][$key] = $translation; $translations[$pluginName][$key] = $decoded; continue; } } } return $translations; }
public function configureReportingMenu(MenuReporting $menu) { $idSite = Common::getRequestVar('idSite', null, 'int'); $goals = API::getInstance()->getGoals($idSite); $mainGoalMenu = $this->getGoalCategoryName($idSite); $site = new Site($idSite); if (count($goals) == 0) { $menu->add($mainGoalMenu, '', array('module' => 'Goals', 'action' => $site->isEcommerceEnabled() ? 'ecommerceReport' : 'addNewGoal', 'idGoal' => $site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null), true, 25); if ($site->isEcommerceEnabled()) { $menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1); } $menu->add($mainGoalMenu, 'Goals_AddNewGoal', array('module' => 'Goals', 'action' => 'addNewGoal')); } else { $menu->add($mainGoalMenu, '', array('module' => 'Goals', 'action' => $site->isEcommerceEnabled() ? 'ecommerceReport' : 'index', 'idGoal' => $site->isEcommerceEnabled() ? Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER : null), true, 25); if ($site->isEcommerceEnabled()) { $menu->add($mainGoalMenu, 'Goals_Ecommerce', array('module' => 'Goals', 'action' => 'ecommerceReport', 'idGoal' => Piwik::LABEL_ID_GOAL_IS_ECOMMERCE_ORDER), true, 1); } $menu->add($mainGoalMenu, 'Goals_GoalsOverview', array('module' => 'Goals', 'action' => 'index'), true, 2); foreach ($goals as $goal) { $menu->add($mainGoalMenu, str_replace('%', '%%', Translate::clean($goal['name'])), array('module' => 'Goals', 'action' => 'goalReport', 'idGoal' => $goal['idgoal'])); } } }
/** * @group Core * @dataProvider getCleanTestData */ public function testClean($data, $expected) { $this->assertEquals($expected, Translate::clean($data)); }