/** * @param $url * @return array * @throws Exception */ protected function addVideoVideoHandlers($url) { $title = VideoFileUploader::URLtoTitle($url); if (!$title) { throw new Exception(wfMessage('videos-error-invalid-video-url')->text()); } return array($title, $title->getArticleID(), null); }
/** * Impliments revert functionality for videos * @param Array $data - Not used but maintaining method signature * @return bool - Whether the action was successful */ public function onSubmit($data) { // Get the archive name of the video $oldImageName = $this->getRequest()->getText('oldimage'); // Get the video file page $page = $this->page; // Get the DB version of the title text $title = $page->getTitle(); $dbKey = $title->getDBkey(); // Get the repo for this file $file = $page->getDisplayedFile(); $repo = $file->repo; // This returns a file object for an archived version of a video $archiveImg = WikiaLocalFile::newFromArchiveTitle($dbKey, $oldImageName, $repo); if (empty($archiveImg)) { return false; } // Get the original URL used to upload this video $handler = $archiveImg->getHandler(); $providerURL = $handler->getProviderDetailUrl(); // Upload this video again to this DB key. This will create a new version $title = VideoFileUploader::URLtoTitle($providerURL, $dbKey); return $title ? true : false; }
public function doSubmit() { global $wgOut, $wgRequest, $wgUser; $replaced = false; if ('' == $wgRequest->getVal('wpWikiaVideoAddName')) { if ('' != $wgRequest->getVal('wpWikiaVideoAddPrefilled')) { $this->mName = $wgRequest->getVal('wpWikiaVideoAddPrefilled'); $replaced = true; } else { $this->mName = ''; } } else { $this->mName = $wgRequest->getVal('wpWikiaVideoAddName'); } '' != $wgRequest->getVal('wpWikiaVideoAddUrl') ? $this->mUrl = $wgRequest->getVal('wpWikiaVideoAddUrl') : ($this->mUrl = ''); if ('' != $this->mName && '' != $this->mUrl) { $this->mName = ucfirst($this->mName); // sanitize all video titles $this->mName = VideoFileUploader::sanitizeTitle($this->mName); $title = Title::makeTitleSafe(NS_VIDEO, $this->mName); if ($title instanceof Title) { $permErrors = $title->getUserPermissionsErrors('edit', $wgUser); $permErrorsUpload = $title->getUserPermissionsErrors('upload', $wgUser); $permErrorsCreate = $title->exists() ? array() : $title->getUserPermissionsErrors('create', $wgUser); if ($permErrors || $permErrorsUpload || $permErrorsCreate) { header('X-screen-type: error'); $wgOut->addWikiMsg('wva-protected'); return; } if (WikiaFileHelper::useVideoHandlersExtForEmbed()) { $res = null; try { $res = VideoFileUploader::URLtoTitle($this->mUrl, $this->mName); } catch (Exception $e) { } if (!$res) { $wgOut->addHTML(wfMsg('wva-failure')); return; } } if (WikiaFileHelper::useWikiaVideoExtForEmbed()) { $video = new VideoPage($title); $video->parseUrl($this->mUrl); $video->setName($this->mName); $video->save(); } $sk = RequestContext::getMain()->getSkin(); $link_back = $sk->makeKnownLinkObj($title); if ($replaced) { $wgOut->addHTML(wfMsg('wva-success-replaced', $link_back)); } else { $wgOut->addHTML(wfMsg('wva-success', $link_back)); } } else { //bad title returned $wgOut->addHTML(wfMsg('wva-failure')); } } else { //one of two params blank $wgOut->addHTML(wfMsg('wva-failure')); } }
public function doSubmit() { global $wgOut; $errors = array(); $replaced = false; $this->mUrl = $this->getRequest()->getVal('wpWikiaVideoAddUrl', ''); $this->mName = $this->getRequest()->getVal('wpWikiaVideoAddName', ''); if ($this->mName == '') { $this->mName = $this->getRequest()->getVal('name', ''); if ($this->mName != '') { $replaced = true; } } if ($this->mUrl == '') { $errors['videoUrl'] = wfMessage('wva-failure')->text(); $this->showForm($errors); return; } else { if ($this->mName == '') { $videoService = new VideoService(); $retval = $videoService->addVideo($this->mUrl); if (is_array($retval)) { list($title, $videoPageId, $videoProvider) = $retval; } else { $errors['videoUrl'] = $retval; $this->showForm($errors); return; } } else { $this->mName = ucfirst($this->mName); // sanitize all video titles $this->mName = VideoFileUploader::sanitizeTitle($this->mName); $title = Title::makeTitleSafe(NS_FILE, $this->mName); if ($title instanceof Title) { $permErrors = $title->getUserPermissionsErrors('edit', $this->getUser()); $permErrorsUpload = $title->getUserPermissionsErrors('upload', $this->getUser()); $permErrorsCreate = $title->exists() ? array() : $title->getUserPermissionsErrors('create', $this->getUser()); if ($permErrors || $permErrorsUpload || $permErrorsCreate) { header('X-screen-type: error'); $wgOut->addWikiMsg('wva-protected'); return; } if (empty(F::app()->wg->allowNonPremiumVideos)) { $errors['videoUrl'] = wfMessage('videohandler-non-premium')->parse(); $this->showForm($errors); return; } if (WikiaFileHelper::useVideoHandlersExtForEmbed()) { $res = null; try { $res = VideoFileUploader::URLtoTitle($this->mUrl, $this->mName); } catch (Exception $e) { } if (!$res) { $errors['videoUrl'] = wfMessage('wva-failure')->text(); $this->showForm($errors); return; } } } else { //bad title returned $errors['name'] = wfMessage('wva-failure')->text(); $this->showForm($errors); return; } } } if ($replaced) { $successMsgKey = 'wva-success-replaced'; } else { $successMsgKey = 'wva-success'; } $query = array("sort" => "recent", "msg" => $successMsgKey, "msgTitle" => urlencode($title)); $wgOut->redirect(SpecialPage::getTitleFor("Videos")->getLocalUrl($query)); }