function isHtml5Editable($editOK = false) { global $wgTitle, $wgRequest; $articleExists = $wgTitle->getArticleID() > 0; $action = $wgRequest->getVal('action', ''); // TODO: during initial phase, articles are only edited with h5e if they // are being created $editable = (H5E_DEBUG || !$articleExists) && (empty($action) || $action == 'view' || $editOK && $action == 'edit') && $wgTitle->getFullText() != wfMsg('mainpage') && $wgTitle->getNamespace() == NS_MAIN && hasHtml5Browser(); return $editable; }
function execute($par) { global $wgOut, $wgRequest, $wgUser, $wgLanguageCode, $wgScriptPath, $IP; $fname = "wfCreatePage"; $target = isset($par) ? $par : $wgRequest->getVal('target'); $me = Title::newFromText("CreatePage", NS_SPECIAL); $sk = $wgUser->getSkin(); $this->setHeaders(); $wgOut->addHTML("<style type='text/css' media='all'>/*<![CDATA[*/ @import '" . wfGetPad('/extensions/min/f/extensions/wikihow/createpage/createpage.css?') . WH_SITEREV . "'; /*]]>*/</style> "); $wgOut->addHTML("<script type='text/javascript' src='" . wfGetPad('/extensions/min/f/extensions/wikihow/createpage/createpage.js?') . WH_SITEREV . "'></script>"); wfLoadExtensionMessages('CreatePage'); if ($wgRequest->wasPosted() && $wgRequest->getVal('create_redirects') != null) { // has the user submitted a redirect? $source = Title::newFromText(EditPageWrapper::formatTitle($wgRequest->getVal('createpage_title'))); $p1 = Title::newFromText($wgRequest->getVal('createpage_title')); if ($wgRequest->getVal($p1->getDBKey()) == 'none' || $wgRequest->getVal($p1->getDBKey()) == null) { $editor = $wgUser->getOption('defaulteditor', ''); if (empty($editor)) { $editor = $wgUser->getOption('useadvanced', false) ? 'advanced' : 'visual'; } if ($editor == 'visual' && class_exists('Html5editor') && hasHtml5Browser()) { $wgOut->redirect($source->getFullURL() . "?create-new-article=true"); } else { if (!class_exists('ArticleCreator') || !$wgUser->getOption('articlecreator')) { $wgOut->redirect($source->getEditURL() . "&review=1"); } else { $wgOut->redirect('/Special:ArticleCreator?t=' . $source->getPartialUrl()); } } return; } else { $target = Title::newFromText($wgRequest->getVal($p1->getDBKey())); if (!$target && $source->getArticleID() > 0) { $wgOut->redirect($source->getEditURL()); return; } // add redirect to list of proposed redirects CreatePage::addProposedRedirect($source, $target); $wgOut->addWikiText(wfMsg('createpage_redirect_confirmation', $source->getText(), $target->getText(), $target->getEditURL())); $wgOut->addHTML(wfMsg('createpage_redirect_confirmation_bottom', $source->getText(), $target->getText(), $target->getEditURL())); return; } } if ($par != "" && false) { $title = Title::newFromText($par); $wgOut->addHTML(wfMsg('createpage_fromsuggestions', htmlspecialchars($title->getText()), $title->getFullURL())); return; } if ($wgRequest->wasPosted() && $wgRequest->getVal('q') != null) { $matches = SuggestionSearch::matchKeyTitles($wgRequest->getVal('q'), 30); if (count($matches) == 0) { $wgOut->addHTML(wfMsg('createpage_nomatches')); $this->outputCreatePageForm(); return; } $wgOut->addHTML("<div class='wh_block'>"); $wgOut->addHTML(wfMsg('createpage_matches')); $wgOut->addHTML("<table class='cpresults'><tr>"); for ($i = 0; $i < count($matches); $i++) { $t = Title::newFromDBkey($matches[$i][0]); if ($t) { $ep = SpecialPage::getTitleFor("CreatePage", $t->getText()); $wgOut->addHTML("<td><a href='{$ep->getFullURL()}' class='new'>{$t->getFullText()}</a></td>"); } if ($i % 3 == 2) { $wgOut->addHTML("</tr><tr>"); } } $wgOut->addHTML("</tr></table>"); $wgOut->addHTML(wfMsg('createpage_tryagain')); $wgOut->addHTML("</div>"); $this->outputCreatePageForm(); return; } if ($target != null) { $t = Title::newFromText($target); // handle formatting $t2 = null; if ($wgLanguageCode == 'en') { require_once "{$IP}/extensions/wikihow/EditPageWrapper.php"; $t2 = Title::newFromText(EditPageWrapper::formatTitle($target)); } if ($t2 && (!$t || !$t->exists())) { $t = $t2; } if ($t->getArticleID() > 0) { $r = Revision::newFromTitle($t); $text = $r->getText(); $redirect = Title::newFromRedirect($text); if ($redirect != null) { $t = $redirect; } $wgOut->addHTML('<div class="wh_block">'); $wgOut->addWikiText(wfMsg('createpage-title-exists', $t->getFullText()) . "<br/><br/>"); $wgOut->addHTML("<a href='" . $t->getEditURL() . "'>" . wfMsg('createpage-edit-existing') . "</a><br/>" . $sk->makeLinkObj($me, wfMsg('createpage-try-again'))); $wgOut->addHTML('</div>'); } else { $wgOut->addHTML('<div class="wh_block">'); $wgOut->addWikiText(wfMsg('createpage_notefollowing')); $wgOut->addHTML('</div>'); $vars = array('step1_title' => htmlspecialchars($t->getFullText()), 'related_block' => $this->getRelatedTopicsText($t)); $box = EasyTemplate::html('createpage_step1box.tmpl.php', $vars); $wgOut->addHTML($box); } return; } $this->outputCreatePageForm(); }