private function buildMimeTypesBlacklist() { if (self::$mimeTypesBlacklist === null) { wfProfileIn(__METHOD__); $app = F::app(); // blacklist types that thumbnailer cannot generate thumbs for (BAC-770) $mimeTypesBlacklist = ['svg+xml', 'svg']; if ($app->wg->UseMimeMagicLite) { // MimeMagicLite defines all the mMediaTypes in PHP that MimeMagic // defines in text files $mimeTypes = new MimeMagicLite(); } else { $mimeTypes = new MimeMagic(); } foreach (['AUDIO', 'VIDEO'] as $type) { foreach ($mimeTypes->mMediaTypes[$type] as $mime) { // parse mime type - "image/svg" -> "svg" list(, $mimeMinor) = explode('/', $mime); $mimeTypesBlacklist[] = $mimeMinor; } } self::$mimeTypesBlacklist = array_unique($mimeTypesBlacklist); wfDebug(sprintf("%s: minor MIME types blacklist - %s\n", __CLASS__, join(', ', self::$mimeTypesBlacklist))); wfProfileOut(__METHOD__); } }
function formatResult($imageList, $dbOut, $limit) { $out = parent::formatResult($imageList, $dbOut, $limit); foreach ($this->getArticlesList() as $key => $value) { $user = explode('/', $value['title']); if (!empty($out[$key])) { $out[$key] = array($this->getData($user[0])) + array_slice($out[$key], 0, $limit - 1); } else { $out[$key] = array($this->getData($user[0])); } } return $out; }
function formatResult($allImages, $filteredImages) { $out = parent::formatResult($allImages, $filteredImages); foreach ($this->getArticles() as $articleId => $articleData) { $titleParts = explode('/', $articleData['title']); $userName = $titleParts[0]; if (!empty($out[$articleId])) { $out[$articleId] = array($this->getAvatar($userName)) + array_slice($out[$articleId], 0, ImageServing::MAX_LIMIT - 1); } else { $out[$articleId] = array($this->getAvatar($userName)); } } return $out; }
protected function loadImagesFromDb($articleIds = array()) { parent::loadImagesFromDb($articleIds); $articleCategories = array(); foreach ($articleIds as $categoryId) { if ($this->getAllImagesCountForArticle($categoryId) < self::QUERY_LIMIT) { $this->addTopArticlesFromCategory($categoryId, $articleCategories); } } $imageIndex = $this->getImageIndex(array_keys($articleCategories), self::QUERY_LIMIT); $propNumber = 0; foreach ($imageIndex as $articleId => $articleImageIndex) { $propNumber++; foreach ($articleImageIndex as $key => $imageData) { foreach ($articleCategories[$articleId] as $categoryId) { $this->addImage($imageData, $categoryId, $propNumber * (2 * self::QUERY_LIMIT + $key), self::QUERY_LIMIT); } } } }
protected function getImagesFromDB($articles = array()) { parent::getImagesFromDB($articles); $toGetFromArticle = array(); foreach ($articles as $val) { if ($this->getImagesCountBeforeFiltr($val) < $this->queryLimit) { $this->getCategoryArticleList($val, $toGetFromArticle); } } $props = $this->getArticleProbs(array_keys($toGetFromArticle), $this->queryLimit); $propNumber = 0; foreach ($props as $article => $prop) { $count = 0; $propNumber++; foreach ($prop as $key => $image) { foreach ($toGetFromArticle[$article] as $cat) { $this->addImagesList($image, $cat, $propNumber * (2 * $this->queryLimit + $key), $this->queryLimit); } } } }
/** * getImages - get array with list of top images for all article passed into the constructor * * @author Tomek Odrobny * * @access public * * @param $n Integer[] number of images to get for each article * @param $driver ImageServingDriverBase allow to force driver * * @return File[] */ public function getImages($n = 5, $driver = null) { wfProfileIn(__METHOD__); $articles = $this->articles; $out = array(); if (!empty($articles)) { if ($this->db == null) { $db = wfGetDB(DB_SLAVE, array()); } else { $db = $this->db; } $this->articlesByNS = array(); foreach ($articles as $key => $value) { $mcValue = $this->memc->get($this->makeKey($key), null); if (!empty($mcValue)) { unset($articles[$key]); $this->addArticleToList($mcValue); } } $res = $db->select(array('page'), array('page_namespace as ns', 'page_title as title', 'page_id as id'), array('page_id' => $articles), __METHOD__); while ($row = $db->fetchRow($res)) { $this->addArticleToList($row); } if (empty($driver)) { foreach ($this->imageServingDrivers as $key => $value) { if (!empty($this->articlesByNS[$key])) { $driver = new $value($db, $this, $this->proportionString); $driver->setArticlesList($this->articlesByNS[$key]); unset($this->articlesByNS[$key]); $out = $out + $driver->execute($n); } } $driver = new ImageServingDriverMainNS($db, $this, $this->proportionString); //rest of article in MAIN name spaces foreach ($this->articlesByNS as $value) { $driver->setArticlesList($value); $out = $out + $driver->execute($n); } } else { $driver = new $driver($db, $this, $this->proportionString); //rest of article in MAIN name spaces foreach ($this->articlesByNS as $value) { $driver->setArticlesList($value); $out = $out + $driver->execute($n); } } if (empty($out)) { // Hook for finding fallback images if there were no matches. - NOTE: should this fallback any time (count($out) < $n)? Seems like overkill. wfRunHooks('ImageServing::fallbackOnNoResults', array(&$this, $n, &$out)); } } wfProfileOut(__METHOD__); return $out; }
public function loadImageDetails($imageNames = []) { parent::loadImageDetails($imageNames); }