public function index() { if ($this->wg->user->isBlocked()) { $this->wg->out->blockedPage(); return false; // skip rendering } if (!$this->wg->user->isAllowed('specialvideohandler')) { $this->displayRestrictionError(); return false; } if (wfReadOnly() && !wfAutomaticReadOnly()) { $this->wg->out->readOnlyPage(); return false; } $videoId = $this->getVal('videoid', null); $provider = strtolower($this->getVal('provider', null)); $undercover = $this->getVal('undercover', false); $videoTitle = $this->getVal('videotitle', null); if ($videoId && $provider) { $overrideMetadata = array(); if (!empty($videoTitle)) { $overrideMetadata['title'] = $videoTitle; } try { $result = VideoFileUploader::uploadVideo($provider, $videoId, $title, null, $undercover, $overrideMetadata); } catch (Exception $e) { $result = (object) array('ok' => null, 'value' => null); } $this->setVal('uploadStatus', $result->ok); $this->setVal('isNewFile', empty($result->value)); $this->setVal('title', !empty($title) ? $title->getText() : ''); $this->setVal('url', !empty($title) ? $title->getFullURL() : ''); } }
public function execute($subpage) { global $wgOut, $wgUser, $wgExtensionsPath, $wgResourceBasePath; // Boilerplate special page permissions if ($wgUser->isBlocked()) { throw new UserBlockedError($this->getUser()->mBlock); } if (wfReadOnly() && !wfAutomaticReadOnly()) { $wgOut->readOnlyPage(); return; } if (!$wgUser->isAllowed('createpage') || !$wgUser->isAllowed('edit')) { $this->displayRestrictionError(); return; } $wgOut->addModules("wikia.jquery.ui"); $wgOut->addScript('<script src="' . $wgExtensionsPath . '/wikia/WikiaPoll/js/CreateWikiaPoll.js"></script>'); $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('/extensions/wikia/WikiaPoll/css/CreateWikiaPoll.scss')); if ($subpage != '') { // We came here from the edit link, go into edit mode $wgOut->addHtml(F::app()->renderView('WikiaPoll', 'SpecialPageEdit', array('title' => $subpage))); } else { $wgOut->addHtml(F::app()->renderView('WikiaPoll', 'SpecialPage')); } }
public function execute($subpage) { global $wgOut, $wgUser, $wgExtensionsPath, $wgResourceBasePath; // Boilerplate special page permissions if ($wgUser->isBlocked()) { throw new UserBlockedError($this->getUser()->mBlock); } if (!$wgUser->isAllowed('wikiaquiz')) { $this->displayRestrictionError(); return; } if (wfReadOnly() && !wfAutomaticReadOnly()) { $wgOut->readOnlyPage(); return; } $wgOut->addScript('<script src="' . $wgResourceBasePath . '/resources/wikia/libraries/jquery-ui/jquery-ui-1.8.14.custom.js"></script>'); $wgOut->addScript('<script src="' . $wgExtensionsPath . '/wikia/WikiaQuiz/js/CreateWikiaQuizArticle.js"></script>'); $wgOut->addStyle(AssetsManager::getInstance()->getSassCommonURL('/extensions/wikia/WikiaQuiz/css/WikiaQuizBuilder.scss')); if ($subpage != '') { // We came here from the edit link, go into edit mode $wgOut->addHtml(F::app()->renderView('WikiaQuiz', 'EditQuizArticle', array('title' => $subpage))); } else { $wgOut->addHtml(F::app()->renderView('WikiaQuiz', 'CreateQuizArticle')); } }
/** * execute * * main entry point * * @access public * * @param string $subpage: subpage of Title * * @return nothing */ public function execute($subpage) { global $wgUser, $wgOut, $wgRequest; if ($wgUser->isBlocked()) { throw new UserBlockedError($this->getUser()->mBlock); } if (wfReadOnly() && !wfAutomaticReadOnly()) { $wgOut->readOnlyPage(); return; } if (!$wgUser->isAllowed('wikifactory')) { $this->displayRestrictionError(); return; } $this->mTitle = Title::makeTitle(NS_SPECIAL, 'WikiFactory'); $this->mDomain = false; /** * initial output */ $wgOut->setPageTitle(wfMsg('wikifactorypagetitle')); $wgOut->setRobotpolicy('noindex,nofollow'); $wgOut->setArticleRelated(false); #--- handle chagelog if ($subpage === "change.log") { $oPager = new ChangeLogPager(); $oTmpl = new EasyTemplate(dirname(__FILE__) . "/templates/"); $oTmpl->set_vars(array("limit" => $oPager->getForm(), "body" => $oPager->getBody(), "nav" => $oPager->getNavigationBar())); $wgOut->addHTML($oTmpl->render("changelog")); } elseif (in_array(strtolower($subpage), array("metrics", "metrics/main", "metrics/monthly", "metrics/daily"))) { $oAWCMetrics = new WikiMetrics(); $oAWCMetrics->show($subpage); } elseif (strpos($subpage, "short.stats") === 0) { $subpageOptions = explode('/', $subpage); $lang = isset($subpageOptions[1]) ? $subpageOptions[1] : null; $wgOut->addHTML($this->shortStats($lang)); } elseif (strpos($subpage, "long.stats") === 0) { $subpageOptions = explode('/', $subpage); $lang = isset($subpageOptions[1]) ? $subpageOptions[1] : null; $wgOut->addHTML($this->longStats($lang)); } elseif (strtolower($subpage) === "add.variable") { $varOverrides = array(); $wgOut->addHTML($this->doAddVariableForm($varOverrides)); // process the post (if relevant). $wgOut->addHTML($this->addVariableForm($varOverrides)); // display the form } else { $subpage = $subpage == "/" ? null : $subpage; $oWiki = $this->getWikiData($subpage); if (!isset($oWiki->city_id)) { $this->doWikiSelector(); } else { $this->mWiki = $oWiki; $this->mTags = new WikiFactoryTags($this->mWiki->city_id); $this->doWikiForm(); } } }
private function checkPermissions() { global $wgUser, $wgOut; if ($wgUser->isBlocked()) { throw new UserBlockedError($wgUser->mBlock); } if (!$wgUser->isAllowed('wikiaquiz')) { throw new PermissionsError(""); } if (wfReadOnly() && !wfAutomaticReadOnly()) { $wgOut->readOnlyPage(); return false; } return true; }
public function updateCalendarEntriesForDate() { global $wgUser; //@todo move this to init once it supports exceptions // Boilerplate special page permissions if ($this->wg->user->isBlocked()) { $this->setVal('error', wfMsg('blockedtext')); return false; // skip rendering } if (!$this->wg->user->isAllowed('specialgamingcalendar')) { $this->setVal('error', wfMsg('badaccess-group0')); return false; } if (wfReadOnly() && !wfAutomaticReadOnly()) { $this->setVal('error', wfMsg('readonlytext')); return false; } wfProfileIn(__METHOD__); $res = array(); $type = $this->getVal('type', null); $date = $this->getVal('date', null); $titles = $this->getVal('title', null); $subtitles = $this->getVal('subtitle', null); $descriptions = $this->getVal('description', null); $images = $this->getVal('image', null); $systemses = $this->getVal('systems', null); $rating = $this->getVal('rating', null); $moreInfoUrls = $this->getVal('moreinfourl', null); $preorderUrls = $this->getVal('preorderurl', null); // input validation if (empty($type)) { $res = array('success' => false, 'error' => F::app()->renderView('Error', 'Index', array(wfMsg('gamingcalendar-error-missing-type')))); $this->setVal('res', $res); return; } // create message content $content = ''; foreach ($titles as $i => $title) { if (empty($title)) { continue; } if (!empty($subtitles[$i])) { $title = trim($title) . '|' . trim($subtitles[$i]); } $content .= GamingCalendar::$ENTRY_TITLE_MARKER . ' ' . $title . "\n"; if (!empty($descriptions[$i])) { $content .= GamingCalendar::$ENTRY_ATTRIBUTE_MARKER . ' ' . GamingCalendar::$ENTRY_DESCRIPTION_MARKER . ' ' . $descriptions[$i] . "\n"; } if (!empty($images[$i])) { $content .= GamingCalendar::$ENTRY_ATTRIBUTE_MARKER . ' ' . GamingCalendar::$ENTRY_IMAGE_MARKER . ' ' . $images[$i] . "\n"; } if (!empty($systemses[$i])) { $systems = explode(',', $systemses[$i]); foreach ($systems as &$system) { $system = trim($system); } $content .= GamingCalendar::$ENTRY_ATTRIBUTE_MARKER . ' ' . GamingCalendar::$ENTRY_SYSTEMS_MARKER . ' ' . implode(',', $systems) . "\n"; } if (!empty($rating[$i])) { $content .= GamingCalendar::$ENTRY_ATTRIBUTE_MARKER . ' ' . GamingCalendar::$ENTRY_RATING_MARKER . ' ' . $rating[$i] . "\n"; } if (!empty($moreInfoUrls[$i])) { $content .= GamingCalendar::$ENTRY_ATTRIBUTE_MARKER . ' ' . GamingCalendar::$ENTRY_MOREINFO_MARKER . ' ' . $moreInfoUrls[$i] . "\n"; } if (!empty($preorderUrls[$i])) { $content .= GamingCalendar::$ENTRY_ATTRIBUTE_MARKER . ' ' . GamingCalendar::$ENTRY_PREORDER_MARKER . ' ' . $preorderUrls[$i] . "\n"; } } // save message $msgTitle = Title::newFromText(GamingCalendar::getEntryKey($type, $date), NS_MEDIAWIKI); $article = new Article($msgTitle); if ($msgTitle->getArticleID()) { $editMsg = 'Message edited'; $editMode = EDIT_UPDATE; } else { $editMsg = 'Message created'; $editMode = EDIT_NEW; } $status = $article->doEdit($content, $editMsg, $editMode, false, $wgUser); $title_object = $article->getTitle(); // @todo check status object $res = array('success' => true, 'url' => '/wiki/Special:GamingCalendar?type=' . $type . '&year=' . date('Y', $date) . '&month=' . date('n', $date)); $this->setVal('res', $res); wfProfileOut(__METHOD__); }