-
Notifications
You must be signed in to change notification settings - Fork 0
/
NewsLogProxy.php
42 lines (35 loc) · 984 Bytes
/
NewsLogProxy.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<?php
class NewsLogProxy extends SpecialLog {
function __construct( $data=[] ) {
$this->data = data;
$this->logs = array();
}
// Replace page construction methods with no-ops.
function setHeaders() {}
protected function addHeader( $type ) {}
function outputHeader() {}
function getOutput() { return $this; }
// As an output.
function addModules( $x ) {}
function addHTML( $html ) {
// Success case.
preg_match_all('/<li><input[^>]*/> ([^<]+) (.*?) <span class="comment">(.*)</span> .*?</li>#', $html, $matches);
foreach($matches as $match) {
array_push($this->logs, array(
"date" => $match[1], // TODO: Better date detection?
"action" => $match[2],
"comment" => $match[3]
);
}
$this->addedHTML = $html;
}
function addWikiMsg( $msg ) {
// Failure case.
// TODO?
}
// Get request replaced with whatever params we want.
public function getRequest() {
// Must return a WebRequest.
return new FauxRequest( $this->data );
}
}