function insertFinalVideo() { global $wgRequest, $wgContLang; $id = $wgRequest->getVal('id'); $provider = $wgRequest->getVal('provider'); $name = urldecode($wgRequest->getVal('name')); $embed_code = ''; if ($provider == 'FILE') { // no need to upload, local reference $title = $oTitle = Title::newFromText($name, NS_FILE); if (empty($oTitle)) { header('X-screen-type: error'); return wfMessage('vet-name-incorrect')->plain(); } wfRunHooks('AddPremiumVideo', array($title)); } else { // needs to upload // sanitize name and init title objects $name = VideoFileUploader::sanitizeTitle($name); if ($name == '') { header('X-screen-type: error'); return wfMessage('vet-warn3')->plain(); } $nameFile = VideoFileUploader::sanitizeTitle($name); $titleFile = VideoFileUploader::getUniqueTitle($nameFile); if (empty($titleFile)) { header('X-screen-type: error'); return wfMessage('vet-name-incorrect')->plain(); } // by definition, WikiaFileHelper::useVideoHandlersExtForEmbed() == true $nameSanitized = $titleFile->getBaseText(); $title = $titleFile; $extra = 0; $metadata = array(); while ('' != $wgRequest->getVal('metadata' . $extra)) { $metadata[] = $wgRequest->getVal('metadata' . $extra); $extra++; } $parts = explode('/', $provider); $provider = $parts[1]; $oTitle = null; $status = $this->uploadVideoAsFile($provider, $id, $nameSanitized, $oTitle); if (!$status->ok) { header('X-screen-type: error'); return wfMessage('wva-thumbnail-upload-failed')->plain(); } } $description = trim(urldecode($wgRequest->getVal('description'))); // Set the video descriptions $vHelper = new VideoHandlerHelper(); $vHelper->setVideoDescription($oTitle, $description); $message = wfMessage('vet-single-success')->plain(); $ns_file = $wgContLang->getFormattedNsText($title->getNamespace()); $caption = $wgRequest->getVal('caption'); $width = $wgRequest->getVal('width'); $width = empty($width) ? 335 : $width; $layout = $wgRequest->getVal('layout'); header('X-screen-type: summary'); $tag = $ns_file . ":" . $oTitle->getText(); // all videos added via VET will be shown as thumbnails / "framed" $tag .= "|thumb"; if (!empty($layout)) { $tag .= "|{$layout}"; } if ($width != '') { $tag .= "|{$width} px"; } if ($caption != '') { $tag .= "|" . $caption; } $tag = "[[{$tag}]]"; $button_message = wfMessage('vet-return')->plain(); // Adding a video from article view page $editFromViewMode = $wgRequest->getVal('placeholder'); if ($editFromViewMode) { Wikia::setVar('EditFromViewMode', true); $article_title = $wgRequest->getVal('article'); $ns = $wgRequest->getVal('ns'); $box = $wgRequest->getVal('box'); $article_title_obj = Title::newFromText($article_title, $ns); $article_obj = new Article($article_title_obj); $text = $article_obj->getContent(); // match [[File:Placeholder|video]] $placeholder = MediaPlaceholderMatch($text, $box, true); $success = false; if ($placeholder) { $placeholder_tag = $placeholder[0]; $file = wfFindFile($title); $embed_code = $file->transform(array('width' => $width))->toHtml(); $params = array('alt' => $title->getText(), 'title' => $title->getText(), 'img-class' => 'thumbimage', 'align' => $layout, 'outerWidth' => $width, 'file' => $file, 'url' => $file->getUrl(), 'html' => $embed_code); $embed_code = F::app()->renderView('ThumbnailController', 'articleBlock', $params); // Make output match what's in a saved article if ($layout == 'center') { $embed_code = '<div class="center">' . $embed_code . '</div>'; } $summary = wfMessage('vet-added-from-placeholder')->plain(); $text = substr_replace($text, $tag, $placeholder[1], strlen($placeholder_tag)); $button_message = wfMessage('vet-placeholder-return')->plain(); $success = $article_obj->doEdit($text, $summary); } if (!$success) { header('X-screen-type: error'); return wfMessage('vet-insert-error')->plain(); } } $tmpl = new EasyTemplate(dirname(__FILE__) . '/templates/'); $tmpl->set_vars(array('tag' => $tag, 'message' => $message, 'code' => $embed_code, 'button_message' => $button_message)); return $tmpl->render('summary'); }
/** * Modify the description of a video * @requestParam string title * @requestParam string description * @responseParam string status [success/fail] * @responseParam string errMsg */ public function editDescription() { $title = urldecode($this->request->getVal('title')); $title = Title::newFromText($title, NS_FILE); $description = urldecode($this->request->getVal('description')); $vHelper = new VideoHandlerHelper(); $status = $vHelper->setVideoDescription($title, $description); if ($status) { $this->status = 'success'; } else { $this->status = 'fail'; $this->errMsg = wfMessage('vet-description-save-error')->text(); } }