/**
  * @param RecentChange $baseRC
  * @param bool $watched
  *
  * @return RCCacheEntry
  */
 public function newFromRecentChange(RecentChange $baseRC, $watched)
 {
     $user = $this->context->getUser();
     $counter = $baseRC->counter;
     $cacheEntry = RCCacheEntry::newFromParent($baseRC);
     // Should patrol-related stuff be shown?
     $cacheEntry->unpatrolled = ChangesList::isUnpatrolled($baseRC, $user);
     $cacheEntry->watched = $cacheEntry->mAttribs['rc_type'] == RC_LOG ? false : $watched;
     $cacheEntry->numberofWatchingusers = $baseRC->numberofWatchingusers;
     $cacheEntry->link = $this->buildCLink($cacheEntry);
     $cacheEntry->timestamp = $this->buildTimestamp($cacheEntry);
     // Make "cur" and "diff" links.  Do not use link(), it is too slow if
     // called too many times (50% of CPU time on RecentChanges!).
     $showDiffLinks = $this->showDiffLinks($cacheEntry, $user);
     $cacheEntry->difflink = $this->buildDiffLink($cacheEntry, $showDiffLinks, $counter);
     $cacheEntry->curlink = $this->buildCurLink($cacheEntry, $showDiffLinks, $counter);
     $cacheEntry->lastlink = $this->buildLastLink($cacheEntry, $showDiffLinks);
     // Make user links
     $cacheEntry->userlink = $this->getUserLink($cacheEntry);
     if (!ChangesList::isDeleted($cacheEntry, Revision::DELETED_USER)) {
         $cacheEntry->usertalklink = Linker::userToolLinks($cacheEntry->mAttribs['rc_user'], $cacheEntry->mAttribs['rc_user_text']);
     }
     return $cacheEntry;
 }
Exemplo n.º 2
0
 /**
  * @todo use rc_source to group, if set; fallback to rc_type
  *
  * @param RCCacheEntry $cacheEntry
  *
  * @return string
  */
 protected function makeCacheGroupingKey(RCCacheEntry $cacheEntry)
 {
     $title = $cacheEntry->getTitle();
     $cacheGroupingKey = $title->getPrefixedDBkey();
     $type = $cacheEntry->mAttribs['rc_type'];
     if ($type == RC_LOG) {
         // Group by log type
         $cacheGroupingKey = SpecialPage::getTitleFor('Log', $cacheEntry->mAttribs['rc_log_type'])->getPrefixedDBkey();
     }
     return $cacheGroupingKey;
 }
