Ejemplo n.º 1
0
 static function create($thread, $change_type, $change_object = null, $comment = '', $user = null, $timestamp = null)
 {
     if (is_null($user)) {
         global $wgUser;
         $user = $wgUser;
     }
     if (is_null($timestamp)) {
         $timestamp = wfTimestampNow();
     }
     if (is_null($comment)) {
         $comment = '';
     }
     $rev = new ThreadRevision();
     $rev->mThreadId = $thread->topmostThread()->id();
     $rev->mTimestamp = $timestamp;
     $rev->mUser = $user;
     $rev->mUserId = $user->getId();
     $rev->mUserText = $user->getName();
     $rev->mChangeType = $change_type;
     if ($change_object instanceof Thread) {
         $rev->mChangeObjectId = $change_object->id();
         $rev->mChangeObject = $change_object;
     } elseif (is_null($change_object)) {
         $rev->mChangeObjectId = $thread->id();
         $rev->mChangeObject = $thread;
     } else {
         $rev->mChangeObjectId = $change_object;
     }
     $rev->mChangeComment = $comment;
     $rev->mThreadObj = $thread->topmostThread();
     $rev->mObjSer = serialize($rev->mThreadObj);
     $rev->insert();
     return $rev;
 }
 function show()
 {
     if (!$this->thread) {
         $this->showMissingThreadPage();
         return false;
     }
     $oldid = $this->request->getInt('lqt_oldid');
     $this->mDisplayRevision = ThreadRevision::loadFromId($oldid);
     if (!$this->mDisplayRevision) {
         $this->showMissingThreadPage();
         return false;
     }
     $this->thread = $this->mDisplayRevision->getThreadObj();
     if (!$this->thread) {
         $this->output->addWikiMsg('lqt-historicalrevision-error');
         return false;
     }
     $this->showHistoryInfo();
     $this->output->addModules('ext.liquidThreads');
     $this->output->setSubtitle($this->getSubtitle());
     $changedObject = $this->mDisplayRevision->getChangeObject();
     $this->showThread($this->thread, 1, 1, array('maxDepth' => -1, 'maxCount' => -1, 'mustShowThreads' => array($changedObject->id())));
     $this->output->setPageTitle($this->thread->subject());
     return false;
 }
Ejemplo n.º 3
0
 function getActionDescription($type)
 {
     global $wgOut;
     $args = array();
     $revision = ThreadRevision::loadFromRow($this->mCurrentRow);
     $changeObject = $revision->getChangeObject();
     if ($revision && $revision->prev()) {
         $lastChangeObject = $revision->prev()->getChangeObject();
     }
     if ($changeObject && $changeObject->title()) {
         $args[] = $changeObject->title()->getPrefixedText();
     } else {
         $args[] = '';
     }
     $msg = self::$change_names[$type];
     switch ($type) {
         case Threads::CHANGE_EDITED_SUBJECT:
             if ($changeObject && $lastChangeObject) {
                 $args[] = $lastChangeObject->subject();
                 $args[] = $changeObject->subject();
             } else {
                 $msg = wfMessage('lqt_hist_edited_subject_corrupt')->parse();
             }
             break;
         case Threads::CHANGE_EDITED_ROOT:
         case Threads::CHANGE_ROOT_BLANKED:
             $view = $this->view;
             if ($changeObject && $changeObject->title()) {
                 $diffLink = $view->diffPermalinkURL($changeObject, $revision);
                 $args[] = $diffLink;
             } else {
                 $args[] = '';
                 if ($type == Threads::CHANGE_EDITED_ROOT) {
                     $msg = wfMessage('lqt_hist_comment_edited_deleted')->parse();
                 }
             }
             break;
         case Threads::CHANGE_REPLY_CREATED:
             if (!$changeObject || !$changeObject->title()) {
                 $msg = wfMessage('lqt_hist_reply_created_deleted')->parse();
             }
             break;
     }
     $content = wfMsgReplaceArgs($msg, $args);
     return Html::rawElement('span', array('class' => 'plainlinks'), $wgOut->parseInline($content));
 }
 function getActionDescription($type)
 {
     global $wgOut;
     $args = array();
     $revision = ThreadRevision::loadFromRow($this->mCurrentRow);
     $changeObject = $revision->getChangeObject();
     if ($revision && $revision->prev()) {
         $lastChangeObject = $revision->prev()->getChangeObject();
     }
     if ($changeObject && $changeObject->title()) {
         $args[] = $changeObject->title()->getPrefixedText();
     } else {
         $args[] = '';
     }
     $msg = self::$change_names[$type];
     switch ($type) {
         case Threads::CHANGE_EDITED_SUBJECT:
             if ($changeObject && $lastChangeObject) {
                 $args[] = $lastChangeObject->subject();
                 $args[] = $changeObject->subject();
             } else {
                 $msg = wfMsg('lqt_hist_edited_subject_corrupt', 'parseinline');
             }
             break;
         case Threads::CHANGE_EDITED_ROOT:
         case Threads::CHANGE_ROOT_BLANKED:
             $view = $this->view;
             if ($changeObject && $changeObject->title()) {
                 $diffLink = $view->diffPermalinkURL($changeObject, $revision);
                 $args[] = $diffLink;
             } else {
                 $args[] = '';
             }
             break;
     }
     $content = wfMsgReplaceArgs($msg, $args);
     return $wgOut->parseInline($content);
 }
Ejemplo n.º 5
0
 function commitRevision($change_type, $change_object = null, $reason = "", $bump = null)
 {
     $this->dieIfHistorical();
     global $wgUser;
     global $wgThreadActionsNoBump;
     if (is_null($bump)) {
         $bump = !in_array($change_type, $wgThreadActionsNoBump);
     }
     if ($bump) {
         $this->sortkey = wfTimestamp(TS_MW);
     }
     $original = $this->dbVersion;
     $this->modified = wfTimestampNow();
     $this->updateEditedness($change_type);
     $this->save(__METHOD__ . "/" . wfGetCaller());
     $topmost = $this->topmostThread();
     $topmost->modified = wfTimestampNow();
     if ($bump) {
         $topmost->setSortkey(wfTimestamp(TS_MW));
     }
     $topmost->save();
     ThreadRevision::create($this, $change_type, $change_object, $reason);
     $this->logChange($change_type, $original, $change_object, $reason);
     if ($change_type == Threads::CHANGE_EDITED_ROOT) {
         NewMessages::writeMessageStateForUpdatedThread($this, $change_type, $wgUser);
     }
 }