Esempio n. 1
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__);
 }
Esempio n. 2
0
 /**
  *
  * Returns the html for the box at the
  * top of NFD Guardian which contains
  * information about the current
  * article being voted on.
  *
  */
 function getArticleInfoBox()
 {
     global $wgOut;
     //first find out who the author was
     $articleInfo = $this->getArticleInfo();
     if (intval($articleInfo->fe_user) > 0) {
         $u = User::newFromId($articleInfo->fe_user);
         $userLink = $u->getUserPage()->getInternalURL();
         $userName = $u->getName();
         $cp = new ContribsPager(ContextSource::getContext(), array($userName));
         $uEdits = $cp->getNumRows();
     } else {
         $u = User::newFromName($articleInfo->fe_user_text);
         $userLink = "/User:"******"") {
         $t = Title::newFromText($nfdReason['article']);
         if ($t) {
             $nfdLongReason .= " with [[" . $t->getText() . "]]";
         }
     }
     //finally check the number of discussion items for this
     //article. We ask for confirmation for articles
     //with a lot of discussion items.
     $t = Title::newFromID($this->mResult->nfd_page);
     if ($t) {
         $a = new Article($t);
         // $pageHistory = new PageHistory($a);
         // $pager = new PageHistoryPager( $pageHistory );
         // $edits = $pager->getNumRows();
         $pageHistory = new HistoryPage($a);
         $items = $pageHistory->fetchRevisions(100000, 0, 1);
         $edits = $items->numRows();
         $discussionTitle = Title::newFromText($t->getText(), NS_TALK);
         if ($discussionTitle) {
             $discussionArticle = new Article($discussionTitle);
             // $pageHistory = new PageHistory($discussionArticle);
             // $pager = new PageHistoryPager( $pageHistory );
             // $discussion = $pager->getNumRows();
             $pageHistory = new HistoryPage($discussionArticle);
             $items = $pageHistory->fetchRevisions(100000, 0, 1);
             $discussion = $items->numRows();
         } else {
             $discussion = 0;
         }
     }
     $articleInfo = $this->getArticleInfo();
     $tmpl = new EasyTemplate(dirname(__FILE__));
     $tmpl->set_vars(array('age' => wfTimeAgo($this->mResult->nfd_fe_timestamp), 'authorUrl' => $userLink, 'authorName' => $userName, 'views' => $articleInfo->page_counter, 'nfd' => $wgOut->parse($nfdLongReason), 'edits' => $edits, 'userEdits' => $uEdits, 'nfdVotes' => $this->getTotalVotes($this->mResult->nfd_id), 'discussion' => $discussion));
     $html = $tmpl->execute('NFDinfo.tmpl.php');
     return $html;
 }
 function get_history_disp($titleKey, $mvd_id)
 {
     global $mvgIP, $wgOut;
     $title = Title::newFromText($titleKey, MV_NS_MVD);
     $article = new Article($title);
     $pageHistoryAjax = new HistoryPage($article);
     // @@todo fix problems... ajax action url context !=history url context
     // so forming urls for links get errors
     $pageHistoryAjax->history();
     return $wgOut->getHTML();
 }
Esempio n. 4
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__);
 }