This class is for now not exposed as public API until needed. Categories of plugins will be automatically displayed in the menu at the very right after all core categories.
コード例 #1
0
ファイル: CategoryList.php プロジェクト: piwik/piwik
 /**
  * @return CategoryList
  */
 public static function get()
 {
     $list = new CategoryList();
     $categories = StaticContainer::get('Piwik\\Plugin\\Categories');
     foreach ($categories->getAllCategories() as $category) {
         $list->addCategory($category);
     }
     // move subcategories into categories
     foreach ($categories->getAllSubcategories() as $subcategory) {
         $categoryId = $subcategory->getCategoryId();
         if (!$categoryId) {
             continue;
         }
         if ($list->hasCategory($categoryId)) {
             $category = $list->getCategory($categoryId);
         } else {
             $category = new Category();
             $category->setId($categoryId);
             $list->addCategory($category);
         }
         $category->addSubcategory($subcategory);
     }
     return $list;
 }
コード例 #2
0
ファイル: ReportsProvider.php プロジェクト: piwik/piwik
 public function compareCategories($catIdA, $subcatIdA, $orderA, $catIdB, $subcatIdB, $orderB)
 {
     if (!isset($this->categoryList)) {
         $this->categoryList = CategoryList::get();
     }
     $catA = $this->categoryList->getCategory($catIdA);
     $catB = $this->categoryList->getCategory($catIdB);
     // in case there is a category class for both reports
     if (isset($catA) && isset($catB)) {
         if ($catA->getOrder() == $catB->getOrder()) {
             // same category order, compare subcategory order
             $subcatA = $catA->getSubcategory($subcatIdA);
             $subcatB = $catB->getSubcategory($subcatIdB);
             // both reports have a subcategory with custom subcategory class
             if ($subcatA && $subcatB) {
                 if ($subcatA->getOrder() == $subcatB->getOrder()) {
                     // same subcategory order, compare order of report
                     if ($orderA == $orderB) {
                         return 0;
                     }
                     return $orderA < $orderB ? -1 : 1;
                 }
                 return $subcatA->getOrder() < $subcatB->getOrder() ? -1 : 1;
             } elseif ($subcatA) {
                 return 1;
             } elseif ($subcatB) {
                 return -1;
             }
             if ($orderA == $orderB) {
                 return 0;
             }
             return $orderA < $orderB ? -1 : 1;
         }
         return $catA->getOrder() < $catB->getOrder() ? -1 : 1;
     } elseif (isset($catA)) {
         return -1;
     } elseif (isset($catB)) {
         return 1;
     }
     if ($catIdA === $catIdB) {
         // both have same category, compare order
         if ($orderA == $orderB) {
             return 0;
         }
         return $orderA < $orderB ? -1 : 1;
     }
     return strnatcasecmp($catIdA, $catIdB);
 }
コード例 #3
0
ファイル: API.php プロジェクト: piwik/piwik
 /**
  * Get a list of all widgetizable widgets.
  *
  * @param int $idSite
  * @return array
  */
 public function getWidgetMetadata($idSite)
 {
     Piwik::checkUserHasViewAccess($idSite);
     $widgetsList = WidgetsList::get();
     $categoryList = CategoryList::get();
     $metadata = new WidgetMetadata();
     return $metadata->getWidgetMetadata($categoryList, $widgetsList);
 }
コード例 #4
0
ファイル: WidgetMetadata.php プロジェクト: piwik/piwik
 /**
  * @param CategoryList $categoryList
  * @param WidgetsList $widgetsList
  * @return array
  */
 private function buildPagesMetadata(CategoryList $categoryList, WidgetsList $widgetsList)
 {
     $pages = array();
     $widgets = array();
     foreach ($widgetsList->getWidgetConfigs() as $config) {
         $pageId = $this->buildPageId($config->getCategoryId(), $config->getSubcategoryId());
         if (!isset($widgets[$pageId])) {
             $widgets[$pageId] = array();
         }
         $widgets[$pageId][] = $config;
     }
     foreach ($categoryList->getCategories() as $category) {
         foreach ($category->getSubcategories() as $subcategory) {
             $pageId = $this->buildPageId($category->getId(), $subcategory->getId());
             if (!empty($widgets[$pageId])) {
                 $pages[] = $this->buildPageMetadata($category, $subcategory, $widgets[$pageId]);
             }
         }
     }
     return $pages;
 }