Exemplo n.º 3
0
 /**
  * Format a line for enhanced recentchange (aka with javascript and block of lines).
  *
  * @param $baseRC RecentChange
  * @param $watched bool
  *
  * @return string
  */
 public function recentChangesLine(&$baseRC, $watched = false)
 {
     wfProfileIn(__METHOD__);
     # Create a specialised object
     $rc = RCCacheEntry::newFromParent($baseRC);
     $curIdEq = array('curid' => $rc->mAttribs['rc_cur_id']);
     # If it's a new day, add the headline and flush the cache
     $date = $this->getLanguage()->date($rc->mAttribs['rc_timestamp'], true);
     $ret = '';
     if ($date != $this->lastdate) {
         # Process current cache
         $ret = $this->recentChangesBlock();
         $this->rc_cache = array();
         $ret .= Xml::element('h4', null, $date) . "\n";
         $this->lastdate = $date;
     }
     # Should patrol-related stuff be shown?
     $rc->unpatrolled = $this->showAsUnpatrolled($rc);
     $showdifflinks = true;
     # Make article link
     $type = $rc->mAttribs['rc_type'];
     $logType = $rc->mAttribs['rc_log_type'];
     // Page moves, very old style, not supported anymore
     if ($type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT) {
         // New unpatrolled pages
     } elseif ($rc->unpatrolled && $type == RC_NEW) {
         $clink = Linker::linkKnown($rc->getTitle(), null, array(), array('rcid' => $rc->mAttribs['rc_id']));
         // Log entries
     } elseif ($type == RC_LOG) {
         if ($logType) {
             $logtitle = SpecialPage::getTitleFor('Log', $logType);
             $logpage = new LogPage($logType);
             $logname = $logpage->getName()->escaped();
             $clink = '(' . Linker::linkKnown($logtitle, $logname) . ')';
         } else {
             $clink = Linker::link($rc->getTitle());
         }
         $watched = false;
         // Log entries (old format) and special pages
     } elseif ($rc->mAttribs['rc_namespace'] == NS_SPECIAL) {
         wfDebug("Unexpected special page in recentchanges\n");
         $clink = '';
         // Edits
     } else {
         $clink = Linker::linkKnown($rc->getTitle());
     }
     # Don't show unusable diff links
     if (!ChangesList::userCan($rc, Revision::DELETED_TEXT, $this->getUser())) {
         $showdifflinks = false;
     }
     $time = $this->getLanguage()->time($rc->mAttribs['rc_timestamp'], true, true);
     $rc->watched = $watched;
     $rc->link = $clink;
     $rc->timestamp = $time;
     $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
     # Make "cur" and "diff" links.  Do not use link(), it is too slow if
     # called too many times (50% of CPU time on RecentChanges!).
     $thisOldid = $rc->mAttribs['rc_this_oldid'];
     $lastOldid = $rc->mAttribs['rc_last_oldid'];
     if ($rc->unpatrolled) {
         $rcIdQuery = array('rcid' => $rc->mAttribs['rc_id']);
     } else {
         $rcIdQuery = array();
     }
     $querycur = $curIdEq + array('diff' => '0', 'oldid' => $thisOldid);
     $querydiff = $curIdEq + array('diff' => $thisOldid, 'oldid' => $lastOldid) + $rcIdQuery;
     if (!$showdifflinks) {
         $curLink = $this->message['cur'];
         $diffLink = $this->message['diff'];
     } elseif (in_array($type, array(RC_NEW, RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT))) {
         if ($type != RC_NEW) {
             $curLink = $this->message['cur'];
         } else {
             $curUrl = htmlspecialchars($rc->getTitle()->getLinkURL($querycur));
             $curLink = "<a href=\"{$curUrl}\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
         }
         $diffLink = $this->message['diff'];
     } else {
         $diffUrl = htmlspecialchars($rc->getTitle()->getLinkURL($querydiff));
         $curUrl = htmlspecialchars($rc->getTitle()->getLinkURL($querycur));
         $diffLink = "<a href=\"{$diffUrl}\" tabindex=\"{$baseRC->counter}\">{$this->message['diff']}</a>";
         $curLink = "<a href=\"{$curUrl}\" tabindex=\"{$baseRC->counter}\">{$this->message['cur']}</a>";
     }
     # Make "last" link
     if (!$showdifflinks || !$lastOldid) {
         $lastLink = $this->message['last'];
     } elseif (in_array($type, array(RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT))) {
         $lastLink = $this->message['last'];
     } else {
         $lastLink = Linker::linkKnown($rc->getTitle(), $this->message['last'], array(), $curIdEq + array('diff' => $thisOldid, 'oldid' => $lastOldid) + $rcIdQuery);
     }
     # Make user links
     if ($this->isDeleted($rc, Revision::DELETED_USER)) {
         $rc->userlink = ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
     } else {
         $rc->userlink = Linker::userLink($rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text']);
         $rc->usertalklink = Linker::userToolLinks($rc->mAttribs['rc_user'], $rc->mAttribs['rc_user_text']);
     }
     $rc->lastlink = $lastLink;
     $rc->curlink = $curLink;
     $rc->difflink = $diffLink;
     # Put accumulated information into the cache, for later display
     # Page moves go on their own line
     $title = $rc->getTitle();
     $secureName = $title->getPrefixedDBkey();
     if ($type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT) {
         # Use an @ character to prevent collision with page names
         $this->rc_cache['@@' . $this->rcMoveIndex++] = array($rc);
     } else {
         # Logs are grouped by type
         if ($type == RC_LOG) {
             $secureName = SpecialPage::getTitleFor('Log', $logType)->getPrefixedDBkey();
         }
         if (!isset($this->rc_cache[$secureName])) {
             $this->rc_cache[$secureName] = array();
         }
         array_push($this->rc_cache[$secureName], $rc);
     }
     wfProfileOut(__METHOD__);
     return $ret;
 }
Exemplo n.º 4
0
 /**
  * Returns value to be used in 'historyLink' element of $data param in
  * EnhancedChangesListModifyBlockLineData hook.
  *
  * @since 1.27
  *
  * @param RCCacheEntry $rc
  * @param array $query array of key/value pairs to append as a query string
  * @return string HTML
  */
 public function getDiffHistLinks(RCCacheEntry $rc, array $query)
 {
     $pageTitle = $rc->getTitle();
     if ($rc->getAttribute('rc_type') == RC_CATEGORIZE) {
         // For categorizations we must swap the category title with the page title!
         $pageTitle = Title::newFromID($rc->getAttribute('rc_cur_id'));
     }
     $retVal = ' ' . $this->msg('parentheses')->rawParams($rc->difflink . $this->message['pipe-separator'] . $this->linkRenderer->makeKnownLink($pageTitle, new HtmlArmor($this->message['hist']), [], $query))->escaped();
     return $retVal;
 }
Exemplo n.º 5
0
 /**
  * Format a line for enhanced recentchange (aka with javascript and block of lines).
  */
 public function recentChangesLine(&$baseRC, $watched = false)
 {
     global $wgLang, $wgContLang, $wgUser;
     wfProfileIn(__METHOD__);
     # Create a specialised object
     $rc = RCCacheEntry::newFromParent($baseRC);
     # 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($rc->mAttribs);
     $curIdEq = 'curid=' . $rc_cur_id;
     # If it's a new day, add the headline and flush the cache
     $date = $wgLang->date($rc_timestamp, true);
     $ret = '';
     if ($date != $this->lastdate) {
         # Process current cache
         $ret = $this->recentChangesBlock();
         $this->rc_cache = array();
         $ret .= "<h4>{$date}</h4>\n";
         $this->lastdate = $date;
     }
     # Should patrol-related stuff be shown?
     if ($wgUser->useRCPatrol()) {
         $rc->unpatrolled = !$rc_patrolled;
     } else {
         $rc->unpatrolled = false;
     }
     $showdifflinks = true;
     # Make article link
     // Page moves
     if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
         $msg = $rc_type == RC_MOVE ? "1movedto2" : "1movedto2_redir";
         $clink = wfMsg($msg, $this->skin->makeKnownLinkObj($rc->getTitle(), '', 'redirect=no'), $this->skin->makeKnownLinkObj($rc->getMovedToTitle(), ''));
         // New unpatrolled pages
     } else {
         if ($rc->unpatrolled && $rc_type == RC_NEW) {
             $clink = $this->skin->makeKnownLinkObj($rc->getTitle(), '', "rcid={$rc_id}");
             // Log entries
         } else {
             if ($rc_type == RC_LOG) {
                 if ($rc_log_type) {
                     $logtitle = SpecialPage::getTitleFor('Log', $rc_log_type);
                     $clink = '(' . $this->skin->makeKnownLinkObj($logtitle, LogPage::logName($rc_log_type)) . ')';
                 } else {
                     $clink = $this->skin->makeLinkObj($rc->getTitle(), '');
                 }
                 $watched = false;
                 // Log entries (old format) and special pages
             } elseif ($rc_namespace == NS_SPECIAL) {
                 list($specialName, $logtype) = SpecialPage::resolveAliasWithSubpage($rc_title);
                 if ($specialName == 'Log') {
                     # Log updates, etc
                     $logname = LogPage::logName($logtype);
                     $clink = '(' . $this->skin->makeKnownLinkObj($rc->getTitle(), $logname) . ')';
                 } else {
                     wfDebug("Unexpected special page in recentchanges\n");
                     $clink = '';
                 }
                 // Edits
             } else {
                 $clink = $this->skin->makeKnownLinkObj($rc->getTitle(), '');
             }
         }
     }
     # Don't show unusable diff links
     if (!ChangesList::userCan($rc, Revision::DELETED_TEXT)) {
         $showdifflinks = false;
     }
     $time = $wgContLang->time($rc_timestamp, true, true);
     $rc->watched = $watched;
     $rc->link = $clink;
     $rc->timestamp = $time;
     $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
     # Make "cur" and "diff" links
     if ($rc->unpatrolled) {
         $rcIdQuery = "&rcid={$rc_id}";
     } else {
         $rcIdQuery = '';
     }
     $querycur = $curIdEq . "&diff=0&oldid={$rc_this_oldid}";
     $querydiff = $curIdEq . "&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcIdQuery}";
     $aprops = ' tabindex="' . $baseRC->counter . '"';
     $curLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $this->message['cur'], $querycur, '', '', $aprops);
     # Make "diff" an "cur" links
     if (!$showdifflinks) {
         $curLink = $this->message['cur'];
         $diffLink = $this->message['diff'];
     } else {
         if (in_array($rc_type, array(RC_NEW, RC_LOG, RC_MOVE, RC_MOVE_OVER_REDIRECT))) {
             $curLink = $rc_type != RC_NEW ? $this->message['cur'] : $curLink;
             $diffLink = $this->message['diff'];
         } else {
             $diffLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $this->message['diff'], $querydiff, '', '', $aprops);
         }
     }
     # Make "last" link
     if (!$showdifflinks || !$rc_last_oldid) {
         $lastLink = $this->message['last'];
     } else {
         if ($rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
             $lastLink = $this->message['last'];
         } else {
             $lastLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $this->message['last'], $curIdEq . '&diff=' . $rc_this_oldid . '&oldid=' . $rc_last_oldid . $rcIdQuery);
         }
     }
     # Make user links
     if ($this->isDeleted($rc, Revision::DELETED_USER)) {
         $rc->userlink = ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>';
     } else {
         $rc->userlink = $this->skin->userLink($rc_user, $rc_user_text);
         $rc->usertalklink = $this->skin->userToolLinks($rc_user, $rc_user_text);
     }
     $rc->lastlink = $lastLink;
     $rc->curlink = $curLink;
     $rc->difflink = $diffLink;
     # Put accumulated information into the cache, for later display
     # Page moves go on their own line
     $title = $rc->getTitle();
     $secureName = $title->getPrefixedDBkey();
     if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
         # Use an @ character to prevent collision with page names
         $this->rc_cache['@@' . $this->rcMoveIndex++] = array($rc);
     } else {
         # Logs are grouped by type
         if ($rc_type == RC_LOG) {
             $secureName = SpecialPage::getTitleFor('Log', $rc_log_type)->getPrefixedDBkey();
         }
         if (!isset($this->rc_cache[$secureName])) {
             $this->rc_cache[$secureName] = array();
         }
         array_push($this->rc_cache[$secureName], $rc);
     }
     wfProfileOut(__METHOD__);
     return $ret;
 }
