public function show() { $page = $this->page; $request = $this->getRequest(); $user = $this->getUser(); $context = $this->getContext(); if (wfRunHooks('CustomEditor', array($page, $user))) { if (ExternalEdit::useExternalEngine($context, 'edit') && $this->getName() == 'edit' && !$request->getVal('section') && !$request->getVal('oldid')) { $extedit = new ExternalEdit($context); $extedit->execute(); } else { $editor = new EditPage($page); $editor->edit(); } } }
public function show() { $page = $this->page; $request = $this->getRequest(); $user = $this->getUser(); $context = $this->getContext(); if (wfRunHooks('CustomEditor', array($page, $user))) { if (ExternalEdit::useExternalEngine($context, 'edit') && $this->getName() == 'edit' && !$request->getVal('section') && !$request->getVal('oldid')) { $extedit = new ExternalEdit($context); $extedit->execute(); } else { $editor = new EditPage($page); /* Wikia change begin - @author: macbre */ /* Allow extensions to change EditPage class used for rendering edit pages */ wfRunHooks('AlternateEditPageClass', array(&$editor)); /* Wikia change - end */ $editor->edit(); } } }
/** * Perform one of the "standard" actions */ function performAction(&$output, &$article, &$title, &$user, &$request) { wfProfileIn('MediaWiki::performAction'); $action = $this->getVal('Action'); if (in_array($action, $this->getVal('DisabledActions', array()))) { /* No such action; this will switch to the default case */ $action = 'nosuchaction'; } switch ($action) { case 'view': $output->setSquidMaxage($this->getVal('SquidMaxage')); $article->view(); break; case 'watch': case 'unwatch': case 'delete': case 'revert': case 'rollback': case 'protect': case 'unprotect': case 'info': case 'markpatrolled': case 'render': case 'deletetrackback': case 'purge': $article->{$action}(); break; case 'print': $article->view(); break; case 'dublincore': if (!$this->getVal('EnableDublinCoreRdf')) { wfHttpError(403, 'Forbidden', wfMsg('nodublincore')); } else { require_once 'includes/Metadata.php'; wfDublinCoreRdf($article); } break; case 'creativecommons': if (!$this->getVal('EnableCreativeCommonsRdf')) { wfHttpError(403, 'Forbidden', wfMsg('nocreativecommons')); } else { require_once 'includes/Metadata.php'; wfCreativeCommonsRdf($article); } break; case 'credits': require_once 'includes/Credits.php'; showCreditsPage($article); break; case 'submit': if (!$this->getVal('CommandLineMode') && !$request->checkSessionCookie()) { /* Send a cookie so anons get talk message notifications */ User::SetupSession(); } /* Continue... */ /* Continue... */ case 'edit': $internal = $request->getVal('internaledit'); $external = $request->getVal('externaledit'); $section = $request->getVal('section'); $oldid = $request->getVal('oldid'); if (!$this->getVal('UseExternalEditor') || $action == 'submit' || $internal || $section || $oldid || !$user->getOption('externaleditor') && !$external) { $editor = new EditPage($article); $editor->submit(); } elseif ($this->getVal('UseExternalEditor') && ($external || $user->getOption('externaleditor'))) { $mode = $request->getVal('mode'); $extedit = new ExternalEdit($article, $mode); $extedit->edit(); } break; case 'history': if ($_SERVER['REQUEST_URI'] == $title->getInternalURL('action=history')) { $output->setSquidMaxage($this->getVal('SquidMaxage')); } $history = new PageHistory($article); $history->history(); break; case 'raw': $raw = new RawPage($article); $raw->view(); break; default: if (wfRunHooks('UnknownAction', array($action, $article))) { $output->showErrorPage('nosuchaction', 'nosuchactiontext'); } } wfProfileOut('MediaWiki::performAction'); }
function showDiffPage($diffOnly = false) { wfProfileIn(__METHOD__); # Allow frames except in certain special cases $out = $this->getOutput(); $out->allowClickjacking(); $out->setRobotPolicy('noindex,nofollow'); if (!$this->loadRevisionData()) { $this->showMissingRevision(); wfProfileOut(__METHOD__); return; } $user = $this->getUser(); $permErrors = $this->mNewPage->getUserPermissionsErrors('read', $user); if ($this->mOldPage) { # mOldPage might not be set, see below. $permErrors = wfMergeErrorArrays($permErrors, $this->mOldPage->getUserPermissionsErrors('read', $user)); } if (count($permErrors)) { wfProfileOut(__METHOD__); throw new PermissionsError('read', $permErrors); } # If external diffs are enabled both globally and for the user, # we'll use the application/x-external-editor interface to call # an external diff tool like kompare, kdiff3, etc. if (ExternalEdit::useExternalEngine($this->getContext(), 'diff')) { //TODO: come up with a good solution for non-text content here. // at least, the content format needs to be passed to the client somehow. // Currently, action=raw will just fail for non-text content. $urls = array('File' => array('Extension' => 'wiki', 'URL' => $this->mNewPage->getCanonicalURL(array('action' => 'raw', 'oldid' => $this->mOldid))), 'File2' => array('Extension' => 'wiki', 'URL' => $this->mNewPage->getCanonicalURL(array('action' => 'raw', 'oldid' => $this->mNewid)))); $externalEditor = new ExternalEdit($this->getContext(), $urls); $externalEditor->execute(); wfProfileOut(__METHOD__); return; } $rollback = ''; $undoLink = ''; $query = array(); # Carry over 'diffonly' param via navigation links if ($diffOnly != $user->getBoolOption('diffonly')) { $query['diffonly'] = $diffOnly; } # Cascade unhide param in links for easy deletion browsing if ($this->unhide) { $query['unhide'] = 1; } # Check if one of the revisions is deleted/suppressed $deleted = $suppressed = false; $allowed = $this->mNewRev->userCan(Revision::DELETED_TEXT, $user); # mOldRev is false if the difference engine is called with a "vague" query for # a diff between a version V and its previous version V' AND the version V # is the first version of that article. In that case, V' does not exist. if ($this->mOldRev === false) { $out->setPageTitle($this->msg('difference-title', $this->mNewPage->getPrefixedText())); $samePage = true; $oldHeader = ''; } else { wfRunHooks('DiffViewHeader', array($this, $this->mOldRev, $this->mNewRev)); $sk = $this->getSkin(); if (method_exists($sk, 'suppressQuickbar')) { $sk->suppressQuickbar(); } if ($this->mNewPage->equals($this->mOldPage)) { $out->setPageTitle($this->msg('difference-title', $this->mNewPage->getPrefixedText())); $samePage = true; } else { $out->setPageTitle($this->msg('difference-title-multipage', $this->mOldPage->getPrefixedText(), $this->mNewPage->getPrefixedText())); $out->addSubtitle($this->msg('difference-multipage')); $samePage = false; } if ($samePage && $this->mNewPage->quickUserCan('edit', $user)) { if ($this->mNewRev->isCurrent() && $this->mNewPage->userCan('rollback', $user)) { $out->preventClickjacking(); $rollback = '   ' . Linker::generateRollback($this->mNewRev, $this->getContext()); } if (!$this->mOldRev->isDeleted(Revision::DELETED_TEXT) && !$this->mNewRev->isDeleted(Revision::DELETED_TEXT)) { $undoLink = ' ' . $this->msg('parentheses')->rawParams(Html::element('a', array('href' => $this->mNewPage->getLocalUrl(array('action' => 'edit', 'undoafter' => $this->mOldid, 'undo' => $this->mNewid)), 'title' => Linker::titleAttrib('undo')), $this->msg('editundo')->text()))->escaped(); } } # Make "previous revision link" if ($samePage && $this->mOldRev->getPrevious()) { $prevlink = Linker::linkKnown($this->mOldPage, $this->msg('previousdiff')->escaped(), array('id' => 'differences-prevlink'), array('diff' => 'prev', 'oldid' => $this->mOldid) + $query); } else { $prevlink = ' '; } if ($this->mOldRev->isMinor()) { $oldminor = ChangesList::flag('minor'); } else { $oldminor = ''; } $ldel = $this->revisionDeleteLink($this->mOldRev); $oldRevisionHeader = $this->getRevisionHeader($this->mOldRev, 'complete'); $oldHeader = '<div id="mw-diff-otitle1"><strong>' . $oldRevisionHeader . '</strong></div>' . '<div id="mw-diff-otitle2">' . Linker::revUserTools($this->mOldRev, !$this->unhide) . '</div>' . '<div id="mw-diff-otitle3">' . $oldminor . Linker::revComment($this->mOldRev, !$diffOnly, !$this->unhide) . $ldel . '</div>' . '<div id="mw-diff-otitle4">' . $prevlink . '</div>'; if ($this->mOldRev->isDeleted(Revision::DELETED_TEXT)) { $deleted = true; // old revisions text is hidden if ($this->mOldRev->isDeleted(Revision::DELETED_RESTRICTED)) { $suppressed = true; // also suppressed } } # Check if this user can see the revisions if (!$this->mOldRev->userCan(Revision::DELETED_TEXT, $user)) { $allowed = false; } } # Make "next revision link" # Skip next link on the top revision if ($samePage && !$this->mNewRev->isCurrent()) { $nextlink = Linker::linkKnown($this->mNewPage, $this->msg('nextdiff')->escaped(), array('id' => 'differences-nextlink'), array('diff' => 'next', 'oldid' => $this->mNewid) + $query); } else { $nextlink = ' '; } if ($this->mNewRev->isMinor()) { $newminor = ChangesList::flag('minor'); } else { $newminor = ''; } # Handle RevisionDelete links... $rdel = $this->revisionDeleteLink($this->mNewRev); $newRevisionHeader = $this->getRevisionHeader($this->mNewRev, 'complete') . $undoLink; $newHeader = '<div id="mw-diff-ntitle1"><strong>' . $newRevisionHeader . '</strong></div>' . '<div id="mw-diff-ntitle2">' . Linker::revUserTools($this->mNewRev, !$this->unhide) . " {$rollback}</div>" . '<div id="mw-diff-ntitle3">' . $newminor . Linker::revComment($this->mNewRev, !$diffOnly, !$this->unhide) . $rdel . '</div>' . '<div id="mw-diff-ntitle4">' . $nextlink . $this->markPatrolledLink() . '</div>'; if ($this->mNewRev->isDeleted(Revision::DELETED_TEXT)) { $deleted = true; // new revisions text is hidden if ($this->mNewRev->isDeleted(Revision::DELETED_RESTRICTED)) { $suppressed = true; } // also suppressed } # If the diff cannot be shown due to a deleted revision, then output # the diff header and links to unhide (if available)... if ($deleted && (!$this->unhide || !$allowed)) { $this->showDiffStyle(); $multi = $this->getMultiNotice(); $out->addHTML($this->addHeader('', $oldHeader, $newHeader, $multi)); if (!$allowed) { $msg = $suppressed ? 'rev-suppressed-no-diff' : 'rev-deleted-no-diff'; # Give explanation for why revision is not visible $out->wrapWikiMsg("<div id='mw-{$msg}' class='mw-warning plainlinks'>\n\$1\n</div>\n", array($msg)); } else { # Give explanation and add a link to view the diff... $link = $this->getTitle()->getFullUrl($this->getRequest()->appendQueryValue('unhide', '1', true)); $msg = $suppressed ? 'rev-suppressed-unhide-diff' : 'rev-deleted-unhide-diff'; $out->wrapWikiMsg("<div id='mw-{$msg}' class='mw-warning plainlinks'>\n\$1\n</div>\n", array($msg, $link)); } # Otherwise, output a regular diff... } else { # Add deletion notice if the user is viewing deleted content $notice = ''; if ($deleted) { $msg = $suppressed ? 'rev-suppressed-diff-view' : 'rev-deleted-diff-view'; $notice = "<div id='mw-{$msg}' class='mw-warning plainlinks'>\n" . $this->msg($msg)->parse() . "</div>\n"; } $this->showDiff($oldHeader, $newHeader, $notice); if (!$diffOnly) { $this->renderNewRevision(); } } wfProfileOut(__METHOD__); }
/** * Perform one of the "standard" actions * * @param $output OutputPage * @param $article Article * @param $title Title * @param $user User * @param $request WebRequest */ function performAction(&$output, &$article, &$title, &$user, &$request) { wfProfileIn(__METHOD__); if (!wfRunHooks('MediaWikiPerformAction', array($output, $article, $title, $user, $request, $this))) { wfProfileOut(__METHOD__); return; } $action = $this->getVal('Action'); if (in_array($action, $this->getVal('DisabledActions', array()))) { /* No such action; this will switch to the default case */ $action = 'nosuchaction'; } // Workaround for bug #20966: inability of IE to provide an action dependent // on which submit button is clicked. if ($action === 'historysubmit') { if ($request->getBool('revisiondelete')) { $action = 'revisiondelete'; } else { $action = 'view'; } } switch ($action) { case 'view': $output->setSquidMaxage($this->getVal('SquidMaxage')); $article->view(); break; case 'raw': // includes JS/CSS wfProfileIn(__METHOD__ . '-raw'); $raw = new RawPage($article); $raw->view(); wfProfileOut(__METHOD__ . '-raw'); break; case 'watch': case 'unwatch': case 'delete': case 'revert': case 'rollback': case 'protect': case 'unprotect': case 'info': case 'markpatrolled': case 'render': case 'deletetrackback': case 'purge': $article->{$action}(); break; case 'print': $article->view(); break; case 'dublincore': if (!$this->getVal('EnableDublinCoreRdf')) { wfHttpError(403, 'Forbidden', wfMsg('nodublincore')); } else { $rdf = new DublinCoreRdf($article); $rdf->show(); } break; case 'creativecommons': if (!$this->getVal('EnableCreativeCommonsRdf')) { wfHttpError(403, 'Forbidden', wfMsg('nocreativecommons')); } else { $rdf = new CreativeCommonsRdf($article); $rdf->show(); } break; case 'credits': Credits::showPage($article); break; case 'submit': if (session_id() == '') { /* Send a cookie so anons get talk message notifications */ wfSetupSession(); } /* Continue... */ /* Continue... */ case 'edit': case 'editredlink': if (wfRunHooks('CustomEditor', array($article, $user))) { $internal = $request->getVal('internaledit'); $external = $request->getVal('externaledit'); $section = $request->getVal('section'); $oldid = $request->getVal('oldid'); if (!$this->getVal('UseExternalEditor') || $action == 'submit' || $internal || $section || $oldid || !$user->getOption('externaleditor') && !$external) { $editor = new EditPage($article); $editor->submit(); } elseif ($this->getVal('UseExternalEditor') && ($external || $user->getOption('externaleditor'))) { $mode = $request->getVal('mode'); $extedit = new ExternalEdit($article, $mode); $extedit->edit(); } } break; case 'history': if ($request->getFullRequestURL() == $title->getInternalURL('action=history')) { $output->setSquidMaxage($this->getVal('SquidMaxage')); } $history = new HistoryPage($article); $history->history(); break; case 'revisiondelete': // For show/hide submission from history page $special = SpecialPage::getPage('Revisiondelete'); $special->execute(''); break; default: if (wfRunHooks('UnknownAction', array($action, $article))) { $output->showErrorPage('nosuchaction', 'nosuchactiontext'); } } wfProfileOut(__METHOD__); }
} # Continue... # Continue... case 'edit': $internal = $wgRequest->getVal('internaledit'); $external = $wgRequest->getVal('externaledit'); $section = $wgRequest->getVal('section'); $oldid = $wgRequest->getVal('oldid'); if (!$wgUseExternalEditor || $action == 'submit' || $internal || $section || $oldid || !$wgUser->getOption('externaleditor') && !$external) { require_once 'includes/EditPage.php'; $editor = new EditPage($wgArticle); $editor->submit(); } elseif ($wgUseExternalEditor && ($external || $wgUser->getOption('externaleditor'))) { require_once 'includes/ExternalEdit.php'; $mode = $wgRequest->getVal('mode'); $extedit = new ExternalEdit($wgArticle, $mode); $extedit->edit(); } break; case 'history': if ($_SERVER['REQUEST_URI'] == $wgTitle->getInternalURL('action=history')) { $wgOut->setSquidMaxage($wgSquidMaxage); } require_once 'includes/PageHistory.php'; $history = new PageHistory($wgArticle); $history->history(); break; case 'raw': require_once 'includes/RawPage.php'; $raw = new RawPage($wgArticle); $raw->view();
/** * Perform one of the "standard" actions */ function performAction(&$output, &$article, &$title, &$user, &$request) { wfProfileIn('MediaWiki::performAction'); if (!wfRunHooks('MediaWikiPerformAction', array($output, $article, $title, $user, $request))) { wfProfileOut('MediaWiki::performAction'); return; } $action = $this->getVal('Action'); if (in_array($action, $this->getVal('DisabledActions', array()))) { /* No such action; this will switch to the default case */ $action = 'nosuchaction'; } switch ($action) { case 'view': $output->setSquidMaxage($this->getVal('SquidMaxage')); $article->view(); break; case 'watch': case 'unwatch': case 'delete': case 'revert': case 'rollback': case 'protect': case 'unprotect': case 'info': case 'markpatrolled': case 'render': case 'deletetrackback': case 'purge': $article->{$action}(); break; case 'print': $article->view(); break; case 'dublincore': if (!$this->getVal('EnableDublinCoreRdf')) { wfHttpError(403, 'Forbidden', wfMsg('nodublincore')); } else { require_once 'includes/Metadata.php'; wfDublinCoreRdf($article); } break; case 'creativecommons': if (!$this->getVal('EnableCreativeCommonsRdf')) { wfHttpError(403, 'Forbidden', wfMsg('nocreativecommons')); } else { require_once 'includes/Metadata.php'; wfCreativeCommonsRdf($article); } break; case 'credits': require_once 'includes/Credits.php'; showCreditsPage($article); break; case 'submit': case 'submit2': if (session_id() == '') { /* Send a cookie so anons get talk message notifications */ wfSetupSession(); } /* Continue... */ /* Continue... */ case 'edit': if (wfRunHooks('CustomEditor', array($article, $user))) { $internal = $request->getVal('internaledit'); $external = $request->getVal('externaledit'); $section = $request->getVal('section'); $oldid = $request->getVal('oldid'); ///------------------------------------------- // XXADDED // do we have a title? if not, it's a new article, use the wrapper. if ($request->getVal('advanced') != 'true') { $newArticle = false; // if it's not new, is it already a wikiHow? $validWikiHow = false; if ($title->getNamespace() == NS_MAIN && $request->getVal('section', null) == null) { if ($request->getVal("title") == "") { $newArticle = true; } else { if ($title->getArticleID() == 0) { $newArticle = true; } } if (!$newArticle) { $validWikiHow = WikihowArticleEditor::useWrapperForEdit($article); } } // use the wrapper if it's a new article or // if it's an existing wikiHow article $t = $request->getVal('title', null); $editor = $user->getOption('defaulteditor', ''); if (empty($editor)) { $editor = $user->getOption('useadvanced', false) ? 'advanced' : 'visual'; } if ($t != null && $t != wfMsg('mainpage') && $editor == 'advanced' && !$request->getVal('override', null)) { // use advanced if they have already set a title // and have the default preference setting #echo "uh oh!"; } else { if ($action != "submit") { if ($newArticle || $action == 'submit2' || $validWikiHow && ($editor != 'advanced' || $request->getVal("override", "") == "yes")) { require_once 'EditPageWrapper.php'; $editor = new EditPageWrapper($article); $editor->edit(); break; } else { #echo "uh oh!"; } } } } if (!$this->getVal('UseExternalEditor') || $action == 'submit' || $internal || $section || $oldid || !$user->getOption('externaleditor') && !$external) { $editor = new EditPage($article); $editor->submit(); } elseif ($this->getVal('UseExternalEditor') && ($external || $user->getOption('externaleditor'))) { $mode = $request->getVal('mode'); $extedit = new ExternalEdit($article, $mode); $extedit->edit(); } } break; case 'history': global $wgRequest; if ($wgRequest->getFullRequestURL() == $title->getInternalURL('action=history')) { $output->setSquidMaxage($this->getVal('SquidMaxage')); } $history = new PageHistory($article); $history->history(); break; case 'raw': $raw = new RawPage($article); $raw->view(); break; default: if (wfRunHooks('UnknownAction', array($action, $article))) { $output->showErrorPage('nosuchaction', 'nosuchactiontext'); return; } } wfProfileOut('MediaWiki::performAction'); }
/** * Perform one of the "standard" actions * * @param $article Article */ private function performAction(Page $article) { global $wgSquidMaxage, $wgUseExternalEditor; wfProfileIn(__METHOD__); $request = $this->context->getRequest(); $output = $this->context->getOutput(); $title = $this->context->getTitle(); $user = $this->context->getUser(); if (!wfRunHooks('MediaWikiPerformAction', array($output, $article, $title, $user, $request, $this))) { wfProfileOut(__METHOD__); return; } $act = $this->getAction(); $action = Action::factory($act, $article); if ($action instanceof Action) { $action->show(); wfProfileOut(__METHOD__); return; } switch ($act) { case 'view': $output->setSquidMaxage($wgSquidMaxage); $article->view(); break; case 'raw': // includes JS/CSS wfProfileIn(__METHOD__ . '-raw'); $raw = new RawPage($article); $raw->view(); wfProfileOut(__METHOD__ . '-raw'); break; case 'delete': case 'protect': case 'unprotect': case 'render': $article->{$act}(); break; case 'submit': if (session_id() == '') { // Send a cookie so anons get talk message notifications wfSetupSession(); } // Continue... // Continue... case 'edit': if (wfRunHooks('CustomEditor', array($article, $user))) { $internal = $request->getVal('internaledit'); $external = $request->getVal('externaledit'); $section = $request->getVal('section'); $oldid = $request->getVal('oldid'); if (!$wgUseExternalEditor || $act == 'submit' || $internal || $section || $oldid || !$user->getOption('externaleditor') && !$external) { $editor = new EditPage($article); $editor->submit(); } elseif ($wgUseExternalEditor && ($external || $user->getOption('externaleditor'))) { $mode = $request->getVal('mode'); $extedit = new ExternalEdit($article->getTitle(), $mode); $extedit->edit(); } } break; case 'history': if ($request->getFullRequestURL() == $title->getInternalURL('action=history')) { $output->setSquidMaxage($wgSquidMaxage); } $history = new HistoryPage($article); $history->history(); break; default: if (wfRunHooks('UnknownAction', array($act, $article))) { $output->showErrorPage('nosuchaction', 'nosuchactiontext'); } } wfProfileOut(__METHOD__); }