本文整理汇总了PHP中LogFormatter::newFromRow方法的典型用法代码示例。如果您正苦于以下问题:PHP LogFormatter::newFromRow方法的具体用法?PHP LogFormatter::newFromRow怎么用?PHP LogFormatter::newFromRow使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LogFormatter
的用法示例。
在下文中一共展示了LogFormatter::newFromRow方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: updateCheckUserData
/**
* 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) = IP::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);
$context = RequestContext::newExtraneousContext($target);
$formatter = LogFormatter::newFromRow($rc->mAttribs);
$formatter->setContext($context);
$actionText = $formatter->getPlainActionText();
} 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;
}
示例2: getHTML
/**
* @return string A HTML <li> element representing this revision, showing
* change tags and everything
*/
public function getHTML()
{
$date = htmlspecialchars($this->list->getLanguage()->userTimeAndDate($this->row->log_timestamp, $this->list->getUser()));
$title = Title::makeTitle($this->row->log_namespace, $this->row->log_title);
$formatter = LogFormatter::newFromRow($this->row);
$formatter->setContext($this->list->getContext());
$formatter->setAudience(LogFormatter::FOR_THIS_USER);
// Log link for this page
$loglink = Linker::link(SpecialPage::getTitleFor('Log'), $this->list->msg('log')->escaped(), array(), array('page' => $title->getPrefixedText()));
$loglink = $this->list->msg('parentheses')->rawParams($loglink)->escaped();
// User links and action text
$action = $formatter->getActionText();
// Comment
$comment = $this->list->getLanguage()->getDirMark() . $formatter->getComment();
if (LogEventsList::isDeleted($this->row, LogPage::DELETED_COMMENT)) {
$comment = '<span class="history-deleted">' . $comment . '</span>';
}
$content = "{$loglink} {$date} {$action} {$comment}";
$attribs = array();
$tags = $this->getTags();
if ($tags) {
list($tagSummary, $classes) = ChangeTags::formatSummaryRow($tags, 'edittags', $this->list->getContext());
$content .= " {$tagSummary}";
$attribs['class'] = implode(' ', $classes);
}
return Xml::tags('li', $attribs, $content);
}
示例3: execute
/**
* Main execution point
*
* @param string $subpage
*/
public function execute($subpage)
{
$this->rcSubpage = $subpage;
$this->setHeaders();
$this->outputHeader();
$this->addModules();
$rows = $this->getRows();
$opts = $this->getOptions();
if ($rows === false) {
if (!$this->including()) {
$this->doHeader($opts, 0);
$this->getOutput()->setStatusCode(404);
}
return;
}
$batch = new LinkBatch();
foreach ($rows as $row) {
$batch->add(NS_USER, $row->rc_user_text);
$batch->add(NS_USER_TALK, $row->rc_user_text);
$batch->add($row->rc_namespace, $row->rc_title);
if ($row->rc_source === RecentChange::SRC_LOG) {
$formatter = LogFormatter::newFromRow($row);
foreach ($formatter->getPreloadTitles() as $title) {
$batch->addObj($title);
}
}
}
$batch->execute();
$this->webOutput($rows, $opts);
$rows->free();
}
示例4: doTestLogFormatter
public function doTestLogFormatter($row, $extra)
{
RequestContext::resetMain();
$row = $this->expandDatabaseRow($row, $this->isLegacy($extra));
$formatter = LogFormatter::newFromRow($row);
$this->assertEquals($extra['text'], self::removeSomeHtml($formatter->getActionText()), 'Action text is equal to expected text');
$this->assertSame($extra['api'], self::removeApiMetaData($formatter->formatParametersForApi()), 'Api log params is equal to expected array');
}
示例5: formatDiff
/**
* Format a diff for the newsfeed
*
* @param $row Object: row from the recentchanges table
* @return String
*/
public static function formatDiff($row)
{
$titleObj = Title::makeTitle($row->rc_namespace, $row->rc_title);
$timestamp = wfTimestamp(TS_MW, $row->rc_timestamp);
$actiontext = '';
if ($row->rc_type == RC_LOG) {
$rcRow = (array) $row;
// newFromRow() only accepts arrays for RC rows
$actiontext = LogFormatter::newFromRow($rcRow)->getActionText();
}
return self::formatDiffRow($titleObj, $row->rc_last_oldid, $row->rc_this_oldid, $timestamp, $row->rc_deleted & Revision::DELETED_COMMENT ? wfMessage('rev-deleted-comment')->escaped() : $row->rc_comment, $actiontext);
}
示例6: getHTML
public function getHTML()
{
$date = htmlspecialchars($this->list->getLanguage()->userTimeAndDate($this->row->log_timestamp, $this->list->getUser()));
$title = Title::makeTitle($this->row->log_namespace, $this->row->log_title);
$formatter = LogFormatter::newFromRow($this->row);
$formatter->setContext($this->list->getContext());
$formatter->setAudience(LogFormatter::FOR_THIS_USER);
// Log link for this page
$loglink = Linker::link(SpecialPage::getTitleFor('Log'), $this->list->msg('log')->escaped(), array(), array('page' => $title->getPrefixedText()));
$loglink = $this->list->msg('parentheses')->rawParams($loglink)->escaped();
// User links and action text
$action = $formatter->getActionText();
// Comment
$comment = $this->list->getLanguage()->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} {$action} {$comment}</li>";
}
示例7: getStartBody
public function getStartBody()
{
# Do a link batch query
if ($this->getNumRows() > 0) {
$lb = new LinkBatch();
foreach ($this->mResult as $row) {
$lb->add($row->log_namespace, $row->log_title);
$lb->addObj(Title::makeTitleSafe(NS_USER, $row->user_name));
$lb->addObj(Title::makeTitleSafe(NS_USER_TALK, $row->user_name));
$formatter = LogFormatter::newFromRow($row);
foreach ($formatter->getPreloadTitles() as $title) {
$lb->addObj($title);
}
}
$lb->execute();
$this->mResult->seek(0);
}
return '';
}
示例8: extractRowInfo
//.........这里部分代码省略.........
if (Revision::userCanBitfield($row->rc_deleted, Revision::DELETED_USER, $user)) {
if ($this->fld_user) {
$vals['user'] = $row->rc_user_text;
}
if ($this->fld_userid) {
$vals['userid'] = $row->rc_user;
}
if (!$row->rc_user) {
$vals['anon'] = true;
}
}
}
/* Add flags, such as new, minor, bot. */
if ($this->fld_flags) {
$vals['bot'] = (bool) $row->rc_bot;
$vals['new'] = $row->rc_type == RC_NEW;
$vals['minor'] = (bool) $row->rc_minor;
}
/* Add sizes of each revision. (Only available on 1.10+) */
if ($this->fld_sizes) {
$vals['oldlen'] = intval($row->rc_old_len);
$vals['newlen'] = intval($row->rc_new_len);
}
/* Add the timestamp. */
if ($this->fld_timestamp) {
$vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->rc_timestamp);
}
/* Add edit summary / log summary. */
if ($this->fld_comment || $this->fld_parsedcomment) {
if ($row->rc_deleted & Revision::DELETED_COMMENT) {
$vals['commenthidden'] = true;
$anyHidden = true;
}
if (Revision::userCanBitfield($row->rc_deleted, Revision::DELETED_COMMENT, $user)) {
if ($this->fld_comment && isset($row->rc_comment)) {
$vals['comment'] = $row->rc_comment;
}
if ($this->fld_parsedcomment && isset($row->rc_comment)) {
$vals['parsedcomment'] = Linker::formatComment($row->rc_comment, $title);
}
}
}
if ($this->fld_redirect) {
$vals['redirect'] = (bool) $row->page_is_redirect;
}
/* Add the patrolled flag */
if ($this->fld_patrolled) {
$vals['patrolled'] = $row->rc_patrolled == 1;
$vals['unpatrolled'] = ChangesList::isUnpatrolled($row, $user);
}
if ($this->fld_loginfo && $row->rc_type == RC_LOG) {
if ($row->rc_deleted & LogPage::DELETED_ACTION) {
$vals['actionhidden'] = true;
$anyHidden = true;
}
if (LogEventsList::userCanBitfield($row->rc_deleted, LogPage::DELETED_ACTION, $user)) {
$vals['logid'] = intval($row->rc_logid);
$vals['logtype'] = $row->rc_log_type;
$vals['logaction'] = $row->rc_log_action;
$vals['logparams'] = LogFormatter::newFromRow($row)->formatParametersForApi();
}
}
if ($this->fld_tags) {
if ($row->ts_tags) {
$tags = explode(',', $row->ts_tags);
ApiResult::setIndexedTagName($tags, 'tag');
$vals['tags'] = $tags;
} else {
$vals['tags'] = array();
}
}
if ($this->fld_sha1 && $row->rev_sha1 !== null) {
if ($row->rev_deleted & Revision::DELETED_TEXT) {
$vals['sha1hidden'] = true;
$anyHidden = true;
}
if (Revision::userCanBitfield($row->rev_deleted, Revision::DELETED_TEXT, $user)) {
if ($row->rev_sha1 !== '') {
$vals['sha1'] = wfBaseConvert($row->rev_sha1, 36, 16, 40);
} else {
$vals['sha1'] = '';
}
}
}
if (!is_null($this->token)) {
$tokenFunctions = $this->getTokenFunctions();
foreach ($this->token as $t) {
$val = call_user_func($tokenFunctions[$t], $row->rc_cur_id, $title, RecentChange::newFromRow($row));
if ($val === false) {
$this->setWarning("Action '{$t}' is not allowed for the current user");
} else {
$vals[$t . 'token'] = $val;
}
}
}
if ($anyHidden && $row->rc_deleted & Revision::DELETED_RESTRICTED) {
$vals['suppressed'] = true;
}
return $vals;
}
示例9: insertLogEntry
/**
* Insert a formatted action
*
* @param $rc RecentChange
*/
public function insertLogEntry($rc)
{
$formatter = LogFormatter::newFromRow($rc->mAttribs);
$formatter->setShowUserToolLinks(true);
$mark = $this->getLanguage()->getDirMark();
return $formatter->getActionText() . " {$mark}" . $formatter->getComment();
}
示例10: extractRowInfo
private function extractRowInfo($row)
{
/* Determine the title of the page that has been changed. */
$title = Title::makeTitle($row->rc_namespace, $row->rc_title);
$user = $this->getUser();
/* Our output data. */
$vals = [];
$type = intval($row->rc_type);
$vals['type'] = RecentChange::parseFromRCType($type);
$anyHidden = false;
/* Create a new entry in the result for the title. */
if ($this->fld_title || $this->fld_ids) {
// These should already have been filtered out of the query, but just in case.
if ($type === RC_LOG && $row->rc_deleted & LogPage::DELETED_ACTION) {
$vals['actionhidden'] = true;
$anyHidden = true;
}
if ($type !== RC_LOG || LogEventsList::userCanBitfield($row->rc_deleted, LogPage::DELETED_ACTION, $user)) {
if ($this->fld_title) {
ApiQueryBase::addTitleInfo($vals, $title);
}
if ($this->fld_ids) {
$vals['pageid'] = intval($row->rc_cur_id);
$vals['revid'] = intval($row->rc_this_oldid);
$vals['old_revid'] = intval($row->rc_last_oldid);
}
}
}
/* Add user data and 'anon' flag, if user is anonymous. */
if ($this->fld_user || $this->fld_userid) {
if ($row->rc_deleted & Revision::DELETED_USER) {
$vals['userhidden'] = true;
$anyHidden = true;
}
if (Revision::userCanBitfield($row->rc_deleted, Revision::DELETED_USER, $user)) {
if ($this->fld_userid) {
$vals['userid'] = (int) $row->rc_user;
// for backwards compatibility
$vals['user'] = (int) $row->rc_user;
}
if ($this->fld_user) {
$vals['user'] = $row->rc_user_text;
}
if (!$row->rc_user) {
$vals['anon'] = true;
}
}
}
/* Add flags, such as new, minor, bot. */
if ($this->fld_flags) {
$vals['bot'] = (bool) $row->rc_bot;
$vals['new'] = $row->rc_type == RC_NEW;
$vals['minor'] = (bool) $row->rc_minor;
}
/* Add sizes of each revision. (Only available on 1.10+) */
if ($this->fld_sizes) {
$vals['oldlen'] = intval($row->rc_old_len);
$vals['newlen'] = intval($row->rc_new_len);
}
/* Add the timestamp. */
if ($this->fld_timestamp) {
$vals['timestamp'] = wfTimestamp(TS_ISO_8601, $row->rc_timestamp);
}
if ($this->fld_notificationtimestamp) {
$vals['notificationtimestamp'] = $row->wl_notificationtimestamp == null ? '' : wfTimestamp(TS_ISO_8601, $row->wl_notificationtimestamp);
}
/* Add edit summary / log summary. */
if ($this->fld_comment || $this->fld_parsedcomment) {
if ($row->rc_deleted & Revision::DELETED_COMMENT) {
$vals['commenthidden'] = true;
$anyHidden = true;
}
if (Revision::userCanBitfield($row->rc_deleted, Revision::DELETED_COMMENT, $user)) {
if ($this->fld_comment && isset($row->rc_comment)) {
$vals['comment'] = $row->rc_comment;
}
if ($this->fld_parsedcomment && isset($row->rc_comment)) {
$vals['parsedcomment'] = Linker::formatComment($row->rc_comment, $title);
}
}
}
/* Add the patrolled flag */
if ($this->fld_patrol) {
$vals['patrolled'] = $row->rc_patrolled == 1;
$vals['unpatrolled'] = ChangesList::isUnpatrolled($row, $user);
}
if ($this->fld_loginfo && $row->rc_type == RC_LOG) {
if ($row->rc_deleted & LogPage::DELETED_ACTION) {
$vals['actionhidden'] = true;
$anyHidden = true;
}
if (LogEventsList::userCanBitfield($row->rc_deleted, LogPage::DELETED_ACTION, $user)) {
$vals['logid'] = intval($row->rc_logid);
$vals['logtype'] = $row->rc_log_type;
$vals['logaction'] = $row->rc_log_action;
$vals['logparams'] = LogFormatter::newFromRow($row)->formatParametersForApi();
}
}
if ($anyHidden && $row->rc_deleted & Revision::DELETED_RESTRICTED) {
$vals['suppressed'] = true;
//.........这里部分代码省略.........
示例11: insertLogEntry
/**
* Insert a formatted action
*
* @param $rc RecentChange
*/
public function insertLogEntry($rc)
{
$formatter = LogFormatter::newFromRow($rc->mAttribs);
$formatter->setShowUserToolLinks(true);
$mark = $this->getLanguage()->getDirMark();
// Start of Wikia change - @author nAndy
// modified for MW1.19 by macbre
$s = $formatter->getActionText() . " {$mark}" . $formatter->getComment();
wfRunHooks('ChangesListInsertLogEntry', array($this, $rc, &$s, $formatter, &$mark));
return $s;
// End of Wikia change
}