Exemplo n.º 6
0
 /**
  * Format a line for enhanced recentchange (aka with javascript and block of lines).
  */
 function recentChangesLine(&$baseRC, $watched = false)
 {
     global $wgLang, $wgContLang;
     # Create a specialised object
     $rc = RCCacheEntry::newFromParent($baseRC);
     # 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 local variables.
     extract($rc->mAttribs);
     $curIdEq = 'curid=' . $rc_cur_id;
     # If it's a new day, add the headline and flush the cache
     $date = $wgLang->date($rc_timestamp, true);
     $ret = '';
     if ($date != $this->lastdate) {
         # Process current cache
         $ret = $this->recentChangesBlock();
         $this->rc_cache = array();
         $ret .= "<h4>{$date}</h4>\n";
         $this->lastdate = $date;
     }
     // BizzWiki begin {{
     $ns = $rc->getTitle()->getNamespace();
     # Should patrol-related stuff be shown?
     if ($this->usePatrol($ns)) {
         $rc->unpatrolled = !$rc_patrolled;
     } else {
         $rc->unpatrolled = false;
     }
     // BizzWiki end }}
     # Make article link
     if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
         $msg = $rc_type == RC_MOVE ? "1movedto2" : "1movedto2_redir";
         $clink = wfMsg($msg, $this->skin->makeKnownLinkObj($rc->getTitle(), '', 'redirect=no'), $this->skin->makeKnownLinkObj($rc->getMovedToTitle(), ''));
     } elseif ($rc_namespace == NS_SPECIAL) {
         list($specialName, $logtype) = SpecialPage::resolveAliasWithSubpage($rc_title);
         if ($specialName == 'Log') {
             # Log updates, etc
             $logname = LogPage::logName($logtype);
             $clink = '(' . $this->skin->makeKnownLinkObj($rc->getTitle(), $logname) . ')';
         } else {
             wfDebug("Unexpected special page in recentchanges\n");
             $clink = '';
         }
     } elseif ($rc->unpatrolled && $rc_type == RC_NEW) {
         # Unpatrolled new page, give rc_id in query
         $clink = $this->skin->makeKnownLinkObj($rc->getTitle(), '', "rcid={$rc_id}");
     } else {
         $clink = $this->skin->makeKnownLinkObj($rc->getTitle(), '');
     }
     $time = $wgContLang->time($rc_timestamp, true, true);
     $rc->watched = $watched;
     $rc->link = $clink;
     $rc->timestamp = $time;
     $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
     # Make "cur" and "diff" links
     if ($rc->unpatrolled) {
         $rcIdQuery = "&rcid={$rc_id}";
     } else {
         $rcIdQuery = '';
     }
     $querycur = $curIdEq . "&diff=0&oldid={$rc_this_oldid}";
     $querydiff = $curIdEq . "&diff={$rc_this_oldid}&oldid={$rc_last_oldid}{$rcIdQuery}";
     $aprops = ' tabindex="' . $baseRC->counter . '"';
     $curLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $this->message['cur'], $querycur, '', '', $aprops);
     if ($rc_type == RC_NEW || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
         if ($rc_type != RC_NEW) {
             $curLink = $this->message['cur'];
         }
         $diffLink = $this->message['diff'];
     } else {
         $diffLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $this->message['diff'], $querydiff, '', '', $aprops);
     }
     # Make "last" link
     if ($rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
         $lastLink = $this->message['last'];
     } else {
         $lastLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $this->message['last'], $curIdEq . '&diff=' . $rc_this_oldid . '&oldid=' . $rc_last_oldid . $rcIdQuery);
     }
     $rc->userlink = $this->skin->userLink($rc_user, $rc_user_text);
     $rc->lastlink = $lastLink;
     $rc->curlink = $curLink;
     $rc->difflink = $diffLink;
     $rc->usertalklink = $this->skin->userToolLinks($rc_user, $rc_user_text);
     # Put accumulated information into the cache, for later display
     # Page moves go on their own line
     $title = $rc->getTitle();
     $secureName = $title->getPrefixedDBkey();
     if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
         # Use an @ character to prevent collision with page names
         $this->rc_cache['@@' . $this->rcMoveIndex++] = array($rc);
     } else {
         if (!isset($this->rc_cache[$secureName])) {
             $this->rc_cache[$secureName] = array();
         }
         array_push($this->rc_cache[$secureName], $rc);
     }
     return $ret;
 }
