Ejemplo n.º 1
0
 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);
         }
     }
 }
Ejemplo n.º 2
0
 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);
 }
Ejemplo n.º 3
0
 private function addMenuItemsForCustomDimensions(MenuReporting $menu, $dimensions, $scope)
 {
     $numItems = 0;
     foreach ($dimensions as $dimension) {
         if ($scope === $dimension['scope']) {
             $numItems++;
         }
     }
     $group = new Group();
     $mainMenuName = '';
     if ($scope === CustomDimensions::SCOPE_VISIT) {
         $mainMenuName = 'General_Visitors';
     } elseif ($scope === CustomDimensions::SCOPE_ACTION) {
         $mainMenuName = 'General_Actions';
     }
     foreach ($dimensions as $dimension) {
         if ($dimension['scope'] !== $scope) {
             continue;
         }
         $name = $dimension['name'];
         $id = $dimension['idcustomdimension'];
         $url = $this->urlForAction('menuGetCustomDimension', array('idDimension' => $id));
         $order = 100 + $id;
         $tooltip = Piwik::translate('CustomDimensions_CustomDimensionId', $id);
         if ($scope === CustomDimensions::SCOPE_VISIT) {
             if ($numItems > 3) {
                 $group->add($name, $url, $tooltip);
             } else {
                 $menu->addVisitorsItem($name, $url, $order, $tooltip);
             }
         } elseif ($scope === CustomDimensions::SCOPE_ACTION) {
             if ($numItems > 3) {
                 $group->add($name, $url, $tooltip);
             } else {
                 $menu->addActionsItem($name, $url, $order, $tooltip);
             }
         }
         if ($numItems > 3) {
             $title = Piwik::translate('CustomDimensions_CustomDimensions');
             $menu->addGroup($mainMenuName, $title, $group, ++$order, $tooltip = false);
         }
     }
 }