Index: trunk/extensions/XMLRC/XMLRC.class.php |
— | — | @@ -9,16 +9,22 @@ |
10 | 10 | var $query; |
11 | 11 | var $format; |
12 | 12 | var $transport; |
| 13 | + var $filter; |
| 14 | + var $props; |
13 | 15 | |
14 | | - public function __construct() { |
15 | | - $this->transportConfig = $GLOBALS['wgXMLRCTransport']; |
16 | | - $this->filter = @$GLOBALS['wgXMLRCFilter']; |
| 16 | + public function __construct( $transportConfig, $props = null ) { |
| 17 | + $this->transportConfig = $transportConfig; |
| 18 | + $this->props = $props; |
17 | 19 | } |
18 | 20 | |
19 | 21 | public static function RecentChange_save( $rc ) { |
20 | | - $xmlrc = new XMLRC(); |
21 | | - $xmlrc->processRecentChange( $rc ); |
| 22 | + global $wgXMLRCTransport, $wgXMLRCProperties; |
22 | 23 | |
| 24 | + if ( !empty( $GLOBALS['wgXMLRCTransport'] ) ) { |
| 25 | + $xmlrc = new XMLRC( $wgXMLRCTransport, $wgXMLRCProperties ); |
| 26 | + $xmlrc->processRecentChange( $rc ); |
| 27 | + } |
| 28 | + |
23 | 29 | return true; //continue processing normally |
24 | 30 | } |
25 | 31 | |
— | — | @@ -60,19 +66,23 @@ |
61 | 67 | $main = $this->getMainModule(); |
62 | 68 | $this->query = new ApiQueryRecentChanges( $main, "recentchanges" ); |
63 | 69 | |
64 | | - //TODO: configure! |
65 | | - $prop['comment'] = true; |
66 | | - $prop['user'] = true; |
67 | | - $prop['flags'] = true; |
68 | | - $prop['timestamp'] = true; |
69 | | - $prop['title'] = true; |
70 | | - $prop['ids'] = true; |
71 | | - $prop['sizes'] = true; |
72 | | - $prop['redirect'] = true; |
73 | | - $prop['patrolled'] = true; |
74 | | - $prop['loginfo'] = true; |
75 | | - $prop['tags'] = true; |
| 70 | + $prop = $this->props; |
76 | 71 | |
| 72 | + if ( !$prop ) $prop = "title|timestamp|ids"; //default taken from the API |
| 73 | + |
| 74 | + if ( is_string( $prop ) ) { |
| 75 | + $prop = preg_split( '\\s*[,;/|+]\\s*', $prop ); |
| 76 | + } |
| 77 | + |
| 78 | + foreach ( $prop as $k => $v ) { |
| 79 | + if ( is_int( $k ) ) { |
| 80 | + unset( $prop[ $k ] ); |
| 81 | + $prop[ $v ] = true; |
| 82 | + } |
| 83 | + } |
| 84 | + |
| 85 | + unset( $prop[ 'patrolled' ] ); //restricted info, don't publish. API denies it. |
| 86 | + |
77 | 87 | $this->query->initProperties( $prop ); |
78 | 88 | |
79 | 89 | return $this->query; |
Index: trunk/extensions/XMLRC/XMLRC_UDP.class.php |
— | — | @@ -8,7 +8,7 @@ |
9 | 9 | function __construct( $config ) { |
10 | 10 | $this->conn = null; |
11 | 11 | |
12 | | - $this->address = $config['address']; |
| 12 | + $this->address = isset( $config['address'] ) ? $config['address'] : '127.0.0.1'; |
13 | 13 | $this->port = isset( $config['port'] ) ? $config['port'] : 4455; |
14 | 14 | } |
15 | 15 | |
Index: trunk/extensions/XMLRC/XMLRC.php |
— | — | @@ -18,11 +18,23 @@ |
19 | 19 | $dir = dirname(__FILE__) . '/'; |
20 | 20 | $wgExtensionMessagesFiles['XMLRC'] = $dir . 'XMLRC.i18n.php'; |
21 | 21 | |
22 | | -$wgXMLRCTransport = array( |
23 | | - 'class' => 'XMLRC_File', |
24 | | - 'file' => '/tmp/rc.xml', |
25 | | -); |
| 22 | +$wgXMLRCTransport = null; |
26 | 23 | |
| 24 | +#$wgXMLRCTransport = array( |
| 25 | +# 'class' => 'XMLRC_File', |
| 26 | +# 'file' => '/tmp/rc.xml', |
| 27 | +#); |
| 28 | + |
| 29 | +#$wgXMLRCTransport = array( |
| 30 | +# 'class' => 'XMLRC_UDP', |
| 31 | +# 'port' => 4455, |
| 32 | +# 'address' => '127.0.0.1', |
| 33 | +#); |
| 34 | + |
| 35 | +$wgXMLRCProperties = 'user|comment|flags|timestamp|title|ids|sizes|redirect|loginfo'; # sensible default |
| 36 | +# $wgXMLRCProperties = 'title|timestamp|ids'; # default as per the API |
| 37 | +# $wgXMLRCProperties = 'user|comment|parsedcomment|flags|timestamp|title|ids|sizes|redirect|loginfo|tags'; # everything except "patrolled", which is verboten |
| 38 | + |
27 | 39 | /* |
28 | 40 | $wgXMLRCTransport = array( |
29 | 41 | 'class' => 'XMLRC_XMPP', |
Index: trunk/extensions/XMLRC/bridge/udp2xmpp.py |
— | — | @@ -71,8 +71,6 @@ |
72 | 72 | self.loglevel = LOG_VERBOSE |
73 | 73 | self.wiki_info = wiki_info; |
74 | 74 | |
75 | | - #FIXME: test unicode! |
76 | | - |
77 | 75 | def warn(self, message): |
78 | 76 | if self.loglevel >= LOG_QUIET: |
79 | 77 | sys.stderr.write( "WARNING: %s\n" % ( message.encode( self.console_encoding ) ) ) |