Extension:EventPipe

From Organic Design wiki
Revision as of 01:47, 25 May 2009 by Nad (talk | contribs) (Extension for allowing wikid.pl to be notified of MW hook execution)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<?php /**Template:Php

Info.svg These are the MediaWiki extensions we're using and/or developing. Please refer to the information on the mediawiki.org wiki for installation and usage details. Extensions here which have no corresponding mediawiki article are either not ready for use or have been superseded. You can also browse our extension code in our local Subversion repository or our GitHub mirror.
* EventPipe extension - Allows selected events (hooks) to be forwarded to a local pipe
*
* @package MediaWiki
* @subpackage Extensions
* @author User:Nad
* @copyright © 2009 User:Nad
* @licence GNU General Public Licence 2.0 or later
*/

if ( !defined( 'MEDIAWIKI' ) ) die( 'Not an entry point.' );

define( 'EVENTPIPE_VERSION', '1.0.0, 2009-05-25' );

$wgEventPipePort = '2012'; $wgEventPipeList = array('PrefsPasswordAudit','ArticleSaveComplete');

$wgExtensionCredits['other'][] = array( 'name' => 'EventPipe', 'author' => 'User:Nad', 'description' => 'Allows selected events (hooks) to be forwarded to a local pipe', 'url' => 'http://www.organicdesign.co.nz/Extension:EventPipe', 'version' => EVENTPIPE_VERSION );

$wgExtensionFunctions[] = 'wfSetupEventPipe'; function wfSetupEventPipe() { global $wgHooks, $wgEventPipeList; foreach ( $wgEventPipeList as $hook ) { $callback = $wgHooks[$hook][] = "wfEventPipeOn$hook"; eval( "function $callback() { \$args=func_get_args();return wfEventPipeSend('$hook',\$args); }" ); } }

function wfEventPipeSend( $hook, $args ) { global $wgEventPipePort; file_get_contents( "http://127.0.0.1:$wgEventPipePort/$hook" ); # var_export( $args, true ), FILE_APPEND ); return true; }