MediaWiki  1.23.1
MachineReadableRCFeedFormatter.php
Go to the documentation of this file.
1 <?php
2 
28 
34  abstract protected function formatArray( array $packet );
35 
40  public function getLine( array $feed, RecentChange $rc, $actionComment ) {
41  global $wgCanonicalServer, $wgScriptPath;
42  $attrib = $rc->getAttributes();
43 
44  $packet = array(
45  // Usually, RC ID is exposed only for patrolling purposes,
46  // but there is no real reason not to expose it in other cases,
47  // and I can see how this may be potentially useful for clients.
48  'id' => $attrib['rc_id'],
49  'type' => $attrib['rc_type'],
50  'namespace' => $rc->getTitle()->getNamespace(),
51  'title' => $rc->getTitle()->getPrefixedText(),
52  'comment' => $attrib['rc_comment'],
53  'timestamp' => (int)wfTimestamp( TS_UNIX, $attrib['rc_timestamp'] ),
54  'user' => $attrib['rc_user_text'],
55  'bot' => (bool)$attrib['rc_bot'],
56  );
57 
58  if ( isset( $feed['channel'] ) ) {
59  $packet['channel'] = $feed['channel'];
60  }
61 
62  $type = $attrib['rc_type'];
63  if ( $type == RC_EDIT || $type == RC_NEW ) {
64  global $wgUseRCPatrol, $wgUseNPPatrol;
65 
66  $packet['minor'] = $attrib['rc_minor'];
67  if ( $wgUseRCPatrol || ( $type == RC_NEW && $wgUseNPPatrol ) ) {
68  $packet['patrolled'] = $attrib['rc_patrolled'];
69  }
70  }
71 
72  switch ( $type ) {
73  case RC_EDIT:
74  $packet['length'] = array(
75  'old' => $attrib['rc_old_len'],
76  'new' => $attrib['rc_new_len']
77  );
78  $packet['revision'] = array(
79  'old' => $attrib['rc_last_oldid'],
80  'new' => $attrib['rc_this_oldid']
81  );
82  break;
83 
84  case RC_NEW:
85  $packet['length'] = array( 'old' => null, 'new' => $attrib['rc_new_len'] );
86  $packet['revision'] = array( 'old' => null, 'new' => $attrib['rc_this_oldid'] );
87  break;
88 
89  case RC_LOG:
90  $packet['log_type'] = $attrib['rc_log_type'];
91  $packet['log_action'] = $attrib['rc_log_action'];
92  if ( $attrib['rc_params'] ) {
94  $params = unserialize( $attrib['rc_params'] );
96  if (
97  // If it's an actual serialised false...
98  $attrib['rc_params'] == serialize( false ) ||
99  // Or if we did not get false back when trying to unserialise
100  $params !== false
101  ) {
102  // From ApiQueryLogEvents::addLogParams
103  $logParams = array();
104  // Keys like "4::paramname" can't be used for output so we change them to "paramname"
105  foreach ( $params as $key => $value ) {
106  if ( strpos( $key, ':' ) === false ) {
107  $logParams[$key] = $value;
108  continue;
109  }
110  $logParam = explode( ':', $key, 3 );
111  $logParams[$logParam[2]] = $value;
112  }
113  $packet['log_params'] = $logParams;
114  } else {
115  $packet['log_params'] = explode( "\n", $attrib['rc_params'] );
116  }
117  }
118  $packet['log_action_comment'] = $actionComment;
119  break;
120  }
121 
122  $packet['server_url'] = $wgCanonicalServer;
123  $packet['server_script_path'] = $wgScriptPath ?: '/';
124  $packet['wiki'] = wfWikiID();
125 
126  return $this->formatArray( $packet );
127  }
128 }
php
skin txt MediaWiki includes four core it has been set as the default in MediaWiki since the replacing Monobook it had been been the default skin since before being replaced by Vector largely rewritten in while keeping its appearance Several legacy skins were removed in the as the burden of supporting them became too heavy to bear Those in etc for skin dependent CSS etc for skin dependent JavaScript These can also be customised on a per user by etc This feature has led to a wide variety of user styles becoming that gallery is a good place to ending in php
Definition: skin.txt:62
RecentChange\getAttributes
getAttributes()
Definition: RecentChange.php:781
RecentChange
Utility class for creating new RC entries.
Definition: RecentChange.php:63
wfTimestamp
wfTimestamp( $outputtype=TS_UNIX, $ts=0)
Get a timestamp string in one of various formats.
Definition: GlobalFunctions.php:2483
RC_LOG
const RC_LOG
Definition: Defines.php:181
wfSuppressWarnings
wfSuppressWarnings( $end=false)
Reference-counted warning suppression.
Definition: GlobalFunctions.php:2387
MachineReadableRCFeedFormatter
Abstract class so there can be multiple formatters outputting the same data.
Definition: MachineReadableRCFeedFormatter.php:27
$params
$params
Definition: styleTest.css.php:40
RC_EDIT
const RC_EDIT
Definition: Defines.php:178
MachineReadableRCFeedFormatter\formatArray
formatArray(array $packet)
Take the packet and return the formatted string.
wfRestoreWarnings
wfRestoreWarnings()
Restore error level to previous value.
Definition: GlobalFunctions.php:2417
array
the array() calling protocol came about after MediaWiki 1.4rc1.
List of Api Query prop modules.
global
when a variable name is used in a it is silently declared as a new masking the global
Definition: design.txt:93
wfWikiID
wfWikiID()
Get an ASCII string identifying this wiki This is used as a prefix in memcached keys.
Definition: GlobalFunctions.php:3604
$value
$value
Definition: styleTest.css.php:45
RC_NEW
const RC_NEW
Definition: Defines.php:179
TS_UNIX
const TS_UNIX
Unix time - the number of seconds since 1970-01-01 00:00:00 UTC.
Definition: GlobalFunctions.php:2426
MachineReadableRCFeedFormatter\getLine
getLine(array $feed, RecentChange $rc, $actionComment)
Generates a notification that can be easily interpreted by a machine.
Definition: MachineReadableRCFeedFormatter.php:40
as
This document is intended to provide useful advice for parties seeking to redistribute MediaWiki to end users It s targeted particularly at maintainers for Linux since it s been observed that distribution packages of MediaWiki often break We ve consistently had to recommend that users seeking support use official tarballs instead of their distribution s and this often solves whatever problem the user is having It would be nice if this could such as
Definition: distributors.txt:9
RecentChange\getTitle
& getTitle()
Definition: RecentChange.php:200
RCFeedFormatter
Interface for RC feed formatters.
Definition: RCFeedFormatter.php:27
$type
$type
Definition: testCompression.php:46