public function execute()
 {
     global $wgRequest, $wgUser;
     $wgRequest->setVal('action', 'edit');
     // force CategorySelect initialisation if available
     if (function_exists('CategorySelectInit') && function_exists('CategorySelectInitializeHooks') && $wgUser->getOption('disablecategoryselect', false) == false) {
         $this->mCategorySelectEnabled = true;
         $FORCE_INIT = true;
         CategorySelectInit($FORCE_INIT);
         CategorySelectInitializeHooks(null, null, $this->mTitle, null, null, null);
     }
 }
 public function execute()
 {
     global $wgOut, $wgUser, $wgRequest, $wgTitle;
     if (!$wgUser->isLoggedIn()) {
         $wgOut->showErrorPage('create-blog-no-login', 'create-blog-login-required', array(wfGetReturntoParam()));
         return;
     }
     if ($wgUser->isBlocked()) {
         throw new UserBlockedError($this->getUser()->mBlock);
     }
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     //nAndy: bugId:9804
     $pageId = intval($wgRequest->getVal('pageId'));
     $this->mTitle = $pageId > 0 ? Title::newFromId($pageId) : Title::makeTitle(NS_SPECIAL, 'CreateBlogPage');
     // force CategorySelect initialisation if available
     if (function_exists('CategorySelectInitializeHooks') && $wgUser->getOption('disablecategoryselect', false) == false) {
         $this->mCategorySelectEnabled = true;
         $wgRequest->setVal('action', 'edit');
         CategorySelectInit(true);
         CategorySelectInitializeHooks(null, null, $this->mTitle, null, null, null);
     }
     $wgOut->setPageTitle(wfMsg("create-blog-post-title"));
     if ($wgRequest->wasPosted()) {
         // BugId:954 - check for "show changes"
         $isShowDiff = !is_null($wgRequest->getVal('wpDiff'));
         $this->parseFormData();
         if (count($this->mFormErrors) > 0 || !empty($this->mPreviewTitle)) {
             $this->renderForm();
         } else {
             if ($isShowDiff) {
                 // watch out! there be dragons (temporary workaround)
                 $this->mEditPage->diff = true;
                 $this->mEditPage->edittime = null;
                 $this->renderForm();
             } else {
                 $this->save();
             }
         }
     } else {
         if ($wgRequest->getVal('article') != null) {
             $this->parseArticle(urldecode($wgRequest->getVal('article')));
         } else {
             if ($wgRequest->getText('preload') != null) {
                 // TOR: added preload functionality
                 $preloadTitle = Title::newFromText($wgRequest->getText('preload'));
                 if (!is_null($preloadTitle)) {
                     $preloadArticle = new Article($preloadTitle);
                     $text = $preloadArticle->getContent();
                     $this->createEditPage($text);
                 }
             } else {
                 if ($pageId > 0) {
                     //nAndy: bugId:9804 Owen: bugId:11432
                     $preloadTitle = Title::newFromId($pageId);
                     if (!is_null($preloadTitle)) {
                         $this->parseArticle($preloadTitle->getDBKey());
                     }
                 } else {
                     $this->createEditPage('');
                 }
             }
         }
         $this->renderForm();
     }
 }