Permalink
Browse files

Adds action to the revision array.

  • Loading branch information...
jimsafley committed Jun 23, 2011
1 parent 51c7b8d commit 3229adfad3cd337367e7141c6a29fbe4a1a7112b
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/Scripto.php
View
@@ -651,6 +651,15 @@ public function getRevision($revisionId)
);
$page = current($response['query']['pages']);
+ // Set the action.
+ $actions = array('Replaced content', 'Unprotected', 'Protected', 'Created page');
+ $actionPattern = '/^(' . implode('|', $actions) . ').+$/';
+ if (preg_match($actionPattern, $page['revisions'][0]['comment'])) {
+ $action = preg_replace($actionPattern, '$1', $page['revisions'][0]['comment']);
+ } else {
+ $action = '';
+ }
+
// Parse the wikitext into HTML.
$response = $this->_mediawiki->parse(
array('text' => '__NOEDITSECTION__' . $page['revisions'][0]['*'])
@@ -661,6 +670,7 @@ public function getRevision($revisionId)
'user' => $page['revisions'][0]['user'],
'timestamp' => $page['revisions'][0]['timestamp'],
'comment' => $page['revisions'][0]['comment'],
+ 'action' => $action,
'size' => $page['revisions'][0]['size'],
'wikitext' => $page['revisions'][0]['*'],
'html' => $response['parse']['text']['*']);

0 comments on commit 3229adf

Please sign in to comment.