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); }
/** * 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); }