/** * Get asset data (used in template) * @param array $thumbOptions An optional array of options to pass to the thumbnailer * @return array An associative array of video metadata for the video named by $this->title * * The associative array data returned has the keys: * videoTitle => Human readable title, e.g. "Soul Bubbles Nintendo DS Trailer - Bubbles" * videoKey => DBKey of the title, e.g. "Soul_Bubbles_Nintendo_DS_Trailer_-_Bubbles" * displayTitle => Preferred title entered via Admin tool, e.g. "Bubbles from "Soul Bubbles" on Nintendo DS" * videoThumb => Embed code for the video thumbnail. * largeThumbUrl => Large version of the video thumbnail image. Does not include the embed code. * altThumbName => Human readable title of the thumbnail that will replace original thumbnail * altThumbKey => DBKey of the thumbnail that will replace original thumbnail * description => Description of this video given in the Admin tool, e.g. "All about Bubbles!" * videoTitleClass => * altThumbClass => * updatedBy => User who updated this asset last, e.g. "Garthwebb" * updatedAt => Date this asset was last updated, e.g. "17:04, September 13, 2013" */ public function getAssetData($thumbOptions = array()) { // Allow defaults to be overridden by options passed into us $thumbOptions = array_merge($this::$defaultThumbOptions, $thumbOptions); $helper = new VideoPageToolHelper(); $data = $helper->getVideoData($this->title, $this->altThumbTitle, $this->displayTitle, $this->description, $thumbOptions); if (empty($data)) { return self::getDefaultAssetData(); } // This needs to be set to an empty string when there is a real asset rather than default asset data $data['videoTitleClass'] = ''; $data['altThumbClass'] = ''; $assetData = array_merge($data, parent::getAssetData()); return $assetData; }
/** * Get video data for a featured video * @requestParam string url * @requestParam string altThumbKey * @responseParam string result [ok/error] * @responseParam string msg - result message * @responseParam array video */ public function getFeaturedVideoData() { $errMsg = ''; if (!$this->validateUser($errMsg)) { $this->result = 'error'; $this->msg = $errMsg; return; } $url = $this->getVal('url', ''); $altThumbTitle = $this->getVal('altThumbKey', ''); $video = array(); if (empty($url)) { $this->result = 'error'; $this->msg = wfMessage('videos-error-invalid-video-url')->plain(); return; } $url = urldecode($url); if (preg_match('/.+\\/wiki\\/File:(.+)$/i', $url, $matches)) { // Use the default thumb options from Featured Assets since that's the only type of // asset this controller returns. $thumbOptions = VideoPageToolAssetFeatured::$defaultThumbOptions; $thumbOptions['noLightbox'] = false; $helper = new VideoPageToolHelper(); $video = $helper->getVideoData($matches[1], $altThumbTitle, null, null, $thumbOptions); } if (empty($video)) { $this->result = 'error'; $this->msg = wfMessage('videohandler-non-premium')->plain(); $this->video = $video; } else { $this->result = 'ok'; $this->msg = ''; $this->video = $video; } }