public function index() { $this->wf->ProfileIn(__METHOD__); $this->wg->Out->setPageTitle(wfMsg('managewikiahome')); if (!$this->checkAccess()) { $this->forward('ManageWikiaHome', 'onWrongRights'); return false; } $this->setVal('slotsInTotal', WikiaHomePageHelper::SLOTS_IN_TOTAL); //wikis with visualization selectbox $visualizationLang = $this->wg->request->getVal(self::WHST_VISUALIZATION_LANG_VAR_NAME, $this->wg->contLang->getCode()); $visualizationLang = substr(strtolower($visualizationLang), 0, 2); $this->visualizationLang = $visualizationLang; $this->visualizationWikisData = $this->helper->getVisualizationWikisData(); $this->currentPage = $this->request->getVal('page', 1); $this->corpWikiId = $this->visualizationWikisData[$this->visualizationLang]['wikiId']; //verticals slots' configuration /* @var $this->helper WikiaHomePageHelper */ $videoGamesAmount = $this->request->getVal('video-games-amount', $this->helper->getNumberOfVideoGamesSlots($this->visualizationLang)); $entertainmentAmount = $this->request->getVal('entertainment-amount', $this->helper->getNumberOfEntertainmentSlots($this->visualizationLang)); $lifestyleAmount = $this->request->getVal('lifestyle-amount', $this->helper->getNumberOfLifestyleSlots($this->visualizationLang)); $hotWikisAmount = $this->request->getVal('hot-wikis-amount', $this->helper->getNumberOfHotWikiSlots($this->visualizationLang)); $newWikisAmount = $this->request->getVal('new-wikis-amount', $this->helper->getNumberOfNewWikiSlots($this->visualizationLang)); if ($this->request->wasPosted()) { //todo: separate post request handling //todo: move validation from saveSlotsConfigInWikiFactory() to helper $total = intval($videoGamesAmount) + intval($entertainmentAmount) + intval($lifestyleAmount); if ($total !== WikiaHomePageHelper::SLOTS_IN_TOTAL) { $this->setVal('errorMsg', wfMsg('manage-wikia-home-error-invalid-total-no-of-slots', array($total, WikiaHomePageHelper::SLOTS_IN_TOTAL))); } elseif ($this->isAnySlotNumberNegative($videoGamesAmount, $entertainmentAmount, $lifestyleAmount)) { $this->setVal('errorMsg', wfMsg('manage-wikia-home-error-negative-slots-number-not-allowed')); } else { $this->saveSlotsConfigInWikiFactory($this->corpWikiId, $visualizationLang, array(WikiaHomePageHelper::VIDEO_GAMES_SLOTS_VAR_NAME => $videoGamesAmount, WikiaHomePageHelper::ENTERTAINMENT_SLOTS_VAR_NAME => $entertainmentAmount, WikiaHomePageHelper::LIFESTYLE_SLOTS_VAR_NAME => $lifestyleAmount)); } } $this->setVal('videoGamesAmount', $videoGamesAmount); $this->setVal('entertainmentAmount', $entertainmentAmount); $this->setVal('lifestyleAmount', $lifestyleAmount); $this->setVal('hotWikisAmount', $hotWikisAmount); $this->setVal('newWikisAmount', $newWikisAmount); $this->response->addAsset('/extensions/wikia/SpecialManageWikiaHome/css/ManageWikiaHome.scss'); $this->response->addAsset('/extensions/wikia/SpecialManageWikiaHome/js/ManageWikiaHome.js'); F::build('JSMessages')->enqueuePackage('ManageWikiaHome', JSMessages::EXTERNAL); $this->wf->ProfileOut(__METHOD__); }