public function executeIndex()
 {
     wfProfileIn(__METHOD__);
     global $wgLang, $wgOut;
     $themeSettings = new ThemeSettings();
     // current settings
     $this->themeSettings = $themeSettings->getSettings();
     // application theme settings (not user settable)
     $this->applicationThemeSettings = SassUtil::getApplicationThemeSettings();
     // recent versions
     $themeHistory = array_reverse($themeSettings->getHistory());
     // format time (for edits older than 30 days - show timestamp)
     foreach ($themeHistory as &$entry) {
         $diff = time() - strtotime($entry['timestamp']);
         if ($diff < 30 * 86400) {
             $entry['timeago'] = wfTimeFormatAgo($entry['timestamp']);
         } else {
             $entry['timeago'] = $wgLang->date($entry['timestamp']);
         }
     }
     $this->themeHistory = $themeHistory;
     // URL user should be redirected to when settings are saved
     if (isset($_SERVER['HTTP_REFERER'])) {
         $this->returnTo = $_SERVER['HTTP_REFERER'];
     } else {
         $this->returnTo = $this->wg->Script;
     }
     // load Google Analytics code
     $this->analytics = AnalyticsEngine::track('GA_Urchin', AnalyticsEngine::EVENT_PAGEVIEW);
     $wgOut->getResourceLoader()->getModule('mediawiki');
     $ret = implode("\n", array($wgOut->getHeadLinks(null, true), $wgOut->buildCssLinks(), $wgOut->getHeadScripts(), $wgOut->getHeadItems()));
     $this->globalVariablesScript = $ret;
     wfProfileOut(__METHOD__);
 }
 public function index()
 {
     global $wgSuppressWikiHeader, $wgSuppressPageHeader, $wgSuppressFooter, $wgSuppressAds, $wgSuppressToolbar, $fbOnLoginJsOverride, $wgRequest, $wgUser;
     wfProfileIn(__METHOD__);
     // hide some default oasis UI things
     $wgSuppressWikiHeader = true;
     $wgSuppressPageHeader = true;
     $wgSuppressFooter = false;
     $wgSuppressAds = true;
     $wgSuppressToolbar = true;
     // store the fact we're on CNW
     $this->wg->atCreateNewWikiPage = true;
     if (!$this->wg->User->isLoggedIn() && !empty($this->wg->EnableFacebookClientExt)) {
         // required for FB Connect to work
         $this->response->addAsset('extensions/wikia/UserLogin/js/UserLoginFacebookPageInit.js');
     }
     // fbconnected means user has gone through step 2 to login via facebook.
     // Therefore, we need to reload some values and start at the step after signup/login
     $fbconnected = $wgRequest->getVal('fbconnected');
     $fbreturn = $wgRequest->getVal('fbreturn');
     if (!empty($fbconnected) && $fbconnected === '1' || !empty($fbreturn) && $fbreturn === '1') {
         $this->LoadState();
         $currentStep = 'DescWiki';
     } else {
         $currentStep = '';
     }
     $this->setupVerticalsAndCategories();
     $this->aTopLanguages = explode(',', wfMsg('autocreatewiki-language-top-list'));
     $languages = wfGetFixedLanguageNames();
     asort($languages);
     $this->aLanguages = $languages;
     $useLang = $wgRequest->getVal('uselang', $wgUser->getGlobalPreference('language'));
     // squash language dialects (same wiki language for different dialects)
     $useLang = $this->squashLanguageDialects($useLang);
     // falling back to english (BugId:3538)
     if (!array_key_exists($useLang, $this->aLanguages)) {
         $useLang = 'en';
     }
     $params['wikiLanguage'] = empty($useLang) ? $this->wg->LanguageCode : $useLang;
     // precedence: selected form field, uselang, default wiki lang
     // export info if user is logged in
     $this->isUserLoggedIn = $wgUser->isLoggedIn();
     // remove wikia plus for now for all languages
     $skipWikiaPlus = true;
     $keys = CreateNewWikiObfuscate::generateValidSeeds();
     $_SESSION['cnw-answer'] = CreateNewWikiObfuscate::generateAnswer($this->keys);
     $this->wg->Out->addJsConfigVars(['wgLangAllAgesOpt' => self::LANG_ALL_AGES_OPT]);
     // prefill
     $params['wikiName'] = $wgRequest->getVal('wikiName', '');
     $params['wikiDomain'] = $wgRequest->getVal('wikiDomain', '');
     $params['LangAllAgesOpt'] = self::LANG_ALL_AGES_OPT;
     $this->params = $params;
     $this->signupUrl = '';
     $signupTitle = Title::newFromText('UserSignup', NS_SPECIAL);
     if ($wgRequest->getInt('nocaptchatest')) {
         $this->signupUrl = $signupTitle->getFullURL('nocaptchatest=1');
     } else {
         $this->signupUrl = $signupTitle->getFullURL();
     }
     // Make various parsed messages and status available in JS
     // Necessary because JSMessages does not support parsing
     $this->wikiBuilderCfg = array('name-wiki-submit-error' => wfMessage('cnw-name-wiki-submit-error')->escaped(), 'desc-wiki-submit-error' => wfMessage('cnw-desc-wiki-submit-error')->escaped(), 'currentstep' => $currentStep, 'skipwikiaplus' => $skipWikiaPlus, 'descriptionplaceholder' => wfMessage('cnw-desc-placeholder')->escaped(), 'cnw-error-general' => wfMessage('cnw-error-general')->parse(), 'cnw-error-general-heading' => wfMessage('cnw-error-general-heading')->escaped(), 'cnw-keys' => $keys);
     // theme designer application theme settings
     $this->applicationThemeSettings = SassUtil::getApplicationThemeSettings();
     wfProfileOut(__METHOD__);
 }