/**
  * @brief Adjusting recent changes for Wall
  *
  * @desc This method creates comment about revision deletion of a message on message wall
  *
  * @param ChangesList $list
  * @param RecentChange $rc
  * @param String $s
  * @param Formatter $formatter
  * @param string $mark
  *
  * @return true because this is a hook
  *
  * @author Andrzej 'nAndy' Lukaszewski
  */
 public function onChangesListInsertLogEntry($list, $rc, &$s, $formatter, &$mark)
 {
     $app = F::app();
     if ($rc->getAttribute('rc_type') == RC_LOG && in_array(MWNamespace::getSubject($rc->getAttribute('rc_namespace')), $app->wg->WallNS) && in_array($rc->getAttribute('rc_log_action'), $this->rcWallActionTypes)) {
         $actionText = '';
         $wfMsgOptsBase = $this->getMessageOptions($rc);
         $wfMsgOpts = array($wfMsgOptsBase['articleUrl'], $wfMsgOptsBase['articleTitleTxt'], $wfMsgOptsBase['wallPageUrl'], $wfMsgOptsBase['wallPageName'], $wfMsgOptsBase['actionUser']);
         $msgType = $wfMsgOptsBase['isThread'] ? 'thread' : 'reply';
         //created in WallHooksHelper::getMessageOptions()
         //and there is not needed to be passed to wfMsg()
         unset($wfMsgOpts['isThread'], $wfMsgOpts['isNew']);
         switch ($rc->getAttribute('rc_log_action')) {
             case 'wall_remove':
                 $actionText = wfMsgExt($this->getMessagePrefix($rc->getAttribute('rc_namespace')) . '-removed-' . $msgType, array('parseinline'), $wfMsgOpts);
                 break;
             case 'wall_restore':
                 $actionText = wfMsgExt($this->getMessagePrefix($rc->getAttribute('rc_namespace')) . '-restored-' . $msgType, array('parseinline'), $wfMsgOpts);
                 break;
             case 'wall_admindelete':
                 $actionText = wfMsgExt($this->getMessagePrefix($rc->getAttribute('rc_namespace')) . '-deleted-' . $msgType, array('parseinline'), $wfMsgOpts);
                 break;
             case 'wall_archive':
                 $actionText = wfMsgExt($this->getMessagePrefix($rc->getAttribute('rc_namespace')) . '-closed-thread', array('parseinline'), $wfMsgOpts);
                 break;
             case 'wall_reopen':
                 $actionText = wfMsgExt($this->getMessagePrefix($rc->getAttribute('rc_namespace')) . '-reopened-thread', array('parseinline'), $wfMsgOpts);
                 break;
             default:
                 $actionText = wfMsg($this->getMessagePrefix($rc->getAttribute('rc_namespace')) . '-unrecognized-log-action', $wfMsgOpts);
                 break;
         }
         $s = '';
         $list->insertUserRelatedLinks($s, $rc);
         $s .= ' ' . $actionText . ' ' . $list->insertComment($rc);
     }
     return true;
 }
