/** * Main page for Special:Css page * * @return boolean */ public function index() { wfProfileIn(__METHOD__); if ($this->checkPermissions()) { $this->displayRestrictionError(); wfProfileOut(__METHOD__); return false; // skip rendering } if ($this->wg->User->isBlocked()) { $block = $this->wg->User->mBlock; wfProfileOut(__METHOD__); throw new UserBlockedError($block); } $model = $this->getModel(); $this->cssFileInfo = $model->getCssFileInfo(); if ($this->request->wasPosted()) { $content = $this->request->getVal('cssContent', ''); /** @var $status Status */ $status = $model->saveCssFileContent($content, $this->request->getVal('editSummary', ''), $this->request->getVal('minorEdit', '') != '', $this->request->getVal('lastEditTimestamp', false), $this->wg->user); if (!$status) { BannerNotificationsController::addConfirmation(wfMessage('special-css-merge-error')->escaped(), BannerNotificationsController::CONFIRMATION_ERROR); $this->diff = $this->app->sendRequest(__CLASS__, 'getDiff', ['wikitext' => $content])->getVal('diff'); } else { if ($status->isOk()) { BannerNotificationsController::addConfirmation(wfMessage('special-css-save-message')->escaped()); $this->wg->Out->redirect($this->specialPage->getTitle()->getLocalURL()); wfProfileOut(__METHOD__); return false; // skip rendering } else { BannerNotificationsController::addConfirmation($status->getMessage(), BannerNotificationsController::CONFIRMATION_ERROR); $this->cssContent = $content; } } } if ($this->request->getVal('oldid', null) !== null) { BannerNotificationsController::addConfirmation(wfMessage('special-css-oldid-message')->escaped(), BannerNotificationsController::CONFIRMATION_WARN); } // get url and number of comments for Talk button $service = new PageStatsService($model->getCssFileArticleId()); $this->cssFileTitle = $model->getCssFileTitle(); $this->cssFileCommentsCount = $service->getCommentsCount(); $this->cssUpdates = $model->getCssUpdatesData(); $this->cssUpdatesUrl = $model->getCssUpdatesUrl(); $this->dropdown = $this->createButtonLinks(); $this->handleAssets(); $this->minorDefault = $model->isMinorEditDefault(); $this->wg->Out->setPageTitle($this->wf->Message('special-css-title')->plain()); $this->wg->SuppressSpotlights = true; wfProfileOut(__METHOD__); return true; }
/** * Renders first tab - blocks creation / edit */ public function main() { wfProfileIn(__METHOD__); if (!$this->userCanExecute($this->wg->User)) { wfProfileOut(__METHOD__); $this->displayRestrictionError(); return; } // creating / editing a block if ($this->wg->Request->wasPosted()) { $res = $this->handleBlockPost(); // add a message that will be shown after the redirect if ($res === self::RESULT_ERROR) { BannerNotificationsController::addConfirmation(wfMsg('phalanx-block-failure'), BannerNotificationsController::CONFIRMATION_ERROR); } else { BannerNotificationsController::addConfirmation(wfMsg($res === self::RESULT_BLOCK_ADDED ? 'phalanx-block-success' : 'phalanx-modify-success'), BannerNotificationsController::CONFIRMATION_CONFIRM); } $this->wg->Out->redirect($this->title->getFullURL()); wfProfileOut(__METHOD__); return; } /* set pager */ $pager = new PhalanxPager(); $listing = $pager->getNavigationBar(); $listing .= $pager->getBody(); $listing .= $pager->getNavigationBar(); $data = $this->blockDataForForm(); $editMode = !empty($data['id']); $expiries = Phalanx::getExpireValues(); if ($editMode) { $expiries = array_merge(array('' => wfMsg('phalanx-expiries-select')), $expiries); } // VSTF should not be allowed to block emails in Phalanx $showEmailBlock = $this->wg->User->isAllowed('phalanxemailblock'); $blockTypes = Phalanx::getAllTypeNames(); $typeSections = ['page-edition' => [Phalanx::TYPE_CONTENT, Phalanx::TYPE_SUMMARY, Phalanx::TYPE_TITLE, Phalanx::TYPE_USER], 'account-creation' => [Phalanx::TYPE_EMAIL], 'wiki-creation' => [Phalanx::TYPE_WIKI_CREATION], 'questions' => [Phalanx::TYPE_ANSWERS_QUESTION_TITLE, Phalanx::TYPE_ANSWERS_RECENT_QUESTIONS]]; if (!$showEmailBlock) { unset($typeSections['account-creation']); } $this->setVal('expiries', $expiries); $this->setVal('languages', $this->wg->PhalanxSupportedLanguages); $this->setVal('listing', $listing); $this->setVal('data', $data); $this->setVal('editMode', $editMode); $this->setVal('action', $this->title->getLocalURL()); $this->setVal('typeFilter', $pager->getSearchFilter()); $this->setVal('blockTypes', $blockTypes); $this->setVal('type', $this->wg->Request->getInt('type')); $this->setVal('typeSections', $typeSections); wfProfileOut(__METHOD__); }
function efConfirmEmailPrompt(&$msg) { global $wgUser; if (!F::app()->checkSkin('oasis')) { return true; } if ($wgUser->isEmailConfirmed()) { return true; } if ($wgUser->getEmail() == '') { return true; } $message = wfMsgExt('confirmemailprompt-error', array('parseinline'), array($wgUser->getEmail(), SpecialPage::getTitleFor('ConfirmEmail')->getPrefixedText(), SpecialPage::getTitleFor('Preferences')->getPrefixedText())); BannerNotificationsController::addConfirmation($message, BannerNotificationsController::CONFIRMATION_ERROR); return true; }
public function index() { wfProfileIn(__METHOD__); $output = $this->getContext()->getOutput(); $output->setRobotPolicy("index,follow"); $policies = Title::newFromText('forum-policies-and-faq', NS_MEDIAWIKI); $this->response->setJsVar('wgCanEditPolicies', $this->wg->User->isAllowed('forumadmin')); $this->response->setJsVar('wgPoliciesRev', $policies->getLatestRevID()); $this->response->setJsVar('wgPoliciesEditURL', $policies->getFullUrl('action=edit')); //getLatestRevID JSMessages::enqueuePackage('Forum', JSMessages::EXTERNAL); $this->response->addAsset('extensions/wikia/Forum/js/Forum.js'); if ($this->request->getVal('showWarning', 0) == 1) { BannerNotificationsController::addConfirmation(wfMessage('forum-board-no-board-warning')->escaped(), BannerNotificationsController::CONFIRMATION_WARN); } $action = $this->getVal('action', ''); if ('editmode' == $action) { $this->forward('ForumSpecial', 'editMode'); } $output->setPageTitle(wfMessage('forum-forum-title')->plain()); $action = $this->getVal('action', ''); $this->blurb = wfMessage('forum-specialpage-blurb')->parse(); $this->blurbHeading = wfMessage('forum-specialpage-blurb-heading')->parse(); $this->lastPostByMsg = wfMessage('forum-specialpage-board-lastpostby')->escaped(); $this->canEdit = $this->wg->User->isAllowed('forumadmin'); $this->editUrl = $this->wg->Title->getFullUrl('action=editmode'); $forum = new Forum(); if ($forum->createDefaultBoard()) { $this->boards = $forum->getBoardList(DB_MASTER); } else { $this->boards = $forum->getBoardList(DB_SLAVE); } if ($forum->haveOldForums()) { $this->showOldForumLink = true; $this->oldForumLink = Title::newFromText('Index', NS_FORUM)->getFullUrl(); } else { $this->showOldForumLink = false; } //TODO: keep the varnish cache and do purging on post $this->response->setCacheValidity(WikiaResponse::CACHE_DISABLED); wfProfileOut(__METHOD__); }
public function index() { $this->setGlobalDisplayVars(); $this->accessReview = $this->wg->User->isAllowed('wdacreview'); if (!$this->specialPage->userCanExecute($this->wg->User)) { $this->specialPage->displayRestrictionError(); return false; } $this->response->addAsset('extensions/wikia/WDACReview/js/WDACReview.js'); $this->response->addAsset('extensions/wikia/WDACReview/css/WDACReview.scss'); $helper = $this->getHelper(); $this->baseUrl = $this->specialPage->getTitle()->getFullUrl(); $this->paginatorUrl = urldecode($this->specialPage->getTitle()->getFullUrl(array('page' => "%s"))); $this->toolName = $this->getToolName(); $this->submitUrl = $this->baseUrl; if ($this->wg->request->wasPosted()) { $data = $this->wg->request->getValues(); if (!empty($data)) { $cities = $this->parseData($data); if (count($cities) > 0) { $helper->updateWDACFlags($cities); BannerNotificationsController::addConfirmation(wfMessage('wdacreview-confirm-update')->escaped()); } } } $iPage = $this->wg->request->getVal('page', 1); $iCount = $helper->getCountWikisForReview(); $this->aCities = $helper->getCitiesForReviewList(self::WIKIS_PER_PAGE_LIMIT, $iPage - 1); $this->paginator = ''; if (self::WIKIS_PER_PAGE_LIMIT < $iCount) { $oPaginator = Paginator::newFromArray(array_fill(0, $iCount, ''), self::WIKIS_PER_PAGE_LIMIT); $oPaginator->setActivePage($iPage - 1); // And here we go! The %s will be replaced with the page number. $this->paginator = $oPaginator->getBarHTML($this->paginatorUrl); } }
/** * Ajax method for un/deleting a map from IntMaps API */ public function updateMapDeletionStatus() { $mapId = $this->request->getInt('mapId'); $deleted = $this->request->getInt('deleted'); if (!in_array($deleted, [WikiaMaps::MAP_DELETED, WikiaMaps::MAP_NOT_DELETED])) { $deleted = WikiaMaps::MAP_DELETED; } $result = false; if (!$this->isUserAllowed() || !$this->canUserDelete() && !$this->isUserMapCreator($mapId)) { throw new WikiaMapsPermissionException(); } if ($mapId) { $result = $this->getModel()->updateMapDeletionStatus($mapId, $deleted)['success']; } if ($result) { $action = $deleted === WikiaMaps::MAP_DELETED ? WikiaMapsLogger::ACTION_DELETE_MAP : WikiaMapsLogger::ACTION_UNDELETE_MAP; WikiaMapsLogger::addLogEntry($action, $this->wg->User, $mapId, $mapId); BannerNotificationsController::addConfirmation($deleted ? wfMessage('wikia-interactive-maps-delete-map-success')->text() : wfMessage('wikia-interactive-maps-undelete-map-success')->text()); $redirectUrl = WikiaMapsSpecialController::getSpecialUrl(); if ($deleted === WikiaMaps::MAP_NOT_DELETED) { $redirectUrl .= '/' . $mapId; } $this->response->setVal('redirectUrl', $redirectUrl); } }
/** * Show a friendly error message to a user after redirect */ private function addBannerNotificationMessage($messageName) { BannerNotificationsController::addConfirmation(wfMessage($messageName)->escaped(), BannerNotificationsController::CONFIRMATION_ERROR); }
public static function onLinksUpdateInsertTemplates($pageId, array $templates) { $app = \F::app(); if (!empty($templates) && $app->wg->HideFlagsExt !== true) { $flagTypesResponse = $app->sendRequest('FlagsApiController', 'getFlagsForPageForEdit', ['wiki_id' => $app->wg->CityId, 'page_id' => $pageId])->getData(); if ($flagTypesResponse[\FlagsApiController::FLAGS_API_RESPONSE_STATUS]) { $flagTypesToExtract = $flagTypesToExtractNames = []; /** * We need modified versions of names of templates and flag_view values to * compare in a case-insensitive and space-underscore-insensitive way. */ $templatesKeys = []; foreach ($templates as $template) { $templatesKeys[] = strtolower($template['tl_title']); } foreach ($flagTypesResponse[\FlagsApiController::FLAGS_API_RESPONSE_DATA] as $flagType) { if (isset($flagType['flag_id'])) { continue; } $flagViewKey = strtolower(str_replace(' ', '_', $flagType['flag_view'])); if (in_array($flagViewKey, $templatesKeys)) { $flagTypesToExtract[$flagType['flag_view']] = $flagType; } } if (!empty($flagTypesToExtract)) { $task = new FlagsExtractTemplatesTask(); $task->wikiId($app->wg->CityId); $task->call('extractTemplatesFromPage', $pageId, $flagTypesToExtract); $task->prioritize(); $task->queue(); \BannerNotificationsController::addConfirmation(wfMessage('flags-notification-templates-extraction')->params(implode(', ', array_keys($flagTypesToExtract)))->parse(), \BannerNotificationsController::CONFIRMATION_WARN, true); } } } return true; }
/** * Performs actions common for map() and mapData() - single map pages * @param $mapData */ public function prepareSingleMapPage($mapData) { $mapCityId = $mapData->city_id; $this->response->setVal('mapCityId', $mapCityId); $this->redirectIfForeignWiki($mapCityId, $this->response->getVal('mapId')); $this->wg->out->setHTMLTitle($mapData->title); $mapDeleted = $mapData->deleted == WikiaMaps::MAP_DELETED; if ($mapDeleted && $this->app->checkSkin('oasis')) { BannerNotificationsController::addConfirmation(wfMessage('wikia-interactive-maps-map-is-deleted'), BannerNotificationsController::CONFIRMATION_WARN); } $this->response->setVal('deleted', $mapDeleted); }
/** * After the forms is sent to the proper Email Controller, inspect the result. * If it's "ok", add a confirmation banner notification to indicate success. Otherwise * add an error banner notification and output the error from the Email Controller. * @param \WikiaResponse $result */ private function addBannerNotification($result) { $responseData = $result->getData(); if ($responseData['result'] == 'ok') { \BannerNotificationsController::addConfirmation("Successfully sent email!", \BannerNotificationsController::CONFIRMATION_CONFIRM); } else { \BannerNotificationsController::addConfirmation("Errors: " . $responseData['msg'], \BannerNotificationsController::CONFIRMATION_ERROR); } }
/** * Edit program assets given a language (region), program date and page section * @requestParam string language * @requestParam string date [timestamp] * @requestParam string section [featured/category/fan] * @responseParam string result [ok/error] * @responseParam string msg - result message */ public function edit() { JSMessages::enqueuePackage('VideoPageTool', JSMessages::EXTERNAL); $time = $this->getVal('date', time()); $language = $this->getVal('language', VideoPageToolHelper::DEFAULT_LANGUAGE); $section = $this->getVal('section', VideoPageToolHelper::DEFAULT_SECTION); $action = $this->getVal('action', ''); // for save message $success = $this->getVal('success', ''); $helper = new VideoPageToolHelper(); // get date $date = strtotime(date('Y-M-d', $time)); // validate section - set to DEFAULT_SECTION if not exists $sections = $helper->getSections(); if (!array_key_exists($section, $sections)) { $section = VideoPageToolHelper::DEFAULT_SECTION; } // get left menu items $leftMenuItems = $helper->getLeftMenuItems($section, $sections, $language, $date); $program = VideoPageToolProgram::newProgram($language, $date); // get program assets. VPT needs a program object for each request. It first checks if one already exists for // that language and date. If one doesn't, it creates a new one. It then uses that program to pull the // associated assets. If it's a new program, it won't have any assets yet created. To help the user, we // grab the assets from the the last saved program and use those as the default assets for this new program. $assets = $program->getAssetsBySection($section); if (empty($assets)) { $latestProgram = VideoPageToolProgram::loadProgramNearestDate($language, $date); if (!empty($latestProgram)) { $assets = $latestProgram->getAssetsBySection($section); } } $publishDate = null; $publishedBy = null; if ($program->isPublished()) { $publishDate = $program->getPublishDate(); $publishedBy = $program->getPublishedBy(); } else { if (isset($latestProgram) && $latestProgram->isPublished()) { $publishDate = $latestProgram->getPublishDate(); $publishedBy = $latestProgram->getPublishedBy(); } } if ($publishedBy) { // Translate user id into username $publishedBy = User::newFromId($publishedBy)->getName(); } $lastSavedOn = 0; $savedBy = null; // get asset data $videos = array(); if (empty($assets)) { // get default assets $videos = $helper->getDefaultValuesBySection($section); } else { // Override defaults so we always show a lightbox in the admin pages $thumbOptions = ['noLightbox' => false]; // Saved on and saved by data are saved on a per asset basis, therefore it's necessary to loop through each // asset to make sure we're using the latest saved information. foreach ($assets as $order => $asset) { /** @var VideoPageToolAsset $asset */ $videos[$order] = $asset->getAssetData($thumbOptions); if ($asset->getUpdatedAt() > $lastSavedOn) { $lastSavedOn = $asset->getUpdatedAt(); $savedBy = $asset->getUpdatedBy(); } } $savedBy = User::newFromId($savedBy)->getName(); } $result = ''; $msg = ''; if ($this->request->wasPosted()) { // publish program if ($action == 'publish') { $response = $this->sendSelfRequest($action, array('date' => $date, 'language' => $language)); $msg = $response->getVal('msg', ''); $result = $response->getVal('result', ''); if ($result == 'ok') { // redirect to Special:VideoPageAdmin $url = SpecialPage::getTitleFor('VideoPageAdmin')->getLocalURL(); $msg = wfMessage('videopagetool-success-publish')->plain(); BannerNotificationsController::addConfirmation($msg, BannerNotificationsController::CONFIRMATION_CONFIRM); $this->getContext()->getOutput()->redirect($url); return false; } // save assets } else { $formValues = $this->request->getParams(); $errMsg = ''; // use displayTitle field to get required rows $requiredRows = $helper->getRequiredRows($section, $formValues); $data = $program->formatFormData($section, $requiredRows, $formValues, $errMsg); // Add blank records so $data is the same length as $assets. // This ensures the old assets are removed from DB if they were removed from the input form for ($i = count($data) + 1; $i <= count($assets); $i++) { $data[$i] = []; } if (empty($errMsg)) { $status = $program->saveAssetsBySection($section, $data); if ($status->isGood()) { $nextUrl = $helper->getNextMenuItemUrl($leftMenuItems) . '&success=1'; $this->getContext()->getOutput()->redirect($nextUrl); return false; } else { $result = 'error'; $msg = $status->getMessage(); } } else { // update original asset data foreach ($data as $order => $row) { foreach ($row as $name => $value) { $videos[$order][$name] = $value; // replace alternative thumbnail if ($name == 'altThumbTitle' && array_key_exists('altThumbKey', $videos[$order]) && $videos[$order]['altThumbKey'] != $value) { $videos[$order] = $helper->replaceThumbnail($videos[$order], $value); } } } $result = 'error'; $msg = $errMsg; } } // save successfully } else { if (!empty($success)) { $result = 'ok'; $msg = wfMessage('videopagetool-success-save')->plain(); } } // add default values if the number of assets is less than number of rows that needed to be shown $defaultValues = array_pop($helper->getDefaultValuesBySection($section, 1)); for ($i = count($videos) + 1; $i <= $helper->getRequiredRowsMax($section); $i++) { $videos[$i] = $defaultValues; } $this->result = $result; $this->msg = $msg; $this->leftMenuItems = $leftMenuItems; $this->moduleView = $this->app->renderView('VideoPageAdminSpecial', $section, array('videos' => $videos, 'date' => $date, 'language' => $language)); $this->publishButton = $program->isPublishable(array_keys($sections)) ? '' : 'disabled'; $this->publishUrl = $this->wg->Title->getLocalURL(array('date' => $date, 'language' => $language)); $this->programDate = $program->getFormattedPublishDate(); $this->section = $section; $this->language = $language; $this->lastSavedOn = $lastSavedOn; $this->savedBy = $savedBy; $this->publishDate = $publishDate; $this->publishedBy = $publishedBy; }
/** * Handle confirmation message from Facebook Connect */ public static function onSkinTemplatePageBeforeUserMsg(&$html) { if (F::app()->checkSkin('oasis')) { // check for querystring param $fbStatus = F::app()->wg->Request->getVal('fbconnected'); if ($fbStatus == '1') { // check if current user is connected to facebook $map = FacebookClient::getInstance()->getMapping(); if (!empty($map)) { BannerNotificationsController::addConfirmation(wfMessage('fbconnect-connect-msg')->escaped()); } } } return true; }
public function execute($subpage) { wfProfileIn(__METHOD__); $this->games = new ScavengerHuntGames(); $this->setHeaders(); $this->mTitle = SpecialPage::getTitleFor('scavengerhunt'); if ($this->isRestricted() && !$this->userCanExecute($this->user)) { $this->displayRestrictionError(); wfProfileOut(__METHOD__); return; } @(list($action, $id) = explode('/', $subpage)); $action = !empty($action) ? $action : 'list'; $id = (int) $id; $game = $this->games->findById($id); if (empty($game)) { $game = $this->games->newGame(); } // check edit tokens if ($this->request->wasPosted() && !$this->user->matchEditToken($this->request->getVal('wpEditToken'))) { BannerNotificationsController::addConfirmation(wfMsg('scavengerhunt-edit-token-mismatch'), BannerNotificationsController::CONFIRMATION_ERROR); $this->out->redirect($this->mTitle->getFullUrl()); wfProfileOut(__METHOD__); return; } $this->out->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/ScavengerHunt/css/scavenger-special.scss')); $this->out->addStyle(AssetsManager::getInstance()->getSassCommonURL('extensions/wikia/ScavengerHunt/css/scavenger-game.scss')); $this->out->addScriptFile($this->app->getGlobal('wgExtensionsPath') . '/wikia/ScavengerHunt/js/scavenger-special.js'); $template = new EasyTemplate(dirname(__FILE__) . '/templates/'); $errors = array(); switch ($action) { case 'list': $button = '<a class="wikia-button scavengerhunt-add-button" href="' . $this->mTitle->getFullUrl() . '/add">' . Xml::element('img', array('class' => 'sprite new', 'src' => $this->app->getGlobal('wgBlankImgUrl'))) . wfMsg('scavengerhunt-button-add') . '</a>'; $this->out->mPagetitle .= $button; $this->out->mPageLinkTitle = true; // Games list $pager = new ScavengerHuntGamesPager($this->games, $this->mTitle->getFullUrl(), $template); $this->out->addHTML($pager->getBody() . $pager->getNavigationBar()); break; case 'toggle': $enable = !$game->isEnabled(); $game->setEnabled($enable); $errors = $this->validateGame($game); if (empty($errors['errors'])) { $game->save(); BannerNotificationsController::addConfirmation($enable ? wfMsg('scavengerhunt-game-has-been-enabled') : wfMsg('scavengerhunt-game-has-been-disabled')); //success! go to the list $this->out->redirect($this->mTitle->getFullUrl()); wfProfileOut(__METHOD__); return; } else { //failure - display errors $game->setEnabled(false); } // no "break" on purpose - wasPosted() will return false but we'll display proper template // no "break" on purpose - wasPosted() will return false but we'll display proper template case 'edit': if ($this->request->wasPosted()) { if ($this->request->getVal('enable')) { $enabled = !$this->request->getVal('prevEnabled'); $game->setEnabled($enabled); $errors = $this->validateGame($game); if (empty($errors['errors'])) { $game->save(); BannerNotificationsController::addConfirmation($enabled ? wfMsg('scavengerhunt-game-has-been-enabled') : wfMsg('scavengerhunt-game-has-been-disabled')); $this->out->redirect($this->mTitle->getFullUrl() . "/edit/{$id}"); wfProfileOut(__METHOD__); return; } else { $game->setEnabled(false); } } else { if ($this->request->getVal('delete')) { $game->delete(); BannerNotificationsController::addConfirmation(wfMsg('scavengerhunt-game-has-been-deleted')); $this->out->redirect($this->mTitle->getFullUrl()); wfProfileOut(__METHOD__); return; } } } // no "break" on purpose // no "break" on purpose case 'add': if ($this->request->wasPosted()) { if ($this->request->getVal('save')) { $game = $this->updatePostedGame($game); // move the validation process to the moment of enabling the game $errors = $this->validateGame($game); // save changes if (empty($errors['errors']) && $game->save()) { BannerNotificationsController::addConfirmation($action == 'add' ? wfMsg('scavengerhunt-game-has-been-created') : wfMsg('scavengerhunt-game-has-been-saved')); $this->out->redirect($this->mTitle->getFullUrl()); wfProfileOut(__METHOD__); return; } else { BannerNotificationsController::addConfirmation(wfMsg('scavengerhunt-game-has-not-been-saved'), BannerNotificationsController::CONFIRMATION_NOTIFY); } } } $template->set('errors', isset($errors['errors']) ? $errors['errors'] : array()); $template->set('highlight', isset($errors['highlight']) ? $errors['highlight'] : array()); $template->set('editToken', $this->user->getEditToken()); $template->set_vars($this->getTemplateVarsFromGame($game)); $this->out->addHTML($template->render('form')); break; } wfProfileOut(__METHOD__); }
/** * Videos page * @requestParam string sort [ recent/popular/trend/premium ] * @requestParam integer page - page number * @requestParam string category * @requestParam string msg - BannerNotifications message * @requestParam string msgTitle - for BannerNotifications * @requestParam string provider * @responseParam integer addVideo [0/1] * @responseParam string pagination * @responseParam string loadMore (For mobile only) * @responseParam string sortMsg - selected option (sorting) * @responseParam array sortingOptions - sorting options * @responseParam array videos - list of videos * @responseParam string message */ public function index() { $this->wg->SupressPageSubtitle = true; $scriptsStr = 'special_videos_js'; $stylesStr = 'special_videos_css'; $isMobile = $this->app->checkSkin('wikiamobile'); if ($isMobile) { $this->response->setTemplateEngine(WikiaResponse::TEMPLATE_ENGINE_MUSTACHE); $scriptsStr .= '_mobile'; $stylesStr .= '_mobile'; } else { $this->response->addAsset('special_videos_css_monobook'); } $this->response->addAsset($scriptsStr); $this->response->addAsset($stylesStr); // enqueue i18n message for javascript JSMessages::enqueuePackage('SpecialVideos', JSMessages::INLINE); // Change the <title> attribute and the <h1> for the page $this->getContext()->getOutput()->setPageTitle(wfMessage('specialvideos-page-title')->text()); $this->getContext()->getOutput()->setHTMLTitle(wfMessage('specialvideos-html-title')->text()); // For search engines $this->getContext()->getOutput()->setRobotPolicy("index,follow"); $helper = new SpecialVideosHelper(); // Add meta description tag to HTML source $this->getContext()->getOutput()->addMeta('description', $helper->getMetaTagDescription()); // Sorting/filtering dropdown values $sort = $this->request->getVal('sort', 'trend'); $page = $this->request->getVal('page', 1); $category = $this->request->getVal('category', ''); // Filter on a comma separated list of providers if given. $providers = $this->request->getVal('provider', ''); // Add BannerNotifications message after adding a new video. // We can abstract this later if we want to add more types of messages $msg = $this->request->getVal('msg', ''); if (!empty($msg)) { $msgTitle = $this->request->getVal('msgTitle', ''); $msgTitle = urldecode($msgTitle); BannerNotificationsController::addConfirmation(wfMessage($msg, $msgTitle)->parse(), BannerNotificationsController::CONFIRMATION_CONFIRM); } if (!is_numeric($page)) { $page = 1; } // Variable to display the "add video" link at the end of the results $addVideo = 1; // get sorting options if ($isMobile) { $sortingOptions = $helper->getSortOptionsMobile(); } else { $sortingOptions = array_merge($helper->getSortOptions(), $helper->getFilterOptions()); } if (!array_key_exists($sort, $sortingOptions)) { $sort = 'recent'; } // The new trending in <category> options have a slightly different key format $sortKey = $sort . (empty($category) ? '' : ":{$category}"); // get videos $params = ['sort' => $sort, 'page' => $page, 'category' => $category, 'provider' => $providers]; $response = $this->sendSelfRequest('getVideos', $params); $videos = $response->getVal('videos', []); $message = ''; $pagination = ''; if ($isMobile) { if (empty($videos)) { $message = wfMessage('specialvideos-no-videos')->escaped(); } else { $this->loadMore = wfMessage('specialvideos-btn-load-more')->text(); } } else { $pagination = $helper->getPagination($params, $addVideo); } $this->addVideo = $addVideo; $this->pagination = $pagination; $this->sortMsg = $sortingOptions[$sortKey]; // selected sorting option to display in drop down $this->sortingOptions = $sortingOptions; // populate the drop down $this->videos = $videos; $this->message = $message; // permission checking for video removal $this->isRemovalAllowed = $this->wg->User->isAllowed('specialvideosdelete') && $this->app->checkSkin('oasis'); /* * Check to see if user is part of videoupload * For the purpose of hiding the appropriate UI elements * Current elements affected: last page of results in Special:Videos */ $this->showAddVideoBtn = $this->wg->User->isAllowed('videoupload'); }