本文整理汇总了PHP中RecentChange::getAttributes方法的典型用法代码示例。如果您正苦于以下问题:PHP RecentChange::getAttributes方法的具体用法?PHP RecentChange::getAttributes怎么用?PHP RecentChange::getAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RecentChange
的用法示例。
在下文中一共展示了RecentChange::getAttributes方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLine
/**
* Generates a notification that can be easily interpreted by a machine.
* @see RCFeedFormatter::getLine
*/
public function getLine(array $feed, RecentChange $rc, $actionComment)
{
global $wgCanonicalServer, $wgScriptPath;
$attrib = $rc->getAttributes();
$packet = array('id' => $attrib['rc_id'], 'type' => $attrib['rc_type'], 'namespace' => $rc->getTitle()->getNamespace(), 'title' => $rc->getTitle()->getPrefixedText(), 'comment' => $attrib['rc_comment'], 'timestamp' => (int) wfTimestamp(TS_UNIX, $attrib['rc_timestamp']), 'user' => $attrib['rc_user_text'], 'bot' => (bool) $attrib['rc_bot']);
if (isset($feed['channel'])) {
$packet['channel'] = $feed['channel'];
}
$type = $attrib['rc_type'];
if ($type == RC_EDIT || $type == RC_NEW) {
global $wgUseRCPatrol, $wgUseNPPatrol;
$packet['minor'] = $attrib['rc_minor'];
if ($wgUseRCPatrol || $type == RC_NEW && $wgUseNPPatrol) {
$packet['patrolled'] = $attrib['rc_patrolled'];
}
}
switch ($type) {
case RC_EDIT:
$packet['length'] = array('old' => $attrib['rc_old_len'], 'new' => $attrib['rc_new_len']);
$packet['revision'] = array('old' => $attrib['rc_last_oldid'], 'new' => $attrib['rc_this_oldid']);
break;
case RC_NEW:
$packet['length'] = array('old' => null, 'new' => $attrib['rc_new_len']);
$packet['revision'] = array('old' => null, 'new' => $attrib['rc_this_oldid']);
break;
case RC_LOG:
$packet['log_type'] = $attrib['rc_log_type'];
$packet['log_action'] = $attrib['rc_log_action'];
if ($attrib['rc_params']) {
wfSuppressWarnings();
$params = unserialize($attrib['rc_params']);
wfRestoreWarnings();
if ($attrib['rc_params'] == serialize(false) || $params !== false) {
// From ApiQueryLogEvents::addLogParams
$logParams = array();
// Keys like "4::paramname" can't be used for output so we change them to "paramname"
foreach ($params as $key => $value) {
if (strpos($key, ':') === false) {
$logParams[$key] = $value;
continue;
}
$logParam = explode(':', $key, 3);
$logParams[$logParam[2]] = $value;
}
$packet['log_params'] = $logParams;
} else {
$packet['log_params'] = explode("\n", $attrib['rc_params']);
}
}
$packet['log_action_comment'] = $actionComment;
break;
}
$packet['server_url'] = $wgCanonicalServer;
$packet['server_script_path'] = $wgScriptPath ?: '/';
$packet['wiki'] = wfWikiID();
return $this->formatArray($packet);
}
示例2: getLine
/**
* @see RCFeedFormatter::getLine
*/
public function getLine(array $feed, RecentChange $rc, $actionComment)
{
global $wgWWRCFeedHideLogs, $wgWWRCFeedHideNamespaces;
$attribs = $rc->getAttributes();
if ($attribs['rc_type'] == RC_LOG) {
$title = Title::newFromText('Log/' . $attribs['rc_log_type'], NS_SPECIAL);
} else {
$title =& $rc->getTitle();
}
if ($attribs['rc_type'] == RC_LOG && in_array($attribs['rc_log_type'], $wgWWRCFeedHideLogs)) {
return null;
} elseif (in_array($title->getNamespace(), $wgWWRCFeedHideNamespaces)) {
return null;
}
// if we aren't hiding it, let the core class do all the heavy lifting
return parent::getLine($feed, $rc, $actionComment);
}
示例3: getLine
/**
* @see RCFeedFormatter::getLine
*/
public function getLine(array $feed, RecentChange $rc, $actionComment)
{
global $wgUseRCPatrol, $wgUseNPPatrol, $wgLocalInterwikis, $wgCanonicalServer, $wgScript, $wgDBname;
$attribs = $rc->getAttributes();
if ($attribs['rc_type'] == RC_LOG) {
// Don't use SpecialPage::getTitleFor, backwards compatibility with
// IRC API which expects "Log".
$titleObj = Title::newFromText('Log/' . $attribs['rc_log_type'], NS_SPECIAL);
} else {
$titleObj =& $rc->getTitle();
}
$title = $titleObj->getPrefixedText();
$title = self::cleanupForIRC($title);
if ($attribs['rc_type'] == RC_LOG) {
$url = '';
} else {
$url = $wgCanonicalServer . $wgScript;
if ($attribs['rc_type'] == RC_NEW) {
$query = '?oldid=' . $attribs['rc_this_oldid'];
} else {
$query = '?diff=' . $attribs['rc_this_oldid'] . '&oldid=' . $attribs['rc_last_oldid'];
}
if ($wgUseRCPatrol || $attribs['rc_type'] == RC_NEW && $wgUseNPPatrol) {
$query .= '&rcid=' . $attribs['rc_id'];
}
// HACK: We need this hook for WMF's secure server setup
Hooks::run('IRCLineURL', array(&$url, &$query, $rc));
$url .= $query;
}
if ($attribs['rc_old_len'] !== null && $attribs['rc_new_len'] !== null) {
$szdiff = $attribs['rc_new_len'] - $attribs['rc_old_len'];
if ($szdiff < -500) {
$szdiff = "{$szdiff}";
} elseif ($szdiff >= 0) {
$szdiff = '+' . $szdiff;
}
// @todo i18n with parentheses in content language?
$szdiff = '(' . $szdiff . ')';
} else {
$szdiff = '';
}
$user = self::cleanupForIRC($attribs['rc_user_text']);
if ($attribs['rc_type'] == RC_LOG) {
$targetText = $rc->getTitle()->getPrefixedText();
$comment = self::cleanupForIRC(str_replace("[[{$targetText}]]", "[[02{$targetText}10]]", $actionComment));
$flag = $attribs['rc_log_action'];
} else {
$comment = self::cleanupForIRC($attribs['rc_comment']);
$flag = '';
if (!$attribs['rc_patrolled'] && ($wgUseRCPatrol || $attribs['rc_type'] == RC_NEW && $wgUseNPPatrol)) {
$flag .= '!';
}
$flag .= ($attribs['rc_type'] == RC_NEW ? "N" : "") . ($attribs['rc_minor'] ? "M" : "") . ($attribs['rc_bot'] ? "B" : "");
}
if ($feed['add_interwiki_prefix'] === true && $wgLocalInterwikis) {
// we use the first entry in $wgLocalInterwikis in recent changes feeds
$prefix = $wgLocalInterwikis[0];
} elseif ($feed['add_interwiki_prefix']) {
$prefix = $feed['add_interwiki_prefix'];
} else {
$prefix = false;
}
if ($prefix !== false) {
$titleString = "14[[03{$prefix}:07{$title}14]]";
} else {
$titleString = "14[[07{$title}14]]";
}
# see http://www.irssi.org/documentation/formats for some colour codes. prefix is \003,
# no colour (\003) switches back to the term default
$fullString = "{$wgDBname} 5* {$titleString}4 {$flag}10 " . "02{$url} 5* 03{$user} 5* {$szdiff} 10{$comment}\n";
return $fullString;
}
示例4: getLine
/**
* Generates a notification that can be easily interpreted by a machine.
* @see RCFeedFormatter::getLine
*/
public function getLine( array $feed, RecentChange $rc, $actionComment ) {
global $wgCanonicalServer, $wgScriptPath, $wgDBname;
$attrib = $rc->getAttributes();
$packet = array(
// Usually, RC ID is exposed only for patrolling purposes,
// but there is no real reason not to expose it in other cases,
// and I can see how this may be potentially useful for clients.
'id' => $attrib['rc_id'],
'type' => $attrib['rc_type'],
'namespace' => $rc->getTitle()->getNamespace(),
'title' => $rc->getTitle()->getPrefixedText(),
'comment' => $attrib['rc_comment'],
'timestamp' => (int)wfTimestamp( TS_UNIX, $attrib['rc_timestamp'] ),
'user' => $attrib['rc_user_text'],
'bot' => (bool)$attrib['rc_bot'],
);
if ( isset( $feed['channel'] ) ) {
$packet['channel'] = $feed['channel'];
}
$type = $attrib['rc_type'];
if ( $type == RC_EDIT || $type == RC_NEW ) {
global $wgUseRCPatrol, $wgUseNPPatrol;
$packet['minor'] = $attrib['rc_minor'];
if ( $wgUseRCPatrol || ( $type == RC_NEW && $wgUseNPPatrol ) ) {
$packet['patrolled'] = $attrib['rc_patrolled'];
}
}
switch ( $type ) {
case RC_EDIT:
$packet['length'] = array( 'old' => $attrib['rc_old_len'], 'new' => $attrib['rc_new_len'] );
$packet['revision'] = array( 'old' => $attrib['rc_last_oldid'], 'new' => $attrib['rc_this_oldid'] );
break;
case RC_NEW:
$packet['length'] = array( 'old' => NULL, 'new' => $attrib['rc_new_len'] );
$packet['revision'] = array( 'old' => NULL, 'new' => $attrib['rc_this_oldid'] );
break;
case RC_LOG:
$packet['log_type'] = $attrib['rc_log_type'];
$packet['log_action'] = $attrib['rc_log_action'];
if ( $attrib['rc_params'] ) {
wfSuppressWarnings();
$params = unserialize( $attrib['rc_params'] );
wfRestoreWarnings();
if (
// If it's an actual serialised false...
$attrib['rc_params'] == serialize( false ) ||
// Or if we did not get false back when trying to unserialise
$params !== false
) {
// From ApiQueryLogEvents::addLogParams
$logParams = array();
// Keys like "4::paramname" can't be used for output so we change them to "paramname"
foreach ( $params as $key => $value ) {
if ( strpos( $key, ':' ) === false ) {
$logParams[$key] = $value;
continue;
}
$logParam = explode( ':', $key, 3 );
$logParams[$logParam[2]] = $value;
}
$packet['log_params'] = $logParams;
} else {
$packet['log_params'] = explode( "\n", $attrib['rc_params'] );
}
}
$packet['log_action_comment'] = $actionComment;
break;
}
$packet['server_url'] = $wgCanonicalServer;
$packet['server_script_path'] = $wgScriptPath ?: '/';
$packet['wiki'] = $wgDBname;
return FormatJson::encode( $packet );
}