/**
  * Ajax call to Create wiki
  */
 public function CreateWiki()
 {
     wfProfileIn(__METHOD__);
     $wgRequest = $this->app->getGlobal('wgRequest');
     /* @var $wgRequest WebRequest */
     $wgDevelDomains = $this->app->getGlobal('wgDevelDomains');
     $wgUser = $this->app->getGlobal('wgUser');
     /* @var $wgUser User */
     $params = $wgRequest->getArray('data');
     //CE-315
     if ($params['wLanguage'] != self::LANG_ALL_AGES_OPT) {
         $params['wAllAges'] = null;
     }
     if (!empty($params) && (!empty($params['wikiName']) && !empty($params['wikiDomain']))) {
         // log if called with old params
         trigger_error("CreateWiki called with old params." . $params['wikiName'] . " " . $params['wikiDomain'] . " " . $wgRequest->getIP() . " " . $wgUser->getName() . " " . $wgUser->getId(), E_USER_WARNING);
     }
     if (!empty($params) && (!empty($params['wikiaName']) && !empty($params['wikiaDomain']))) {
         // log if called with old params
         trigger_error("CreateWiki called with 2nd old params." . $params['wikiaName'] . " " . $params['wikiaDomain'] . " " . $wgRequest->getIP() . " " . $wgUser->getName() . " " . $wgUser->getId(), E_USER_WARNING);
     }
     if (empty($params) || empty($params['wName']) || empty($params['wDomain']) || empty($params['wLanguage']) || (!isset($params['wVertical']) || $params['wVertical'] === '-1')) {
         // do nothing
         $this->status = 'error';
         // VOLDEV-10: Parse the HTML in the message
         $this->statusMsg = wfMessage('cnw-error-general')->parse();
         $this->statusHeader = wfMessage('cnw-error-general-heading')->escaped();
     } else {
         /*
         $stored_answer = $this->getStoredAnswer();
         if(empty($stored_answer) || $params['wAnswer'].'' !== $stored_answer.'') {
         	$this->status = 'error';
         	$this->statusMsg = wfMsgExt( 'cnw-error-bot', array('parseinline') );
         	$this->statusHeader = wfMsg( 'cnw-error-bot-header');
         	return;
         }
         */
         // check if user is logged in
         if (!$wgUser->isLoggedIn()) {
             $this->status = 'error';
             $this->statusMsg = wfMessage('cnw-error-anon-user')->parse();
             $this->statusHeader = wfMessage('cnw-error-anon-user-header')->text();
             wfProfileOut(__METHOD__);
             return;
         }
         // check if user has confirmed e-mail
         if (!$wgUser->isEmailConfirmed()) {
             $this->status = 'error';
             $this->statusMsg = wfMessage('cnw-error-unconfirmed-email')->parse();
             $this->statusHeader = wfMessage('cnw-error-unconfirmed-email-header')->text();
             wfProfileOut(__METHOD__);
             return;
         }
         // check if user is blocked
         if ($wgUser->isBlocked()) {
             $this->status = 'error';
             $this->statusMsg = wfMsg('cnw-error-blocked', $wgUser->blockedBy(), $wgUser->blockedFor(), $wgUser->getBlockId());
             $this->statusHeader = wfMsg('cnw-error-blocked-header');
             wfProfileOut(__METHOD__);
             return;
         }
         // check if user is a tor node
         if (class_exists('TorBlock') && TorBlock::isExitNode()) {
             $this->status = 'error';
             $this->statusMsg = wfMsg('cnw-error-torblock');
             $this->statusHeader = wfMsg('cnw-error-blocked-header');
             wfProfileOut(__METHOD__);
             return;
         }
         // check if user created more wikis than we allow per day
         $numWikis = $this->countCreatedWikis($wgUser->getId());
         if ($numWikis >= self::DAILY_USER_LIMIT && $wgUser->isPingLimitable() && !$wgUser->isAllowed('createwikilimitsexempt')) {
             $this->status = 'wikilimit';
             $this->statusMsg = wfMsgExt('cnw-error-wiki-limit', array('parsemag'), self::DAILY_USER_LIMIT);
             $this->statusHeader = wfMsg('cnw-error-wiki-limit-header');
             wfProfileOut(__METHOD__);
             return;
         }
         $categories = isset($params['wCategories']) ? $params['wCategories'] : array();
         $createWiki = new CreateWiki($params['wName'], $params['wDomain'], $params['wLanguage'], $params['wVertical'], $categories);
         try {
             $createWiki->create();
         } catch (Exception $ex) {
             $error_code = $ex->getCode();
             $this->status = 'backenderror';
             $this->statusMsg = wfMessage('cnw-error-general')->parse();
             $this->statusHeader = wfMessage('cnw-error-general-heading')->escaped();
             $this->error('CreateWiki: failed to create new wiki', ['code' => $error_code, 'params' => $params, 'exception' => $ex]);
             wfProfileOut(__METHOD__);
             return;
         }
         $cityId = $createWiki->getWikiInfo('city_id');
         if (isset($params['wAllAges']) && !empty($params['wAllAges'])) {
             WikiFactory::setVarByName(self::WF_WDAC_REVIEW_FLAG_NAME, $cityId, true, __METHOD__);
         }
         $this->status = 'ok';
         $this->siteName = $createWiki->getWikiInfo('sitename');
         $this->cityId = $cityId;
         $finishCreateTitle = GlobalTitle::newFromText("FinishCreate", NS_SPECIAL, $cityId);
         $this->finishCreateUrl = empty($wgDevelDomains) ? $finishCreateTitle->getFullURL() : str_replace('.wikia.com', '.' . $wgDevelDomains[0], $finishCreateTitle->getFullURL());
         $this->info('CreateWiki: completed', ['city_id' => $cityId, 'params' => $params]);
     }
     wfProfileOut(__METHOD__);
 }