Exemplo n.º 7
0
 /**
  * Determines whether a revision is linked to this change; this may not be the case
  * when the categorization wasn't done by an edit but a conditional parser function
  *
  * @since 1.27
  *
  * @param RecentChange|RCCacheEntry $rcObj
  * @return bool
  */
 protected function isCategorizationWithoutRevision($rcObj)
 {
     return intval($rcObj->getAttribute('rc_type')) === RC_CATEGORIZE && intval($rcObj->getAttribute('rc_this_oldid')) === 0;
 }
 /**
  * Hook
  *
  * @desc Changes $secureName in MW ChangesList.php #L815 so Article Comments and extensions which are based on AC (as long as those extensions doesn't have their own hook)
  *
  * @param ChangesList $oChangeList -- instance of ChangeList class
  * @param String $currentName    -- current value of RC key
  * @param RCCacheEntry $oRCCacheEntry  -- instance of RCCacheEntry class
  *
  * @static
  * @access public
  *
  * @return boolean -- because it's a hook
  */
 public static function makeChangesListKey($oChangeList, &$currentName, $oRCCacheEntry)
 {
     global $wgEnableGroupedArticleCommentsRC;
     if (empty($wgEnableGroupedArticleCommentsRC)) {
         return true;
     }
     wfProfileIn(__METHOD__);
     $oTitle = $oRCCacheEntry->getTitle();
     $namespace = $oTitle->getNamespace();
     if (MWNamespace::isTalk($namespace) && ArticleComment::isTitleComment($oTitle)) {
         $parts = ArticleComment::explode($oTitle->getText());
         if ($parts['title'] != '') {
             $currentName = 'ArticleComments' . $parts['title'];
         }
     }
     wfProfileOut(__METHOD__);
     return true;
 }
