/** * Get asset data (used in template) * @param array $thumbOptions * @return array * * The associative array data returned has the keys: * categoryName => Human readable title, e.g. "Soul Bubbles Nintendo DS" * displayTitle => Preferred title entered via Admin tool, e.g. "Soul Bubbles on Nintendo DS" * thumbnails => An array of video thumbnail data of the format: * [ title => $title, * thumb => $thumb, * url => $url, * ] * updatedBy => Name of the user who updated this asset last * updatedAt => Date this asset was last updated, e.g. "17:04, September 13, 2013" */ public function getAssetData($thumbOptions = array()) { $title = Title::newFromText($this->categoryName, NS_CATEGORY); if (empty($title)) { return self::getDefaultAssetData(); } // Allow defaults to be overridden by options passed into us $thumbOptions = array_merge($this->defaultThumbOptions, $thumbOptions); $helper = new VideoPageToolHelper(); $data = array('categoryName' => $title->getText(), 'displayTitle' => $this->displayTitle, 'thumbnails' => $helper->getVideosByCategory($title, $thumbOptions), 'total' => $helper->getVideosByCategoryCount($title), 'url' => $title->escapeLocalURL(), 'seeMoreLabel' => wfMessage('videopagetool-see-more-label')->plain()); $assetData = array_merge($data, parent::getAssetData($thumbOptions)); return $assetData; }
/** * Get videos by category * @requestParam string categoryName * @responseParam string $result [ok/error] * @responseParam string $msg - result message * @responseParam array thumbnails - the list of videos in the category * @responseParam integer total - the number of videos in the category * @responseParam string url - the url of the category page * @responseParam string seeMoreLabel */ public function getVideosByCategory() { $categoryName = $this->getVal('categoryName', ''); if (empty($categoryName)) { $this->result = 'error'; $this->msg = wfMessage('videopagetool-error-invalid-category')->plain(); return; } $title = Title::newFromText($categoryName, NS_CATEGORY); if (empty($title)) { $this->result = 'error'; $this->msg = wfMessage('videopagetool-error-unknown-category')->plain(); return; } $helper = new VideoPageToolHelper(); $this->result = 'ok'; $this->msg = ''; $this->thumbnails = $helper->getVideosByCategory($title); $this->total = $helper->getVideosByCategoryCount($title); $this->url = $title->escapeLocalURL(); $this->seeMoreLabel = wfMessage('videopagetool-see-more-label')->plain(); }