Пример #1
0
 /**
  * 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');
 }
Пример #2
0
 /**
  * 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__);
 }
Пример #3
0
 /**
  * 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');
 }
Пример #4
0
                     $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();
                 break;
             case 'purge':
                 wfPurgeSquidServers(array($wgTitle->getInternalURL()));
                 $wgOut->setSquidMaxage($wgSquidMaxage);
                 $wgTitle->invalidateCache();
                 $wgArticle->view();
                 break;
             default:
                 if (wfRunHooks('UnknownAction', array($action, $wgArticle))) {
                     $wgOut->errorpage('nosuchaction', 'nosuchactiontext');
                 }
         }
     }
 }
Пример #5
0
 /**
  * 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__);
 }