Exemplo n.º 9
0
 function recentChangesLineNew(&$baseRC, $watched = false)
 {
     global $wgTitle, $wgLang, $wgContLang, $wgUser, $wgUseRCPatrol, $wgOnlySysopsCanPatrol, $wgSysopUserBans;
     static $message;
     if (!isset($message)) {
         foreach (explode(' ', 'cur diff hist minoreditletter newpageletter last blocklink undo diff-to-lvr ' . 'diff-to-lvr_tooltiptext cur_tooltiptext diff_tooltiptext last_tooltiptext updatedmarker updatedmarker_tooltiptext ') as $msg) {
             $message[$msg] = wfMsg($msg);
         }
     }
     # Create a specialised object
     $rc = RCCacheEntry::newFromParent($baseRC);
     # Extract fields from DB into the function scope (rc_xxxx variables)
     extract($rc->mAttribs);
     $curIdEq = 'curid=' . $rc_cur_id;
     # If it's a new day, add the headline and flush the cache
     $date = $wgLang->date($rc_timestamp, true);
     $ret = '';
     if ($date != $this->lastdate) {
         # Process current cache
         $ret = $this->recentChangesBlock();
         $this->rc_cache = array();
         $ret .= "<h4>{$date}</h4>\n";
         $this->lastdate = $date;
     }
     # Should patrol-related stuff be shown?
     if ($wgUseRCPatrol && $wgUser->isLoggedIn() && (!$wgOnlySysopsCanPatrol || $wgUser->isAllowed('patrol'))) {
         $rc->unpatrolled = !$rc_patrolled;
     } else {
         $rc->unpatrolled = false;
     }
     # Make article link
     if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
         $msg = $rc_type == RC_MOVE ? "1movedto2" : "1movedto2_redir";
         $clink = wfMsg($msg, $this->skin->makeKnownLinkObj($rc->getTitle(), '', 'redirect=no'), $this->skin->makeKnownLinkObj($rc->getMovedToTitle(), ''));
     } elseif ($rc_namespace == NS_SPECIAL && preg_match('!^Log/(.*)$!', $rc_title, $matches)) {
         # Log updates, etc
         $logtype = $matches[1];
         $logname = LogPage::logName($logtype);
         $clink = '(' . $this->skin->makeKnownLinkObj($rc->getTitle(), $logname) . ')';
     } elseif ($rc->unpatrolled && $rc_type == RC_NEW) {
         # Unpatrolled new page, give rc_id in query
         $clink = $this->skin->makeKnownLinkObj($rc->getTitle(), '', "rcid={$rc_id}");
     } else {
         $clink = $this->skin->makeKnownLinkObj($rc->getTitle(), '');
     }
     $time = $wgContLang->time($rc_timestamp, true, true);
     $rc->watched = $watched;
     $rc->link = $clink;
     $rc->timestamp = $time;
     $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
     $rc->lastvisitedrevision = $baseRC->lastvisitedrevision;
     $rc->notificationtimestamp = $baseRC->notificationtimestamp;
     # Make "cur" and "diff" links
     $titleObj = $rc->getTitle();
     if ($rc->unpatrolled) {
         $rcIdQuery = "&rcid={$rc_id}";
     } else {
         $rcIdQuery = '';
     }
     $query = $curIdEq . "&diff={$rc_this_oldid}&oldid={$rc_last_oldid}";
     $aprops = ' tabindex="' . $baseRC->counter . '"';
     $curLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $message['cur'], $query, '', '', $aprops);
     if ($rc_type == RC_NEW || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
         if ($rc_type != RC_NEW) {
             $curLink = $message['cur'];
         }
         $diffLink = $message['diff'];
     } else {
         #	$query = $curIdEq.'&diff=0&oldid='.$rc_this_oldid;
         $query = $curIdEq . "&diff={$rc_this_oldid}&oldid={$rc_last_oldid}";
         $aprops = ' tabindex="' . $baseRC->counter . '"';
         $curLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $message['cur'], $query, '', '', $aprops, $message['cur_tooltiptext']);
         $diffLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $message['diff'], $query . $rcIdQuery, '', '', $aprops, $message['diff_tooltiptext']);
     }
     # Make "last" link
     if ($rc_last_oldid == 0 || $rc_type == RC_LOG || $rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
         $lastLink = $message['last'];
     } else {
         $lastLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $message['last'], $curIdEq . '&diff=' . $rc_this_oldid . '&oldid=' . $rc_last_oldid . $rcIdQuery, '', '', '', $message['last_tooltiptext']);
     }
     # Make user link (or user contributions for unregistered users)
     if ($rc_user == 0) {
         $contribsPage =& Title::makeTitle(NS_SPECIAL, 'Contributions');
         $userLink = $this->skin->makeKnownLinkObj($contribsPage, $rc_user_text, 'target=' . $rc_user_text);
     } else {
         $userPage =& Title::makeTitle(NS_USER, $rc_user_text);
         $userLink = $this->skin->makeLinkObj($userPage, $rc_user_text);
     }
     if ($watched && $baseRC->lastvisitedrevision) {
         $lvrLink = $this->skin->makeKnownLinkObj($rc->getTitle(), $message['diff-to-lvr'], "{$curIdEq}&diff=0&oldid={$baseRC->lastvisitedrevision}", '', '', '', $message['diff-to-lvr_tooltiptext']);
     } else {
         $lvrLink = '';
     }
     $rc->lvrlink = $lvrLink;
     $rc->userlink = $userLink;
     $rc->lastlink = $lastLink;
     $rc->curlink = $curLink;
     $rc->difflink = $diffLink;
     # Make user talk link
     $talkname = $wgContLang->getNsText(NS_TALK);
     # use the shorter name
     $userTalkPage =& Title::makeTitle(NS_USER_TALK, $rc_user_text);
     $userTalkLink = $this->skin->makeLinkObj($userTalkPage, $talkname);
     global $wgDisableAnonTalk;
     if (($wgSysopUserBans || 0 == $rc_user) && $wgUser->isAllowed('block')) {
         $blockPage =& Title::makeTitle(NS_SPECIAL, 'Blockip');
         $blockLink = $this->skin->makeKnownLinkObj($blockPage, $message['blocklink'], 'ip=' . $rc_user_text);
         if ($wgDisableAnonTalk) {
             $rc->usertalklink = ' (' . $blockLink . ')';
         } else {
             $rc->usertalklink = ' (' . $userTalkLink . ' | ' . $blockLink . ')';
         }
     } else {
         if ($wgDisableAnonTalk && $rc_user == 0) {
             $rc->usertalklink = '';
         } else {
             $rc->usertalklink = ' (' . $userTalkLink . ')';
         }
     }
     # Put accumulated information into the cache, for later display
     # Page moves go on their own line
     $title = $rc->getTitle();
     $secureName = $title->getPrefixedDBkey();
     if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) {
         # Use an @ character to prevent collision with page names
         $this->rc_cache['@@' . $this->rcMoveIndex++] = array($rc);
     } else {
         if (!isset($this->rc_cache[$secureName])) {
             $this->rc_cache[$secureName] = array();
         }
         array_push($this->rc_cache[$secureName], $rc);
     }
     return $ret;
 }
 /**
  * Format a line for enhanced recentchange (aka with javascript and block of lines).
  */
 function recentChangesLine(&$baseRC, $watched = false)
 {
     global $wgLang;
     # Create a specialised object
     $rc = RCCacheEntry::newFromParent($baseRC);
     // Extract most used variables
     $timestamp = $rc->getAttribute('rc_timestamp');
     $titleObj = $rc->getTitle();
     $rc_id = $rc->getAttribute('rc_id');
     $date = $wgLang->date($timestamp, true, true);
     $time = $wgLang->time($timestamp, true, true);
     # Should patrol-related stuff be shown?
     $rc->unpatrolled = self::usePatrol() ? !$rc->getAttribute('rc_patrolled') : false;
     $logEntry = $this->isLog($rc);
     if ($logEntry) {
         $clink = $this->getLogTitle($rc);
     } elseif ($rc->unpatrolled && $rc->getAttribute('rc_type') == RC_NEW) {
         # Unpatrolled new page, give rc_id in query
         $clink = $this->skin->makeKnownLinkObj($titleObj, '', "rcid={$rc_id}");
     } else {
         $clink = $this->skin->makeKnownLinkObj($titleObj);
     }
     $rc->watched = $watched;
     $rc->link = $this->maybeWatchedLink($clink, $watched);
     $rc->timestamp = $time;
     $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
     $rc->_reqCurId = array('curid' => $rc->getAttribute('rc_cur_id'));
     $rc->_reqOldId = array('oldid' => $rc->getAttribute('rc_this_oldid'));
     $this->makeLinks($rc);
     $stuff = $this->userToolLinks($rc->getAttribute('rc_user'), $rc->getAttribute('rc_user_text'));
     self::$userinfo += $stuff[1];
     $rc->_user = $this->skin->userLink($rc->getAttribute('rc_user'), $rc->getAttribute('rc_user_text'));
     $rc->_userInfo = $stuff[0];
     if (!$this->isLog($rc)) {
         $rc->_comment = $this->getComment($rc);
     }
     $rc->_watching = $this->numberofWatchingusers($baseRC->numberofWatchingusers);
     # If it's a new day, add the headline and flush the cache
     $ret = '';
     if ($date !== $this->lastdate) {
         # Process current cache
         $ret = $this->recentChangesBlock();
         $this->rc_cache = array();
         $ret .= Xml::element('h4', null, $date) . "\n";
         $this->lastdate = $date;
     }
     # Put accumulated information into the cache, for later display
     # Page moves go on their own line
     if ($logEntry) {
         $secureName = $this->getLogTitle($rc);
     } else {
         $secureName = $titleObj->getPrefixedDBkey();
     }
     $this->rc_cache[$secureName][] = $rc;
     return $ret;
 }
