Difference between revisions of "Extension:Livelets.php"

From Organic Design wiki
(framework)
 
(moved to wikimedia)
 
(89 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<?
+
{{svn|http://svn.wikimedia.org/viewvc/mediawiki/trunk/extensions/Livelets}}
# LiveWiki Extension
 
# - Allows live articles to be transcluded which update automatically on change in a non-polling, fully event-driven way
 
# - Version 0.1 (2007-03-30)
 
# - See http://www.mediawiki.org/wiki/Extension:LiveWiki for installation and usage details
 
# - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
 
# - Author: http://www.organicdesign.co.nz/nad
 
  
$wgLiveWikiMagic              = "live"; # the parser-function name for doing live-transclusions
+
== Notes ==
$wgExtensionFunctions[]        = 'wfSetupLiveWiki';
+
Add dev notes here, e.g. regarding the SWF live updates
$wgHooks['LanguageGetMagic'][] = 'wfLiveWikiLanguageGetMagic';
 
 
 
class LiveWiki {
 
 
 
var $version = '0.1, 2007-03-30';
 
var $magic;
 
var $args;
 
var $id = 0;
 
 
 
# Constructor
 
function LiveWiki($magic) {
 
global $wgParser,$wgHooks;
 
$this->magic = $magic
 
$this->args  = array();
 
$wgParser->setFunctionHook($magic,array($this,'functionHook'));
 
$wgParser->setHook($magic,array($this,'tagHook'));
 
}
 
 
 
# Remove live container content, store its parameters and convert it to $magic tags
 
function functionHook(&$parser) {
 
$magic = $this->magic;
 
$id    = $this->id++;
 
$args  = array();
 
foreach (func_get_args() as $arg) if (!is_object($arg)) {
 
if (preg_match('/^(.+?)=(.+)$/',$arg,$match)) $args[$match[1]] = $match[2]; else $args[] = $arg;
 
}
 
$this->args[$id] = $args;
 
return "<$magic>$id</$magic>";
 
}
 
 
 
# Convert the $magic tags to client-side javascript request code from its stored parameters
 
function tagHook($id,$argv,&$parser) {
 
 
 
$args    = $this->args[$id];
 
 
 
return "";
 
}
 
 
 
# Called from $wgExtensionFunctions array when initialising extensions
 
function wfSetupLiveWiki() {
 
global $wgLiveWiki,$wgLiveWikiMagic;
 
$wgLiveWiki = new LiveWiki($wgLiveWikiMagic);
 
}
 
 
 
# Needed in MediaWiki >1.8.0 for magic word hooks to work properly
 
function wfLiveWikiLanguageGetMagic(&$magicWords,$langCode = 0) {
 
global $wgLiveWikiMagic;
 
$magicWords[$wgLiveWikiMagic] = array(0,$wgLiveWikiMagic);
 
return true;
 
}
 
?>
 

Latest revision as of 02:55, 4 September 2010

Info.svg This code is in our Git repository here.

Note: If there is no information in this page about this code and it's a MediaWiki extension, there may be something at mediawiki.org.

Notes

Add dev notes here, e.g. regarding the SWF live updates