protected function parseFormData()
 {
     global $wgRequest;
     // create EditPage object
     $this->createEditPage($this->mFormData['postBody']);
     if (!count($this->mFormErrors) && $wgRequest->getVal('wpPreview')) {
         // preview mode
         $this->mEditPage->formtype = 'preview';
         $this->mPreviewTitle = Title::newFromText($this->mFormData['postTitle']);
         // simple hack to show correct title in preview mode
         global $wgCustomTitle;
         $wgCustomTitle = $this->mPreviewTitle;
         // CategorySelect compatibility (add categories to article body)
         if ($this->mCategorySelectEnabled) {
             CategorySelectImportFormData($this->mEditPage, $wgRequest);
         }
     }
 }
 protected function parseFormData()
 {
     global $wgUser, $wgRequest, $wgOut;
     wfRunHooks('BlogsAlternateEdit', array(false));
     $this->mFormData['postId'] = $wgRequest->getVal('blogPostId');
     $this->mFormData['postTitle'] = $wgRequest->getVal('blogPostTitle');
     $this->mFormData['postBody'] = $wgRequest->getVal('wpTextbox1');
     $this->mFormData['postEditSummary'] = $wgRequest->getVal('wpSummary');
     $this->mFormData['postCategories'] = $wgRequest->getVal('wpCategoryTextarea1');
     $this->mFormData['isVotingEnabled'] = $wgRequest->getCheck('blogPostIsVotingEnabled');
     $this->mFormData['isCommentingEnabled'] = $wgRequest->getCheck('blogPostIsCommentingEnabled');
     $this->mFormData['isExistingArticleEditAllowed'] = $wgRequest->getVal('articleEditAllowed');
     $this->mFormData['isWatched'] = $wgRequest->getCheck('wpWatchthis');
     if (empty($this->mFormData['postId'])) {
         if (empty($this->mFormData['postTitle'])) {
             $this->mFormErrors[] = wfMsg('create-blog-empty-title-error');
         } else {
             $oPostTitle = Title::newFromText($wgUser->getName() . '/' . $this->mFormData['postTitle'], NS_BLOG_ARTICLE);
             if (!$oPostTitle instanceof Title) {
                 $this->mFormErrors[] = wfMsg('create-blog-invalid-title-error');
             } else {
                 $sFragment = $oPostTitle->getFragment();
                 if (strlen($sFragment) > 0) {
                     $this->mFormErrors[] = wfMsg('create-blog-invalid-title-error');
                 } else {
                     $this->mPostArticle = new BlogArticle($oPostTitle, 0);
                     if ($this->mPostArticle->exists() && !$this->mFormData['isExistingArticleEditAllowed']) {
                         $this->mFormErrors[] = wfMsg('create-blog-article-already-exists');
                     }
                 }
             }
         }
     } else {
         // we have an article id
         $isAllowed = $wgUser->isAllowed("blog-articles-edit");
         $oPostTitle = Title::newFromID($this->mFormData['postId']);
         $this->mPostArticle = new BlogArticle($oPostTitle, 0);
         if (strtolower($wgUser->getName()) != strtolower(BlogArticle::getOwner($oPostTitle)) && !$isAllowed) {
             $this->mFormErrors[] = wfMsg('create-blog-permission-denied');
         }
     }
     if (empty($this->mFormData['postBody'])) {
         $this->mFormErrors[] = wfMsg('create-blog-empty-post-error');
     }
     //create EditPage object
     $this->createEditPage($this->mFormData['postBody']);
     // BugId:954 - show changes
     if (!empty($this->mPostArticle)) {
         $this->mEditPage->mArticle = $this->mPostArticle;
     }
     if (!count($this->mFormErrors) && $wgRequest->getVal('wpPreview')) {
         // preview mode
         $this->mEditPage->formtype = 'preview';
         $this->mPreviewTitle = Title::newFromText($this->mFormData['postTitle']);
         //simple hack to show correct title in preview mode
         global $wgCustomTitle;
         $wgCustomTitle = $this->mPreviewTitle;
         // CategorySelect compatibility (add categories to article body)
         if ($this->mCategorySelectEnabled) {
             CategorySelectImportFormData($this->mEditPage, $wgRequest);
         }
     }
 }
 protected function save()
 {
     global $wgOut, $wgUser, $wgContLang, $wgRequest;
     // CategorySelect compatibility (add categories to article body)
     if ($this->mCategorySelectEnabled) {
         CategorySelectImportFormData($this->mEditPage, $wgRequest);
     }
     $sPostBody = $this->mEditPage->textbox1;
     $editPage = new EditPage($this->mPostArticle);
     $editPage->initialiseForm();
     $editPage->textbox1 = $sPostBody;
     $editPage->summary = isset($this->mFormData['postEditSummary']) ? $this->mFormData['postEditSummary'] : '';
     $editPage->recreate = true;
     $result = false;
     $status = $editPage->internalAttemptSave($result);
     switch ($status->value) {
         case EditPage::AS_SUCCESS_UPDATE:
         case EditPage::AS_SUCCESS_NEW_ARTICLE:
         case EditPage::AS_ARTICLE_WAS_DELETED:
             $wgOut->redirect($this->mPostArticle->getTitle()->getFullUrl());
             break;
         default:
             Wikia::log(__METHOD__, "createpage", $status);
             if ($status == EditPage::AS_READ_ONLY_PAGE_LOGGED || $status == EditPage::AS_READ_ONLY_PAGE_ANON) {
                 $sMsg = wfMsg('createpage_cant_edit');
             } else {
                 $sMsg = wfMsg('createpage_spam');
             }
             $this->mFormErrors[] = $sMsg . " ({$status})";
             global $wgCreatePageCaptchaTriggered;
             // do not display form - there is already one invoked from Captcha [RT#21902] - Marooned
             if (empty($wgCreatePageCaptchaTriggered)) {
                 $this->renderForm();
             }
             break;
     }
 }