Exemplo n.º 11
0
 /**
  * Format a line for enhanced recentchange (aka with javascript and block of lines).
  *
  * @param $baseRC RecentChange
  * @param $watched bool
  *
  * @return string
  */
 public function recentChangesLine(&$baseRC, $watched = false)
 {
     wfProfileIn(__METHOD__);
     # Create a specialised object
     $rc = RCCacheEntry::newFromParent($baseRC);
     # If it's a new day, add the headline and flush the cache
     $date = $this->getLanguage()->date($rc->mAttribs['rc_timestamp'], true);
     $ret = '';
     if ($date != $this->lastdate) {
         # Process current cache
         $ret = $this->recentChangesBlock();
         $this->rc_cache = array();
         $ret .= Xml::element('h4', null, $date) . "\n";
         $this->lastdate = $date;
     }
     # Should patrol-related stuff be shown?
     $rc->unpatrolled = $this->showAsUnpatrolled($rc);
     $linksCache = $this->lineLinksCache($rc, $rc->unpatrolled);
     $showdifflinks = true;
     # Make article link
     $type = $rc->mAttribs['rc_type'];
     $logType = $rc->mAttribs['rc_log_type'];
     // Page moves, very old style, not supported anymore
     if ($type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT) {
         // New unpatrolled pages
     } elseif ($rc->unpatrolled && $type == RC_NEW) {
         $clink = $linksCache['clink_unpatrolled'];
         // Log entries
     } elseif ($type == RC_LOG) {
         if ($logType) {
             $logtitle = SpecialPage::getTitleFor('Log', $logType);
             $logpage = new LogPage($logType);
             $logname = $logpage->getName()->escaped();
             $clink = '(' . Linker::linkKnown($logtitle, $logname) . ')';
         } else {
             $clink = $linksCache['clink'];
         }
         $watched = false;
         // Log entries (old format) and special pages
     } elseif ($rc->mAttribs['rc_namespace'] == NS_SPECIAL) {
         wfDebug("Unexpected special page in recentchanges\n");
         $clink = '';
         // Edits
     } else {
         $clink = $linksCache['clink'];
     }
     # Don't show unusable diff links
     if (!ChangesList::userCan($rc, Revision::DELETED_TEXT, $this->getUser())) {
         $showdifflinks = false;
     }
     $time = $this->getLanguage()->time($rc->mAttribs['rc_timestamp'], true, true);
     $rc->watched = $watched;
     $rc->link = $clink;
     $rc->timestamp = $time;
     $rc->numberofWatchingusers = $baseRC->numberofWatchingusers;
     if (!$showdifflinks) {
         $curLink = $this->message['cur'];
         $diffLink = $this->message['diff'];
     } else {
         $rc->curlink = $linksCache['cur'];
         $rc->difflink = $linksCache['diff'];
     }
     # Make "last" link
     if (!$showdifflinks || !$lastOldid) {
         $lastLink = $this->message['last'];
     } else {
         $rc->lastlink = $linksCache['last'];
     }
     # Make user links
     $rc->userlink = $linksCache['userlink'];
     $rc->usertalklink = $linksCache['usertalklink'];
     # Put accumulated information into the cache, for later display
     # Page moves go on their own line
     $title = $rc->getTitle();
     $secureName = $title->getPrefixedDBkey();
     if ($type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT) {
         # Use an @ character to prevent collision with page names
         $this->rc_cache['@@' . $this->rcMoveIndex++] = array($rc);
     } else {
         # Logs are grouped by type
         if ($type == RC_LOG) {
             $secureName = SpecialPage::getTitleFor('Log', $logType)->getPrefixedDBkey();
         }
         // Start of Wikia change - @author unknown
         wfRunHooks('ChangesListMakeSecureName', array($this, &$secureName, $rc));
         // End of Wikia change
         if (!isset($this->rc_cache[$secureName])) {
             $this->rc_cache[$secureName] = array();
         }
         array_push($this->rc_cache[$secureName], $rc);
     }
     wfProfileOut(__METHOD__);
     return $ret;
 }
Exemplo n.º 12
0
 /**
  * Put accumulated information into the cache, for later display.
  * Page moves go on their own line.
  *
  * @param RCCacheEntry $cacheEntry
  */
 protected function addCacheEntry(RCCacheEntry $cacheEntry)
 {
     $title = $cacheEntry->getTitle();
     $secureName = $title->getPrefixedDBkey();
     $type = $cacheEntry->mAttribs['rc_type'];
     if ($type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT) {
         # Use an @ character to prevent collision with page names
         $this->rc_cache['@@' . $this->rcMoveIndex++] = array($cacheEntry);
     } else {
         # Logs are grouped by type
         if ($type == RC_LOG) {
             $secureName = SpecialPage::getTitleFor('Log', $cacheEntry->mAttribs['rc_log_type'])->getPrefixedDBkey();
         }
         if (!isset($this->rc_cache[$secureName])) {
             $this->rc_cache[$secureName] = array();
         }
         array_push($this->rc_cache[$secureName], $cacheEntry);
     }
 }