Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Adds action to the revision array.

  • Loading branch information...
commit 3229adfad3cd337367e7141c6a29fbe4a1a7112b 1 parent 51c7b8d
@jimsafley jimsafley authored
Showing with 10 additions and 0 deletions.
  1. +10 −0 lib/Scripto.php
View
10 lib/Scripto.php
@@ -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']['*']);
Please sign in to comment.
Something went wrong with that request. Please try again.