/** * Hook function for RecentChange_save * Saves user data into the cu_changes table */ public static function updateCheckUserData(RecentChange $rc) { global $wgRequest; // Extract params extract($rc->mAttribs); // Get IP $ip = wfGetIP(); // Get XFF header $xff = $wgRequest->getHeader('X-Forwarded-For'); list($xff_ip, $isSquidOnly) = self::getClientIPfromXFF($xff); // Get agent $agent = $wgRequest->getHeader('User-Agent'); // Store the log action text for log events // $rc_comment should just be the log_comment // BC: check if log_type and log_action exists // If not, then $rc_comment is the actiontext and comment if (isset($rc_log_type) && $rc_type == RC_LOG) { $target = Title::makeTitle($rc_namespace, $rc_title); $actionText = LogPage::actionText($rc_log_type, $rc_log_action, $target, null, LogPage::extractParams($rc_params)); } else { $actionText = ''; } $dbw = wfGetDB(DB_MASTER); $cuc_id = $dbw->nextSequenceValue('cu_changes_cu_id_seq'); $rcRow = array('cuc_id' => $cuc_id, 'cuc_namespace' => $rc_namespace, 'cuc_title' => $rc_title, 'cuc_minor' => $rc_minor, 'cuc_user' => $rc_user, 'cuc_user_text' => $rc_user_text, 'cuc_actiontext' => $actionText, 'cuc_comment' => $rc_comment, 'cuc_this_oldid' => $rc_this_oldid, 'cuc_last_oldid' => $rc_last_oldid, 'cuc_type' => $rc_type, 'cuc_timestamp' => $rc_timestamp, 'cuc_ip' => IP::sanitizeIP($ip), 'cuc_ip_hex' => $ip ? IP::toHex($ip) : null, 'cuc_xff' => !$isSquidOnly ? $xff : '', 'cuc_xff_hex' => $xff_ip && !$isSquidOnly ? IP::toHex($xff_ip) : null, 'cuc_agent' => $agent); # On PG, MW unsets cur_id due to schema incompatibilites. So it may not be set! if (isset($rc_cur_id)) { $rcRow['cuc_page_id'] = $rc_cur_id; } $dbw->insert('cu_changes', $rcRow, __METHOD__); return true; }
/** * Format a diff for the newsfeed * * @param $row Object: row from the recentchanges table * @return String */ public static function formatDiff($row) { global $wgUser; $titleObj = Title::makeTitle($row->rc_namespace, $row->rc_title); $timestamp = wfTimestamp(TS_MW, $row->rc_timestamp); $actiontext = ''; if ($row->rc_type == RC_LOG) { if ($row->rc_deleted & LogPage::DELETED_ACTION) { $actiontext = wfMsgHtml('rev-deleted-event'); } else { $actiontext = LogPage::actionText($row->rc_log_type, $row->rc_log_action, $titleObj, $wgUser->getSkin(), LogPage::extractParams($row->rc_params, true, true)); } } return self::formatDiffRow($titleObj, $row->rc_last_oldid, $row->rc_this_oldid, $timestamp, $row->rc_deleted & Revision::DELETED_COMMENT ? wfMsgHtml('rev-deleted-comment') : $row->rc_comment, $actiontext); }
/** * Hook function for RecentChange_save * Saves user data into the cu_changes table */ function efUpdateCheckUserData($rc) { global $wgUser; // Extract params extract($rc->mAttribs); // Get IP $ip = wfGetIP(); // Get XFF header $xff = wfGetForwardedFor(); list($xff_ip, $trusted) = efGetClientIPfromXFF($xff); // Our squid XFFs can flood this up sometimes $isSquidOnly = efXFFChainIsSquid($xff); // Get agent $agent = wfGetAgent(); // Store the log action text for log events // $rc_comment should just be the log_comment // BC: check if log_type and log_action exists // If not, then $rc_comment is the actiontext and comment if (isset($rc_log_type) && $rc_type == RC_LOG) { $target = Title::makeTitle($rc_namespace, $rc_title); $actionText = LogPage::actionText($rc_log_type, $rc_log_action, $target, NULL, explode('\\n', $rc_params)); } else { $actionText = ''; } $dbw = wfGetDB(DB_MASTER); $cuc_id = $dbw->nextSequenceValue('cu_changes_cu_id_seq'); $rcRow = array('cuc_id' => $cuc_id, 'cuc_namespace' => $rc_namespace, 'cuc_title' => $rc_title, 'cuc_minor' => $rc_minor, 'cuc_user' => $rc_user, 'cuc_user_text' => $rc_user_text, 'cuc_actiontext' => $actionText, 'cuc_comment' => $rc_comment, 'cuc_this_oldid' => $rc_this_oldid, 'cuc_last_oldid' => $rc_last_oldid, 'cuc_type' => $rc_type, 'cuc_timestamp' => $rc_timestamp, 'cuc_ip' => IP::sanitizeIP($ip), 'cuc_ip_hex' => $ip ? IP::toHex($ip) : null, 'cuc_xff' => !$isSquidOnly ? $xff : '', 'cuc_xff_hex' => $xff_ip && !$isSquidOnly ? IP::toHex($xff_ip) : null, 'cuc_agent' => $agent); ## On PG, MW unsets cur_id due to schema incompatibilites. So it may not be set! if (isset($rc_cur_id)) { $rcRow['cuc_page_id'] = $rc_cur_id; } $dbw->insert('cu_changes', $rcRow, __METHOD__); # Every 100th edit, prune the checkuser changes table. wfSeedRandom(); if (0 == mt_rand(0, 99)) { # Periodically flush old entries from the recentchanges table. global $wgCUDMaxAge; $cutoff = $dbw->timestamp(time() - $wgCUDMaxAge); $recentchanges = $dbw->tableName('cu_changes'); $sql = "DELETE FROM {$recentchanges} WHERE cuc_timestamp < '{$cutoff}'"; $dbw->query($sql); } return true; }
private function logAction($row, $title, $paramArray) { if (self::isDeleted($row, LogPage::DELETED_ACTION)) { $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>'; } else { $action = LogPage::actionText($row->log_type, $row->log_action, $title, $this->skin, $paramArray, true); } return $action; }
/** * @param Object $s a single row from the result set * @return string Formatted HTML list item * @private */ function logLine($s) { global $wgLang, $wgUser; $skin = $wgUser->getSkin(); $title = Title::makeTitle($s->log_namespace, $s->log_title); $time = $wgLang->timeanddate(wfTimestamp(TS_MW, $s->log_timestamp), true); // Enter the existence or non-existence of this page into the link cache, // for faster makeLinkObj() in LogPage::actionText() $linkCache =& LinkCache::singleton(); if ($s->page_id) { $linkCache->addGoodLinkObj($s->page_id, $title); } else { $linkCache->addBadLinkObj($title); } $userLink = $this->skin->userLink($s->log_user, $s->user_name) . $this->skin->userToolLinksRedContribs($s->log_user, $s->user_name); $comment = $this->skin->commentBlock($s->log_comment); $paramArray = LogPage::extractParams($s->log_params); $revert = ''; // show revertmove link if ($s->log_type == 'move' && isset($paramArray[0])) { $destTitle = Title::newFromText($paramArray[0]); if ($destTitle) { $revert = '(' . $this->skin->makeKnownLinkObj(SpecialPage::getTitleFor('Movepage'), wfMsg('revertmove'), 'wpOldTitle=' . urlencode($destTitle->getPrefixedDBkey()) . '&wpNewTitle=' . urlencode($title->getPrefixedDBkey()) . '&wpReason=' . urlencode(wfMsgForContent('revertmove')) . '&wpMovetalk=0') . ')'; } // show undelete link } elseif ($s->log_action == 'delete' && $wgUser->isAllowed('delete', $s->log_namespace)) { $revert = '(' . $this->skin->makeKnownLinkObj(SpecialPage::getTitleFor('Undelete'), wfMsg('undeletebtn'), 'target=' . urlencode($title->getPrefixedDBkey())) . ')'; // show unblock link } elseif ($s->log_action == 'block' && $wgUser->isAllowed('block')) { $revert = '(' . $skin->makeKnownLinkObj(SpecialPage::getTitleFor('Ipblocklist'), wfMsg('unblocklink'), 'action=unblock&ip=' . urlencode($s->log_title)) . ')'; // show change protection link } elseif ($s->log_action == 'protect' && $wgUser->isAllowed('protect', $s->log_namespace)) { $revert = '(' . $skin->makeKnownLink($title->getPrefixedDBkey(), wfMsg('protect_change'), 'action=unprotect') . ')'; // show user tool links for self created users } elseif ($s->log_action == 'create2') { $revert = $this->skin->userToolLinksRedContribs($s->log_user, $s->log_title); // do not show $comment for self created accounts. It includes wrong user tool links: // 'blockip' for users w/o block allowance and broken links for very long usernames (bug 4756) $comment = ''; } $action = LogPage::actionText($s->log_type, $s->log_action, $title, $this->skin, $paramArray, true, true); $out = "<li>{$time} {$userLink} {$action} {$comment} {$revert}</li>\n"; return $out; }
public function getHTML() { $date = htmlspecialchars($this->list->getLang()->timeanddate($this->row->log_timestamp)); $paramArray = LogPage::extractParams($this->row->log_params); $title = Title::makeTitle($this->row->log_namespace, $this->row->log_title); // Log link for this page $loglink = Linker::link(SpecialPage::getTitleFor('Log'), wfMsgHtml('log'), array(), array('page' => $title->getPrefixedText())); // Action text if (!$this->canView()) { $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>'; } else { $skin = $this->list->getUser()->getSkin(); $action = LogPage::actionText($this->row->log_type, $this->row->log_action, $title, $skin, $paramArray, true, true); if ($this->row->log_deleted & LogPage::DELETED_ACTION) { $action = '<span class="history-deleted">' . $action . '</span>'; } } // User links $userLink = Linker::userLink($this->row->log_user, User::WhoIs($this->row->log_user)); if (LogEventsList::isDeleted($this->row, LogPage::DELETED_USER)) { $userLink = '<span class="history-deleted">' . $userLink . '</span>'; } // Comment $comment = $this->list->getLang()->getDirMark() . Linker::commentBlock($this->row->log_comment); if (LogEventsList::isDeleted($this->row, LogPage::DELETED_COMMENT)) { $comment = '<span class="history-deleted">' . $comment . '</span>'; } return "<li>({$loglink}) {$date} {$userLink} {$action} {$comment}</li>"; }
/** * Add a log entry * @param string $action one of '', 'block', 'protect', 'rights', 'delete', 'upload', 'move', 'move_redir' * @param object &$target A title object. * @param string $comment Description associated * @param array $params Parameters passed later to wfMsg.* functions */ function addEntry($action, $target, $comment, $params = array()) { if (!is_array($params)) { $params = array($params); } $this->action = $action; $this->target = $target; $this->comment = $comment; $this->params = LogPage::makeParamBlob($params); $this->actionText = LogPage::actionText($this->type, $action, $target, NULL, $params); return $this->saveContent(); }
/** * Add a log entry * * @param $action String: one of '', 'block', 'protect', 'rights', 'delete', 'upload', 'move', 'move_redir' * @param $target Title object * @param $comment String: description associated * @param $params Array: parameters passed later to wfMsg.* functions * @param $doer User object: the user doing the action */ public function addEntry($action, $target, $comment, $params = array(), $doer = null) { if (!is_array($params)) { $params = array($params); } if ($comment === null) { $comment = ''; } $this->action = $action; $this->target = $target; $this->comment = $comment; $this->params = LogPage::makeParamBlob($params); if ($doer === null) { global $wgUser; $doer = $wgUser; } elseif (!is_object($doer)) { $doer = User::newFromId($doer); } $this->doer = $doer; $this->actionText = LogPage::actionText($this->type, $action, $target, null, $params); return $this->saveContent(); }
/** * @param Object $s a single row from the result set * @return string Formatted HTML list item * @private */ function logLine($s) { global $wgLang, $wgUser, $wgContLang; $skin = $wgUser->getSkin(); $title = Title::makeTitle($s->log_namespace, $s->log_title); $time = $wgLang->timeanddate(wfTimestamp(TS_MW, $s->log_timestamp), true); // Enter the existence or non-existence of this page into the link cache, // for faster makeLinkObj() in LogPage::actionText() $linkCache =& LinkCache::singleton(); if ($s->page_id) { $linkCache->addGoodLinkObj($s->page_id, $title); } else { $linkCache->addBadLinkObj($title); } $userLink = $this->skin->userLink($s->log_user, $s->user_name) . $this->skin->userToolLinksRedContribs($s->log_user, $s->user_name); $comment = $wgContLang->getDirMark() . $this->skin->commentBlock($s->log_comment); $paramArray = LogPage::extractParams($s->log_params); $revert = ''; // show revertmove link if (!($this->flags & self::NO_ACTION_LINK)) { if ($s->log_type == 'move' && isset($paramArray[0])) { $destTitle = Title::newFromText($paramArray[0]); if ($destTitle) { $revert = '(' . $this->skin->makeKnownLinkObj(SpecialPage::getTitleFor('Movepage'), wfMsg('revertmove'), 'wpOldTitle=' . urlencode($destTitle->getPrefixedDBkey()) . '&wpNewTitle=' . urlencode($title->getPrefixedDBkey()) . '&wpReason=' . urlencode(wfMsgForContent('revertmove')) . '&wpMovetalk=0') . ')'; } // show undelete link } elseif ($s->log_action == 'delete' && $wgUser->isAllowed('delete')) { $revert = '(' . $this->skin->makeKnownLinkObj(SpecialPage::getTitleFor('Undelete'), wfMsg('undeletebtn'), 'target=' . urlencode($title->getPrefixedDBkey())) . ')'; // show unblock link } elseif ($s->log_action == 'block' && $wgUser->isAllowed('block')) { $revert = '(' . $skin->makeKnownLinkObj(SpecialPage::getTitleFor('Ipblocklist'), wfMsg('unblocklink'), 'action=unblock&ip=' . urlencode($s->log_title)) . ')'; // show change protection link } elseif (($s->log_action == 'protect' || $s->log_action == 'modify') && $wgUser->isAllowed('protect')) { $revert = '(' . $skin->makeKnownLinkObj($title, wfMsg('protect_change'), 'action=unprotect') . ')'; // show user tool links for self created users // TODO: The extension should be handling this, get it out of core! } elseif ($s->log_action == 'create2') { if (isset($paramArray[0])) { $revert = $this->skin->userToolLinks($paramArray[0], $s->log_title, true); } else { # Fall back to a blue contributions link $revert = $this->skin->userToolLinks(1, $s->log_title); } # Suppress $comment from old entries, not needed and can contain incorrect links $comment = ''; } } $action = LogPage::actionText($s->log_type, $s->log_action, $title, $this->skin, $paramArray, true); $out = "<li>{$time} {$userLink} {$action} {$comment} {$revert}</li>\n"; return $out; }
/** * @param $row Row: a single row from the result set * @return String: Formatted HTML list item */ public function logLine($row) { global $wgLang, $wgUser, $wgContLang; $title = Title::makeTitle($row->log_namespace, $row->log_title); $time = $wgLang->timeanddate(wfTimestamp(TS_MW, $row->log_timestamp), true); // User links if (self::isDeleted($row, LogPage::DELETED_USER)) { $userLink = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>'; } else { $userLink = $this->skin->userLink($row->log_user, $row->user_name) . $this->skin->userToolLinks($row->log_user, $row->user_name, true, 0, $row->user_editcount); } // Comment if (self::isDeleted($row, LogPage::DELETED_COMMENT)) { $comment = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>'; } else { $comment = $wgContLang->getDirMark() . $this->skin->commentBlock($row->log_comment); } // Extract extra parameters $paramArray = LogPage::extractParams($row->log_params); $revert = $del = ''; // Some user can hide log items and have review links if ($wgUser->isAllowed('deleterevision')) { $del = $this->getShowHideLinks($row) . ' '; } // Add review links and such... if ($this->flags & self::NO_ACTION_LINK || $row->log_deleted & LogPage::DELETED_ACTION) { // Action text is suppressed... } else { if (self::typeAction($row, 'move', 'move', 'move') && !empty($paramArray[0])) { $destTitle = Title::newFromText($paramArray[0]); if ($destTitle) { $revert = '(' . $this->skin->makeKnownLinkObj(SpecialPage::getTitleFor('Movepage'), $this->message['revertmove'], 'wpOldTitle=' . urlencode($destTitle->getPrefixedDBkey()) . '&wpNewTitle=' . urlencode($title->getPrefixedDBkey()) . '&wpReason=' . urlencode(wfMsgForContent('revertmove')) . '&wpMovetalk=0') . ')'; } // Show undelete link } else { if (self::typeAction($row, array('delete', 'suppress'), 'delete', 'delete')) { $revert = '(' . $this->skin->makeKnownLinkObj(SpecialPage::getTitleFor('Undelete'), $this->message['undeletelink'], 'target=' . urlencode($title->getPrefixedDBkey())) . ')'; // Show unblock/change block link } else { if (self::typeAction($row, array('block', 'suppress'), array('block', 'reblock'), 'block')) { $revert = '(' . $this->skin->link(SpecialPage::getTitleFor('Ipblocklist'), $this->message['unblocklink'], array(), array('action' => 'unblock', 'ip' => $row->log_title), 'known') . ' ' . $this->message['pipe-separator'] . ' ' . $this->skin->link(SpecialPage::getTitleFor('Blockip', $row->log_title), $this->message['change-blocklink'], array(), array(), 'known') . ')'; // Show change protection link } else { if (self::typeAction($row, 'protect', array('modify', 'protect', 'unprotect'))) { $revert .= ' (' . $this->skin->link($title, $this->message['hist'], array(), array('action' => 'history', 'offset' => $row->log_timestamp)); if ($wgUser->isAllowed('protect')) { $revert .= ' ' . $this->message['pipe-separator'] . ' ' . $this->skin->link($title, $this->message['protect_change'], array(), array('action' => 'protect'), 'known'); } $revert .= ')'; // Show unmerge link } else { if (self::typeAction($row, 'merge', 'merge', 'mergehistory')) { $merge = SpecialPage::getTitleFor('Mergehistory'); $revert = '(' . $this->skin->makeKnownLinkObj($merge, $this->message['revertmerge'], wfArrayToCGI(array('target' => $paramArray[0], 'dest' => $title->getPrefixedDBkey(), 'mergepoint' => $paramArray[1]))) . ')'; // If an edit was hidden from a page give a review link to the history } else { if (self::typeAction($row, array('delete', 'suppress'), 'revision', 'deleterevision')) { if (count($paramArray) == 2) { $revdel = SpecialPage::getTitleFor('Revisiondelete'); // Different revision types use different URL params... $key = $paramArray[0]; // Link to each hidden object ID, $paramArray[1] is the url param $Ids = explode(',', $paramArray[1]); $revParams = ''; foreach ($Ids as $n => $id) { $revParams .= '&' . urlencode($key) . '[]=' . urlencode($id); } $revert = '(' . $this->skin->makeKnownLinkObj($revdel, $this->message['revdel-restore'], 'target=' . $title->getPrefixedUrl() . $revParams) . ')'; } // Hidden log items, give review link } else { if (self::typeAction($row, array('delete', 'suppress'), 'event', 'deleterevision')) { if (count($paramArray) == 1) { $revdel = SpecialPage::getTitleFor('Revisiondelete'); $Ids = explode(',', $paramArray[0]); // Link to each hidden object ID, $paramArray[1] is the url param $logParams = ''; foreach ($Ids as $n => $id) { $logParams .= '&logid[]=' . intval($id); } $revert = '(' . $this->skin->makeKnownLinkObj($revdel, $this->message['revdel-restore'], 'target=' . $title->getPrefixedUrl() . $logParams) . ')'; } // Self-created users } else { if (self::typeAction($row, 'newusers', 'create2')) { if (isset($paramArray[0])) { $revert = $this->skin->userToolLinks($paramArray[0], $title->getDBkey(), true); } else { # Fall back to a blue contributions link $revert = $this->skin->userToolLinks(1, $title->getDBkey()); } if ($time < '20080129000000') { # Suppress $comment from old entries (before 2008-01-29), # not needed and can contain incorrect links $comment = ''; } // Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters. } else { wfRunHooks('LogLine', array($row->log_type, $row->log_action, $title, $paramArray, &$comment, &$revert, $row->log_timestamp)); } } } } } } } } } // Event description if (self::isDeleted($row, LogPage::DELETED_ACTION)) { $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>'; } else { $action = LogPage::actionText($row->log_type, $row->log_action, $title, $this->skin, $paramArray, true); } if ($revert != '') { $revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>'; } return Xml::tags('li', array("class" => "mw-logline-{$row->log_type}"), $del . $time . ' ' . $userLink . ' ' . $action . ' ' . $comment . ' ' . $revert); }
/** * @param Object $s a single row from the result set * @return string Formatted HTML list item * @private */ function logLine($s) { global $wgLang; $title = Title::makeTitle($s->log_namespace, $s->log_title); $user = Title::makeTitleSafe(NS_USER, $s->user_name); $time = $wgLang->timeanddate(wfTimestamp(TS_MW, $s->log_timestamp), true); // Enter the existence or non-existence of this page into the link cache, // for faster makeLinkObj() in LogPage::actionText() $linkCache =& LinkCache::singleton(); if ($s->page_id) { $linkCache->addGoodLinkObj($s->page_id, $title); } else { $linkCache->addBadLinkObj($title); } $userLink = $this->skin->userLink($s->log_user, $s->user_name) . $this->skin->userToolLinks($s->log_user, $s->user_name); $comment = $this->skin->commentBlock($s->log_comment); $paramArray = LogPage::extractParams($s->log_params); $revert = ''; if ($s->log_type == 'move' && isset($paramArray[0])) { $specialTitle = Title::makeTitle(NS_SPECIAL, 'Movepage'); $destTitle = Title::newFromText($paramArray[0]); if ($destTitle) { $revert = '(' . $this->skin->makeKnownLinkObj($specialTitle, wfMsg('revertmove'), 'wpOldTitle=' . urlencode($destTitle->getPrefixedDBkey()) . '&wpNewTitle=' . urlencode($title->getPrefixedDBkey()) . '&wpReason=' . urlencode(wfMsgForContent('revertmove')) . '&wpMovetalk=0') . ')'; } } // WERELATE: newuser log global $wgUser; if ($s->log_type == 'newuser') { if (!$wgUser->isAllowed('block')) { // block normal users from seeing IP addresses $comment = ''; } else { if (isset($paramArray[0])) { // add a block link $specialTitle = Title::makeTitle(NS_SPECIAL, 'Blockip'); $revert = '(' . $this->skin->makeKnownLinkObj($specialTitle, wfMsgHtml('blocklink') . ' IP', 'ip=' . urlencode($paramArray[0])) . ')'; } } } $action = LogPage::actionText($s->log_type, $s->log_action, $title, $this->skin, $paramArray, true, true); $out = "<li>{$time} {$userLink} {$action} {$comment} {$revert}</li>\n"; return $out; }
/** * @param Object $s a single row from the result set * @return string Formatted HTML list item * @private */ function logLine($s) { global $wgLang, $wgUser, $wgContLang; $skin = $wgUser->getSkin(); $title = Title::makeTitle($s->log_namespace, $s->log_title); $time = $wgLang->timeanddate(wfTimestamp(TS_MW, $s->log_timestamp), true); // Enter the existence or non-existence of this page into the link cache, // for faster makeLinkObj() in LogPage::actionText() $linkCache =& LinkCache::singleton(); if ($s->page_id) { $linkCache->addGoodLinkObj($s->page_id, $title); } else { $linkCache->addBadLinkObj($title); } $userLink = $this->skin->userLink($s->log_user, $s->user_name) . $this->skin->userToolLinksRedContribs($s->log_user, $s->user_name); $comment = $wgContLang->getDirMark() . $this->skin->commentBlock($s->log_comment); $paramArray = LogPage::extractParams($s->log_params); $revert = ''; // show revertmove link if (!($this->flags & self::NO_ACTION_LINK)) { if ($s->log_type == 'move' && isset($paramArray[0]) && $wgUser->isAllowed('move')) { $destTitle = Title::newFromText($paramArray[0]); if ($destTitle) { $revert = '(' . $this->skin->makeKnownLinkObj(SpecialPage::getTitleFor('Movepage'), wfMsg('revertmove'), 'wpOldTitle=' . urlencode($destTitle->getPrefixedDBkey()) . '&wpNewTitle=' . urlencode($title->getPrefixedDBkey()) . '&wpReason=' . urlencode(wfMsgForContent('revertmove')) . '&wpMovetalk=0') . ')'; } // show undelete link } elseif ($s->log_action == 'delete' && $wgUser->isAllowed('delete')) { $revert = '(' . $this->skin->makeKnownLinkObj(SpecialPage::getTitleFor('Undelete'), wfMsg('undeletelink'), 'target=' . urlencode($title->getPrefixedDBkey())) . ')'; // show unblock link } elseif ($s->log_action == 'block' && $wgUser->isAllowed('block')) { $revert = '(' . $skin->makeKnownLinkObj(SpecialPage::getTitleFor('Ipblocklist'), wfMsg('unblocklink'), 'action=unblock&ip=' . urlencode($s->log_title)) . ')'; // show change protection link } elseif (($s->log_action == 'protect' || $s->log_action == 'modify') && $wgUser->isAllowed('protect')) { $revert = '(' . $skin->makeKnownLinkObj($title, wfMsg('protect_change'), 'action=unprotect') . ')'; // Show unmerge link } elseif ($s->log_action == 'merge') { $merge = SpecialPage::getTitleFor('Mergehistory'); $revert = '(' . $this->skin->makeKnownLinkObj($merge, wfMsg('revertmerge'), wfArrayToCGI(array('target' => $paramArray[0], 'dest' => $title->getPrefixedText(), 'mergepoint' => $paramArray[1]))) . ')'; } elseif (wfRunHooks('LogLine', array($s->log_type, $s->log_action, $title, $paramArray, &$comment, &$revert, $s->log_timestamp))) { // wfDebug( "Invoked LogLine hook for " $s->log_type . ", " . $s->log_action . "\n" ); // Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters. } } $action = LogPage::actionText($s->log_type, $s->log_action, $title, $this->skin, $paramArray, true); $out = "<li>{$time} {$userLink} {$action} {$comment} {$revert}</li>\n"; return $out; }
/** * Enhanced RC ungrouped line. * * @param $rcObj RecentChange * @return String: a HTML formated line (generated using $r) */ protected function recentChangesBlockLine($rcObj) { global $wgRCShowChangedSize; wfProfileIn(__METHOD__); $query['curid'] = $rcObj->mAttribs['rc_cur_id']; $type = $rcObj->mAttribs['rc_type']; $logType = $rcObj->mAttribs['rc_log_type']; if ($logType) { # Log entry $classes = 'mw-enhanced-rc ' . Sanitizer::escapeClass('mw-changeslist-log-' . $logType . '-' . $rcObj->mAttribs['rc_title']); } else { $classes = 'mw-enhanced-rc ' . Sanitizer::escapeClass('mw-changeslist-ns' . $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title']); } $r = Html::openElement('table', array('class' => $classes)) . Html::openElement('tr'); $r .= '<td class="mw-enhanced-rc">' . $this->spacerArrow(); # Flag and Timestamp if ($type == RC_MOVE || $type == RC_MOVE_OVER_REDIRECT) { $r .= '    '; // 4 flags -> 4 spaces } else { $r .= $this->recentChangesFlags(array('newpage' => $type == RC_NEW, 'minor' => $rcObj->mAttribs['rc_minor'], 'unpatrolled' => $rcObj->unpatrolled, 'bot' => $rcObj->mAttribs['rc_bot'])); } $r .= ' ' . $rcObj->timestamp . ' </td><td>'; # Article or log link if ($logType) { $logtitle = SpecialPage::getTitleFor('Log', $logType); $logname = LogPage::logName($logType); $r .= '(' . Linker::linkKnown($logtitle, htmlspecialchars($logname)) . ')'; } else { $this->insertArticleLink($r, $rcObj, $rcObj->unpatrolled, $rcObj->watched); } # Diff and hist links if ($type != RC_LOG) { $r .= ' (' . $rcObj->difflink . $this->message['pipe-separator']; $query['action'] = 'history'; $r .= Linker::linkKnown($rcObj->getTitle(), $this->message['hist'], array(), $query) . ')'; } $r .= ' . . '; # Character diff if ($wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference())) { $r .= "{$cd} . . "; } # User/talk $r .= ' ' . $rcObj->userlink . $rcObj->usertalklink; # Log action (if any) if ($logType) { if ($this->isDeleted($rcObj, LogPage::DELETED_ACTION)) { $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>'; } else { $r .= ' ' . LogPage::actionText($logType, $rcObj->mAttribs['rc_log_action'], $rcObj->getTitle(), $this->getSkin(), LogPage::extractParams($rcObj->mAttribs['rc_params']), true, true); } } $this->insertComment($r, $rcObj); $this->insertRollback($r, $rcObj); # Tags $classes = explode(' ', $classes); $this->insertTags($r, $rcObj, $classes); # Show how many people are watching this if enabled $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers); $r .= "</td></tr></table>\n"; wfProfileOut(__METHOD__); return $r; }
/** * @param Array $row row * @returns string */ private function logLine($row) { global $wgLang; $date = $wgLang->timeanddate($row->log_timestamp); $paramArray = LogPage::extractParams($row->log_params); $title = Title::makeTitle($row->log_namespace, $row->log_title); $logtitle = SpecialPage::getTitleFor('Log'); $loglink = $this->skin->makeKnownLinkObj($logtitle, wfMsgHtml('log'), wfArrayToCGI(array('page' => $title->getPrefixedUrl()))); // Action text if (!LogEventsList::userCan($row, LogPage::DELETED_ACTION)) { $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>'; } else { $action = LogPage::actionText($row->log_type, $row->log_action, $title, $this->skin, $paramArray, true, true); if ($row->log_deleted & LogPage::DELETED_ACTION) { $action = '<span class="history-deleted">' . $action . '</span>'; } } // User links $userLink = $this->skin->userLink($row->log_user, User::WhoIs($row->log_user)); if (LogEventsList::isDeleted($row, LogPage::DELETED_USER)) { $userLink = '<span class="history-deleted">' . $userLink . '</span>'; } // Comment $comment = $wgLang->getDirMark() . $this->skin->commentBlock($row->log_comment); if (LogEventsList::isDeleted($row, LogPage::DELETED_COMMENT)) { $comment = '<span class="history-deleted">' . $comment . '</span>'; } return "<li>({$loglink}) {$date} {$userLink} {$action} {$comment}</li>"; }
/** * @param Object $s a single row from the result set * @return string Formatted HTML list item * @private */ function logLine($s) { global $wgLang, $wgLinkCache; $title = Title::makeTitle($s->log_namespace, $s->log_title); $user = Title::makeTitleSafe(NS_USER, $s->user_name); $time = $wgLang->timeanddate($s->log_timestamp, true); // Enter the existence or non-existence of this page into the link cache, // for faster makeLinkObj() in LogPage::actionText() if ($s->page_id) { $wgLinkCache->addGoodLinkObj($s->page_id, $title); } else { $wgLinkCache->addBadLinkObj($title); } $userLink = $this->skin->makeLinkObj($user, htmlspecialchars($s->user_name)); $comment = $this->skin->commentBlock($s->log_comment); $paramArray = LogPage::extractParams($s->log_params); $revert = ''; if ($s->log_type == 'move' && isset($paramArray[0])) { $specialTitle = Title::makeTitle(NS_SPECIAL, 'Movepage'); $destTitle = Title::newFromText($paramArray[0]); if ($destTitle) { $revert = '(' . $this->skin->makeKnownLinkObj($specialTitle, wfMsg('revertmove'), 'wpOldTitle=' . urlencode($destTitle->getPrefixedDBkey()) . '&wpNewTitle=' . urlencode($title->getPrefixedDBkey()) . '&wpReason=' . urlencode(wfMsgForContent('revertmove')) . '&wpMovetalk=0') . ')'; } } $action = LogPage::actionText($s->log_type, $s->log_action, $title, $this->skin, $paramArray, true); $out = "<li>{$time} {$userLink} {$action} {$comment} {$revert}</li>\n"; return $out; }
/** * Enhanced RC ungrouped line. * @return string a HTML formated line (generated using $r) */ protected function recentChangesBlockLine($rcObj) { global $wgContLang, $wgRCShowChangedSize; wfProfileIn(__METHOD__); # 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. $classes = array(); // TODO implement extract($rcObj->mAttribs); $curIdEq = "curid={$rc_cur_id}"; $r = '<table cellspacing="0" cellpadding="0" border="0" style="background: none"><tr>'; $r .= '<td valign="top" style="white-space: nowrap"><tt>' . $this->spacerArrow() . ' '; # Flag and Timestamp if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) { $r .= ' '; // 4 flags -> 4 spaces } else { $r .= $this->recentChangesFlags($rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot); } $r .= ' ' . $rcObj->timestamp . ' </tt></td><td>'; # Article or log link if ($rc_log_type) { $logtitle = Title::newFromText("Log/{$rc_log_type}", NS_SPECIAL); $logname = LogPage::logName($rc_log_type); $r .= '(' . $this->skin->makeKnownLinkObj($logtitle, $logname) . ')'; } else { $this->insertArticleLink($r, $rcObj, $rcObj->unpatrolled, $rcObj->watched); } # Diff and hist links if ($rc_type != RC_LOG) { $r .= ' (' . $rcObj->difflink . $this->message['semicolon-separator']; $r .= $this->skin->makeKnownLinkObj($rcObj->getTitle(), $this->message['hist'], $curIdEq . '&action=history') . ')'; } $r .= ' . . '; # Character diff if ($wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference())) { $r .= "{$cd} . . "; } # User/talk $r .= ' ' . $rcObj->userlink . $rcObj->usertalklink; # Log action (if any) if ($rc_log_type) { if ($this->isDeleted($rcObj, LogPage::DELETED_ACTION)) { $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>'; } else { $r .= ' ' . LogPage::actionText($rc_log_type, $rc_log_action, $rcObj->getTitle(), $this->skin, LogPage::extractParams($rc_params), true, true); } } $this->insertComment($r, $rcObj); $this->insertRollback($r, $rcObj); # Tags $this->insertTags($r, $rcObj, $classes); # Show how many people are watching this if enabled $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers); $r .= "</td></tr></table>\n"; wfProfileOut(__METHOD__); return $r; }
/** * Enhanced RC ungrouped line. * @return String: a HTML formated line (generated using $r) */ protected function recentChangesBlockLine($rcObj) { global $wgRCShowChangedSize; wfProfileIn(__METHOD__); # 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. // TODO implement extract($rcObj->mAttribs); $query['curid'] = $rc_cur_id; if ($rc_log_type) { # Log entry $classes = 'mw-enhanced-rc ' . Sanitizer::escapeClass('mw-changeslist-log-' . $rc_log_type . '-' . $rcObj->mAttribs['rc_title']); } else { $classes = 'mw-enhanced-rc ' . Sanitizer::escapeClass('mw-changeslist-ns' . $rcObj->mAttribs['rc_namespace'] . '-' . $rcObj->mAttribs['rc_title']); } $r = Html::openElement('table', array('class' => $classes)) . Html::openElement('tr'); $r .= '<td class="mw-enhanced-rc">' . $this->spacerArrow() . ' '; # Flag and Timestamp if ($rc_type == RC_MOVE || $rc_type == RC_MOVE_OVER_REDIRECT) { $r .= '    '; // 4 flags -> 4 spaces } else { $r .= $this->recentChangesFlags($rc_type == RC_NEW, $rc_minor, $rcObj->unpatrolled, ' ', $rc_bot); } $r .= ' ' . $rcObj->timestamp . ' </td><td style="padding:0px;">'; # Article or log link if ($rc_log_type) { $logtitle = Title::newFromText("Log/{$rc_log_type}", NS_SPECIAL); $logname = LogPage::logName($rc_log_type); $r .= '(' . $this->skin->link($logtitle, $logname, array(), array(), array('known', 'noclasses')) . ')'; } else { $this->insertArticleLink($r, $rcObj, $rcObj->unpatrolled, $rcObj->watched); } # Diff and hist links if ($rc_type != RC_LOG) { $r .= ' (' . $rcObj->difflink . $this->message['pipe-separator']; $query['action'] = 'history'; $r .= $this->skin->link($rcObj->getTitle(), $this->message['hist'], array(), $query, array('known', 'noclasses')) . ')'; } $r .= ' . . '; # Character diff if ($wgRCShowChangedSize && ($cd = $rcObj->getCharacterDifference())) { $r .= "{$cd} . . "; } # User/talk $r .= ' ' . $rcObj->userlink . $rcObj->usertalklink; # Log action (if any) if ($rc_log_type) { if ($this->isDeleted($rcObj, LogPage::DELETED_ACTION)) { $r .= ' <span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>'; } else { $r .= ' ' . LogPage::actionText($rc_log_type, $rc_log_action, $rcObj->getTitle(), $this->skin, LogPage::extractParams($rc_params), true, true); } } $this->insertComment($r, $rcObj); $this->insertRollback($r, $rcObj); # Tags $classes = explode(' ', $classes); $this->insertTags($r, $rcObj, $classes); # Show how many people are watching this if enabled $r .= $this->numberofWatchingusers($rcObj->numberofWatchingusers); $r .= "</td></tr></table>\n"; wfProfileOut(__METHOD__); return $r; }
protected function getActionMessage() { $entry = $this->entry; $action = LogPage::actionText($entry->getType(), $entry->getSubtype(), $entry->getTarget(), $this->plaintext ? null : $this->context->getSkin(), (array) $entry->getParameters(), !$this->plaintext); $performer = $this->getPerformerElement(); if (!$this->irctext) { $sep = $this->msg('word-separator'); $sep = $this->plaintext ? $sep->text() : $sep->escaped(); $action = $performer . $sep . $action; } return $action; }
/** * @param $row Row: a single row from the result set * @return String: Formatted HTML list item */ public function logLine($row) { global $wgLang, $wgUser, $wgContLang; $title = Title::makeTitle($row->log_namespace, $row->log_title); $classes = array("mw-logline-{$row->log_type}"); $time = $wgLang->timeanddate(wfTimestamp(TS_MW, $row->log_timestamp), true); // User links if (self::isDeleted($row, LogPage::DELETED_USER)) { $userLink = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-user') . '</span>'; } else { $userLink = $this->skin->userLink($row->log_user, $row->user_name) . $this->skin->userToolLinks($row->log_user, $row->user_name, true, 0, $row->user_editcount); } // Comment if (self::isDeleted($row, LogPage::DELETED_COMMENT)) { $comment = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-comment') . '</span>'; } else { $comment = $wgContLang->getDirMark() . $this->skin->commentBlock($row->log_comment); } // Extract extra parameters $paramArray = LogPage::extractParams($row->log_params); $revert = $del = ''; // Some user can hide log items and have review links if (!($this->flags & self::NO_ACTION_LINK) && $wgUser->isAllowed('deletedhistory')) { // Don't show useless link to people who cannot hide revisions if ($row->log_deleted || $wgUser->isAllowed('deleterevision')) { $del = $this->getShowHideLinks($row) . ' '; } } // Add review links and such... if ($this->flags & self::NO_ACTION_LINK || $row->log_deleted & LogPage::DELETED_ACTION) { // Action text is suppressed... } else { if (self::typeAction($row, 'move', 'move', 'move') && !empty($paramArray[0])) { $destTitle = Title::newFromText($paramArray[0]); if ($destTitle) { $revert = '(' . $this->skin->link(SpecialPage::getTitleFor('Movepage'), $this->message['revertmove'], array(), array('wpOldTitle' => $destTitle->getPrefixedDBkey(), 'wpNewTitle' => $title->getPrefixedDBkey(), 'wpReason' => wfMsgForContent('revertmove'), 'wpMovetalk' => 0), array('known', 'noclasses')) . ')'; } // Show undelete link } else { if (self::typeAction($row, array('delete', 'suppress'), 'delete', 'deletedhistory')) { if (!$wgUser->isAllowed('undelete')) { $viewdeleted = $this->message['undeleteviewlink']; } else { $viewdeleted = $this->message['undeletelink']; } $revert = '(' . $this->skin->link(SpecialPage::getTitleFor('Undelete'), $viewdeleted, array(), array('target' => $title->getPrefixedDBkey()), array('known', 'noclasses')) . ')'; // Show unblock/change block link } else { if (self::typeAction($row, array('block', 'suppress'), array('block', 'reblock'), 'block')) { $revert = '(' . $this->skin->link(SpecialPage::getTitleFor('Ipblocklist'), $this->message['unblocklink'], array(), array('action' => 'unblock', 'ip' => $row->log_title), 'known') . $this->message['pipe-separator'] . $this->skin->link(SpecialPage::getTitleFor('Blockip', $row->log_title), $this->message['change-blocklink'], array(), array(), 'known') . ')'; // Show change protection link } else { if (self::typeAction($row, 'protect', array('modify', 'protect', 'unprotect'))) { $revert .= ' (' . $this->skin->link($title, $this->message['hist'], array(), array('action' => 'history', 'offset' => $row->log_timestamp)); if ($wgUser->isAllowed('protect')) { $revert .= $this->message['pipe-separator'] . $this->skin->link($title, $this->message['protect_change'], array(), array('action' => 'protect'), 'known'); } $revert .= ')'; // Show unmerge link } else { if (self::typeAction($row, 'merge', 'merge', 'mergehistory')) { $merge = SpecialPage::getTitleFor('Mergehistory'); $revert = '(' . $this->skin->link($merge, $this->message['revertmerge'], array(), array('target' => $paramArray[0], 'dest' => $title->getPrefixedDBkey(), 'mergepoint' => $paramArray[1]), array('known', 'noclasses')) . ')'; // If an edit was hidden from a page give a review link to the history } else { if (self::typeAction($row, array('delete', 'suppress'), 'revision', 'deletedhistory')) { if (count($paramArray) >= 2) { // Different revision types use different URL params... $key = $paramArray[0]; // $paramArray[1] is a CSV of the IDs $Ids = explode(',', $paramArray[1]); $query = $paramArray[1]; $revert = array(); // Diff link for single rev deletions if (count($Ids) == 1) { // Live revision diffs... if (in_array($key, array('oldid', 'revision'))) { $revert[] = $this->skin->link($title, $this->message['diff'], array(), array('diff' => intval($Ids[0]), 'unhide' => 1), array('known', 'noclasses')); // Deleted revision diffs... } else { if (in_array($key, array('artimestamp', 'archive'))) { $revert[] = $this->skin->link(SpecialPage::getTitleFor('Undelete'), $this->message['diff'], array(), array('target' => $title->getPrefixedDBKey(), 'diff' => 'prev', 'timestamp' => $Ids[0]), array('known', 'noclasses')); } } } // View/modify link... $revert[] = $this->skin->link(SpecialPage::getTitleFor('Revisiondelete'), $this->message['revdel-restore'], array(), array('target' => $title->getPrefixedText(), 'type' => $key, 'ids' => $query), array('known', 'noclasses')); // Pipe links $revert = wfMsg('parentheses', $wgLang->pipeList($revert)); } // Hidden log items, give review link } else { if (self::typeAction($row, array('delete', 'suppress'), 'event', 'deletedhistory')) { if (count($paramArray) >= 1) { $revdel = SpecialPage::getTitleFor('Revisiondelete'); // $paramArray[1] is a CSV of the IDs $Ids = explode(',', $paramArray[0]); $query = $paramArray[0]; // Link to each hidden object ID, $paramArray[1] is the url param $revert = '(' . $this->skin->link($revdel, $this->message['revdel-restore'], array(), array('target' => $title->getPrefixedText(), 'type' => 'logging', 'ids' => $query), array('known', 'noclasses')) . ')'; } // Self-created users } else { if (self::typeAction($row, 'newusers', 'create2')) { if (isset($paramArray[0])) { $revert = $this->skin->userToolLinks($paramArray[0], $title->getDBkey(), true); } else { # Fall back to a blue contributions link $revert = $this->skin->userToolLinks(1, $title->getDBkey()); } if ($time < '20080129000000') { # Suppress $comment from old entries (before 2008-01-29), # not needed and can contain incorrect links $comment = ''; } // Do nothing. The implementation is handled by the hook modifiying the passed-by-ref parameters. } else { wfRunHooks('LogLine', array($row->log_type, $row->log_action, $title, $paramArray, &$comment, &$revert, $row->log_timestamp)); } } } } } } } } } // Event description if (self::isDeleted($row, LogPage::DELETED_ACTION)) { $action = '<span class="history-deleted">' . wfMsgHtml('rev-deleted-event') . '</span>'; } else { $action = LogPage::actionText($row->log_type, $row->log_action, $title, $this->skin, $paramArray, true); } // Any tags... list($tagDisplay, $newClasses) = ChangeTags::formatSummaryRow($row->ts_tags, 'logevent'); $classes = array_merge($classes, $newClasses); if ($revert != '') { $revert = '<span class="mw-logevent-actionlink">' . $revert . '</span>'; } $time = htmlspecialchars($time); return Xml::tags('li', array("class" => implode(' ', $classes)), $del . $time . ' ' . $userLink . ' ' . $action . ' ' . $comment . ' ' . $revert . " {$tagDisplay}") . "\n"; }