示例#2
0
 /**
  * Enhanced RC group
  */
 protected function recentChangesBlockGroup($block)
 {
     global $wgLang, $wgContLang, $wgRCShowChangedSize;
     $r = '<table cellpadding="0" cellspacing="0" border="0" style="background: none"><tr>';
     # Collate list of users
     $userlinks = array();
     # Other properties
     $unpatrolled = false;
     $isnew = false;
     $curId = $currentRevision = 0;
     # Some catalyst variables...
     $namehidden = true;
     $allLogs = true;
     foreach ($block as $rcObj) {
         $oldid = $rcObj->mAttribs['rc_last_oldid'];
         if ($rcObj->mAttribs['rc_new']) {
             $isnew = true;
         }
         // If all log actions to this page were hidden, then don't
         // give the name of the affected page for this block!
         if (!$this->isDeleted($rcObj, LogPage::DELETED_ACTION)) {
             $namehidden = false;
         }
         $u = $rcObj->userlink;
         if (!isset($userlinks[$u])) {
             $userlinks[$u] = 0;
         }
         if ($rcObj->unpatrolled) {
             $unpatrolled = true;
         }
         if ($rcObj->mAttribs['rc_type'] != RC_LOG) {
             $allLogs = false;
         }
         # Get the latest entry with a page_id and oldid
         # since logs may not have these.
         if (!$curId && $rcObj->mAttribs['rc_cur_id']) {
             $curId = $rcObj->mAttribs['rc_cur_id'];
         }
         if (!$currentRevision && $rcObj->mAttribs['rc_this_oldid']) {
             $currentRevision = $rcObj->mAttribs['rc_this_oldid'];
         }
         $bot = $rcObj->mAttribs['rc_bot'];
         $userlinks[$u]++;
     }
     # Sort the list and convert to text
     krsort($userlinks);
     asort($userlinks);
     $users = array();
     foreach ($userlinks as $userlink => $count) {
         $text = $userlink;
         $text .= $wgContLang->getDirMark();
         if ($count > 1) {
             $text .= ' (' . $wgLang->formatNum($count) . '×)';
         }
         array_push($users, $text);
     }
     $users = ' <span class="changedby">[' . implode($this->message['semicolon-separator'], $users) . ']</span>';
     # ID for JS visibility toggle
     $jsid = $this->rcCacheIndex;
     # onclick handler to toggle hidden/expanded
     $toggleLink = "onclick='toggleVisibility({$jsid}); return false'";
     # Title for <a> tags
     $expandTitle = htmlspecialchars(wfMsg('rc-enhanced-expand'));
     $closeTitle = htmlspecialchars(wfMsg('rc-enhanced-hide'));
     $tl = "<span id='mw-rc-openarrow-{$jsid}' class='mw-changeslist-expanded' style='visibility:hidden'><a href='#' {$toggleLink} title='{$expandTitle}'>" . $this->sideArrow() . "</a></span>";
     $tl .= "<span id='mw-rc-closearrow-{$jsid}' class='mw-changeslist-hidden' style='display:none'><a href='#' {$toggleLink} title='{$closeTitle}'>" . $this->downArrow() . "</a></span>";
     $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $tl . '&nbsp;';
     # Main line
     $r .= $this->recentChangesFlags($isnew, false, $unpatrolled, '&nbsp;', $bot);
     # Timestamp
     $r .= '&nbsp;' . $block[0]->timestamp . '&nbsp;</tt></td><td>';
     # Article link
     if ($namehidden) {
         $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>';
     } else {
         if ($allLogs) {
             $r .= $this->maybeWatchedLink($block[0]->link, $block[0]->watched);
         } else {
             $this->insertArticleLink($r, $block[0], $block[0]->unpatrolled, $block[0]->watched);
         }
     }
     $r .= $wgContLang->getDirMark();
     $curIdEq = 'curid=' . $curId;
     # Changes message
     $n = count($block);
     static $nchanges = array();
     if (!isset($nchanges[$n])) {
         $nchanges[$n] = wfMsgExt('nchanges', array('parsemag', 'escape'), $wgLang->formatNum($n));
     }
     # Total change link
     $r .= ' ';
     if (!$allLogs) {
         $r .= '(';
         if (!ChangesList::userCan($rcObj, Revision::DELETED_TEXT)) {
             $r .= $nchanges[$n];
         } else {
             if ($isnew) {
                 $r .= $nchanges[$n];
             } else {
                 $r .= $this->skin->makeKnownLinkObj($block[0]->getTitle(), $nchanges[$n], $curIdEq . "&diff={$currentRevision}&oldid={$oldid}");
             }
         }
     }
     # History
     if ($allLogs) {
         // don't show history link for logs
     } else {
         if ($namehidden || !$block[0]->getTitle()->exists()) {
             $r .= $this->message['semicolon-separator'] . $this->message['hist'] . ')';
         } else {
             $r .= $this->message['semicolon-separator'] . $this->skin->makeKnownLinkObj($block[0]->getTitle(), $this->message['hist'], $curIdEq . '&action=history') . ')';
         }
     }
     $r .= ' . . ';
     # Character difference (does not apply if only log items)
     if ($wgRCShowChangedSize && !$allLogs) {
         $last = 0;
         $first = count($block) - 1;
         # Some events (like logs) have an "empty" size, so we need to skip those...
         while ($last < $first && $block[$last]->mAttribs['rc_new_len'] === NULL) {
             $last++;
         }
         while ($first > $last && $block[$first]->mAttribs['rc_old_len'] === NULL) {
             $first--;
         }
         # Get net change
         $chardiff = $rcObj->getCharacterDifference($block[$first]->mAttribs['rc_old_len'], $block[$last]->mAttribs['rc_new_len']);
         if ($chardiff == '') {
             $r .= ' ';
         } else {
             $r .= ' ' . $chardiff . ' . . ';
         }
     }
     $r .= $users;
     $r .= $this->numberofWatchingusers($block[0]->numberofWatchingusers);
     $r .= "</td></tr></table>\n";
     # Sub-entries
     $r .= '<div id="mw-rc-subentries-' . $jsid . '" class="mw-changeslist-hidden">';
     $r .= '<table cellpadding="0" cellspacing="0"  border="0" style="background: none">';
     foreach ($block as $rcObj) {
         # Extract fields from DB into the function scope (rc_xxxx variables)
         // FIXME: Would be good to replace this extract() call with something
         // that explicitly initializes variables.
         extract($rcObj->mAttribs);
         #$r .= '<tr><td valign="top">'.$this->spacerArrow();
         $r .= '<tr><td valign="top">';
         $r .= '<tt>' . $this->spacerIndent() . $this->spacerIndent();
         $r .= $this->recentChangesFlags($rc_new, $rc_minor, $rcObj->unpatrolled, '&nbsp;', $rc_bot);
         $r .= '&nbsp;</tt></td><td valign="top">';
         $o = '';
         if ($rc_this_oldid != 0) {
             $o = 'oldid=' . $rc_this_oldid;
         }
         # Log timestamp
         if ($rc_type == RC_LOG) {
             $link = '<tt>' . $rcObj->timestamp . '</tt> ';
             # Revision link
         } else {
             if (!ChangesList::userCan($rcObj, Revision::DELETED_TEXT)) {
                 $link = '<span class="history-deleted"><tt>' . $rcObj->timestamp . '</tt></span> ';
             } else {
                 $rcIdEq = $rcObj->unpatrolled && $rc_type == RC_NEW ? '&rcid=' . $rcObj->mAttribs['rc_id'] : '';
                 $link = '<tt>' . $this->skin->makeKnownLinkObj($rcObj->getTitle(), $rcObj->timestamp, $curIdEq . '&' . $o . $rcIdEq) . '</tt>';
                 if ($this->isDeleted($rcObj, Revision::DELETED_TEXT)) {
                     $link = '<span class="history-deleted">' . $link . '</span> ';
                 }
             }
         }
         $r .= $link;
         if (!$rc_type == RC_LOG || $rc_type == RC_NEW) {
             $r .= ' (';
             $r .= $rcObj->curlink;
             $r .= $this->message['semicolon-separator'];
             $r .= $rcObj->lastlink;
             $r .= ')';
         }
         $r .= ' . . ';
         # Character diff
         if ($wgRCShowChangedSize) {
             $r .= $rcObj->getCharacterDifference() == '' ? '' : $rcObj->getCharacterDifference() . ' . . ';
         }
         # User links
         $r .= $rcObj->userlink;
         $r .= $rcObj->usertalklink;
         // log action
         parent::insertAction($r, $rcObj);
         // log comment
         parent::insertComment($r, $rcObj);
         # Mark revision as deleted
         if (!$rc_log_type && $this->isDeleted($rcObj, Revision::DELETED_TEXT)) {
             $r .= ' <tt>' . wfMsgHtml('deletedrev') . '</tt>';
         }
         $r .= "</td></tr>\n";
     }
     $r .= "</table></div>\n";
     $this->rcCacheIndex++;
     return $r;
 }