function execute($par) { wfProfileIn(__METHOD__); global $wgOut, $wgRequest, $wgExtensionsPath, $wgStylePath; global $wgPhalanxSupportedLanguages, $wgUser, $wgTitle; // check restrictions if (!$this->userCanExecute($wgUser)) { $this->displayRestrictionError(); wfProfileOut(__METHOD__); return; } $this->setHeaders(); $wgOut->addStyle("{$wgExtensionsPath}/wikia/Phalanx/css/Phalanx.css"); $wgOut->addScript("<script type='text/javascript' src='{$wgExtensionsPath}/wikia/Phalanx/js/Phalanx.js'></script>\n"); $wgOut->addExtensionStyle("{$wgStylePath}/common/wikia_ui/tabs.css"); $wgOut->setPageTitle(wfMsg('phalanx-title')); $template = new EasyTemplate(dirname(__FILE__) . '/templates'); $pager = new PhalanxPager(); $listing = $pager->getNavigationBar(); $listing .= $pager->getBody(); $listing .= $pager->getNavigationBar(); $data = $this->prefillForm(); $template->set_vars(array('expiries' => Phalanx::getExpireValues(), 'languages' => $wgPhalanxSupportedLanguages, 'listing' => $listing, 'data' => $data, 'action' => $wgTitle->getFullURL(), 'showEmail' => $wgUser->isAllowed('phalanxemailblock'))); $wgOut->addHTML($template->render('phalanx')); wfProfileOut(__METHOD__); }
/** * 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__); }