public function getExhibitionItems(Title $title) { wfProfileIn(__METHOD__); if (class_exists('CategoryDataService')) { $cacheKey = $this->getExhibitionItemsCacheKey($title->getText()); $items = $this->wg->memc->get($cacheKey); if (!is_array($items)) { $exh = CategoryDataService::getMostVisited($title->getDBkey(), null, self::EXHIBITION_ITEMS_LIMIT); $ids = array_keys($exh); $length = count($ids); $items = array(); for ($i = 0; $i < $length; $i++) { $pageId = $ids[$i]; $imgRespnse = $this->app->sendRequest('ImageServing', 'index', array('ids' => array($pageId), 'height' => 150, 'width' => 150, 'count' => 1)); $img = $imgRespnse->getVal('result'); if (!empty($img[$pageId])) { $img = $img[$pageId][0]['url']; } else { $img = false; } $oTitle = Title::newFromID($pageId); $items[] = ['img' => $img, 'title' => $oTitle->getText(), 'url' => $oTitle->getFullURL()]; } $this->wg->memc->set($cacheKey, $items, self::CACHE_TTL_EXHIBITION); } wfProfileOut(__METHOD__); return $items; } wfProfileOut(__METHOD__); return false; }
/** * fetchSectionItems - returns gets array of items from category from specyfic namespace. * @param $sCategoryDBKey int category namespace * @param $mNamespace mixed: int namespace or array of int for category query * @return array */ protected function fetchSectionItems($mNamespace = NS_MAIN, $negative = false) { $sCategoryDBKey = $this->categoryTitle->getDBkey(); // Check if page is a redirect if ($this->categoryTitle->isRedirect()) { $oTmpArticle = new Article($this->categoryTitle); if (!is_null($oTmpArticle)) { $rdTitle = $oTmpArticle->getRedirectTarget(); if (!is_null($rdTitle) && $rdTitle->getNamespace() == NS_CATEGORY) { $sCategoryDBKey = $rdTitle->getDBkey(); } } } if (!is_array($mNamespace)) { $mNamespace = (int) $mNamespace; } else { $mNamespace = implode(',', $mNamespace); } switch ($this->getSortType()) { case 'mostvisited': $res = CategoryDataService::getMostVisited($sCategoryDBKey, $mNamespace, false, $negative); //FB#26239 - fall back to alphabetical order if most visited data is empty return !empty($res) ? $res : CategoryDataService::getAlphabetical($sCategoryDBKey, $mNamespace, $negative); case 'alphabetical': return CategoryDataService::getAlphabetical($sCategoryDBKey, $mNamespace, $negative); case 'recentedits': return CategoryDataService::getRecentlyEdited($sCategoryDBKey, $mNamespace, $negative); } return array(); }