/** * Add a default video description if one doesn't already exist * * @param $file - The file object for the video * @return bool - Returns true if successful, false otherwise */ public function addDefaultVideoDescription(File $file) { wfProfileIn(__METHOD__); $title = $file->getTitle(); // Get the file page for this file $page = WikiPage::factory($title); // Get the description and strip the H2 header $text = $this->stripDescriptionHeader($page->getText()); // Strip out the category tags that might be part of the content $text = FilePageHelper::stripCategoriesFromDescription($text); // If there is no description, pull the description from metadata, // otherwise do nothing if (trim($text) == '') { $text = $file->getMetaDescription(); wfProfileOut(__METHOD__); return $this->setVideoDescription($title, $text); } else { wfProfileOut(__METHOD__); return true; } }
/** * If there's no description text, render the default message */ protected function renderDefaultDescription() { wfProfileIn(__METHOD__); $app = F::App(); $out = $this->getContext()->getOutput(); $isContentEmpty = false; // Display description text or default message, except when we're showing a diff (we want the diff to only // show actual content, not template injected stuff) if (!$app->wg->Request->getVal('diff')) { $content = FilePageHelper::stripCategoriesFromDescription($this->getContent()); $isContentEmpty = empty($content); } if ($isContentEmpty) { $file = $this->getDisplayedFile(); $editLink = $file->getTitle()->getLocalURL(array('action' => 'edit', 'useMessage' => 'video-page-default-description-header-and-text')); $html = $app->renderPartial('FilePageController', 'defaultDescription', array('editLink' => $editLink)); $out->addHTML($html); } wfProfileOut(__METHOD__); }