/**
  * Show the special page
  *
  * @param $par Mixed: parameter passed to the page or null
  */
 public function execute($par)
 {
     global $wgOut, $wgUser, $wgRequest;
     // If user is blocked, s/he doesn't need to access this page
     if ($wgUser->isBlocked()) {
         $wgOut->blockedPage();
         return;
     }
     // Is the database locked?
     if (wfReadOnly()) {
         $wgOut->readOnlyPage();
         return;
     }
     // Do we have the required permissions?
     if (!$wgUser->isAllowed('createpage')) {
         $wgOut->permissionRequired('createpage');
         return;
     }
     // Set the page title, robot policies, etc.
     $this->setHeaders();
     $mainForm = new CreatePageCreateplateForm($par);
     $action = $wgRequest->getVal('action');
     if ($wgRequest->wasPosted() && $action == 'submit') {
         $mainForm->submitForm();
     } elseif ($action == 'check') {
         $mainForm->checkArticleExists($wgRequest->getVal('to_check'), true);
     } else {
         $mainForm->showForm('');
         $mainForm->showCreateplate(true);
     }
 }
function wfCreatePageRedLinks($article, $user)
{
    global $wgRequest, $wgContentNamespaces, $wgCreatePageCoverRedLinks;
    if (!$wgCreatePageCoverRedLinks) {
        return true;
    }
    $namespace = $article->getTitle()->getNamespace();
    if ($user->getOption('createpage-redlinks', 1) == 0 || !in_array($namespace, $wgContentNamespaces)) {
        return true;
    }
    // nomulti should always bypass that (this is for AdvancedEdit mode)
    if ($article->getTitle()->exists() || $wgRequest->getVal('editmode') == 'nomulti') {
        return true;
    } else {
        if ($wgRequest->getCheck('wpPreview')) {
            return true;
        }
        $mainform = new CreatePageCreateplateForm();
        $mainform->mTitle = $wgRequest->getVal('title');
        $mainform->mRedLinked = true;
        $mainform->showForm('');
        $mainform->showCreateplate(true);
        return false;
    }
}
 /**
  * Try to submit the form.
  *
  * @return Mixed: boolean false on failure, nothing on success; if
  *                everything went well, the user is redirected to their new
  *                page
  */
 function submitForm()
 {
     global $wgOut, $wgRequest, $wgServer, $wgScript, $wgScriptPath;
     // check if we are editing in red link mode
     if ($wgRequest->getCheck('wpSubmitCreateplate')) {
         $mainform = new CreatePageCreateplateForm();
         $mainform->showForm('');
         $mainform->showCreateplate();
         return false;
     } else {
         $valid = $this->checkArticleExists($wgRequest->getVal('Createtitle'));
         if ($valid != '') {
             // no title? this means overwriting Main Page...
             $mainform = new CreatePageCreateplateForm();
             $mainform->showForm($valid);
             $editor = new CreatePageMultiEditor($this->mCreateplate);
             $editor->generateForm($editor->glueArticle());
             return false;
         }
         if ($wgRequest->getCheck('wpSave')) {
             $editor = new CreatePageMultiEditor($this->mCreateplate);
             $rtitle = Title::newFromText($wgRequest->getVal('Createtitle'));
             $rarticle = new Article($rtitle, $rtitle->getArticleID());
             $editpage = new EditPage($rarticle);
             $editpage->mTitle = $rtitle;
             $editpage->mArticle = $rarticle;
             $editpage->textbox1 = CreateMultiPage::unescapeBlankMarker($editor->glueArticle());
             $editpage->minoredit = $wgRequest->getCheck('wpMinoredit');
             $editpage->watchthis = $wgRequest->getCheck('wpWatchthis');
             $editpage->summary = $wgRequest->getVal('wpSummary');
             $_SESSION['article_createplate'] = $this->mCreateplate;
             // pipe tags to pipes
             wfCreatePageUnescapeKnownMarkupTags($editpage->textbox1);
             $editpage->attemptSave();
             return false;
         } elseif ($wgRequest->getCheck('wpPreview')) {
             $mainform = new CreatePageCreatePlateForm();
             $editor = new CreatePageMultiEditor($this->mCreateplate, true);
             $content = $editor->glueArticle(true, false);
             $content_static = $editor->glueArticle(true);
             $mainform->showForm('', $content_static);
             $editor->generateForm($content);
             return false;
         } elseif ($wgRequest->getCheck('wpAdvancedEdit')) {
             $editor = new CreatePageMultiEditor($this->mCreateplate);
             $content = CreateMultiPage::unescapeBlankMarker($editor->glueArticle());
             wfCreatePageUnescapeKnownMarkupTags($content);
             $_SESSION['article_content'] = $content;
             $wgOut->redirect($wgServer . $wgScript . '?title=' . $wgRequest->getVal('Createtitle') . '&action=edit&createpage=true');
         } elseif ($wgRequest->getCheck('wpImageUpload')) {
             $mainform = new CreatePageCreatePlateForm();
             $mainform->showForm('');
             $editor = new CreatePageMultiEditor($this->mCreateplate);
             $content = $editor->glueArticle();
             $editor->generateForm($content);
         } elseif ($wgRequest->getCheck('wpCancel')) {
             if ($wgRequest->getVal('Createtitle') != '') {
                 $wgOut->redirect($wgServer . $wgScript . '?title=' . $wgRequest->getVal('Createtitle'));
             } else {
                 $wgOut->redirect($wgServer . $wgScript);
             }
         }
     }
 }