Extension:Workflow.php

From Organic Design wiki
Revision as of 00:27, 6 October 2007 by Nad (talk | contribs) (start from template)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

<?php

  1. Extension:Workflow
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.

Template:Php

  1. - Licenced under LGPL (http://www.gnu.org/copyleft/lesser.html)
  2. - Author: User:NadCategory:Extensions created with Template:Extension
  3. - Started: 2007-10-06

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

define('WORKFLOW_VERSION','0.0.0, 2007-10-06');

$wgWorkflowMagic = "tag"; $wgExtensionFunctions[] = 'wfSetupWorkflow'; $wgHooks['LanguageGetMagic'][] = 'wfWorkflowLanguageGetMagic';

$wgExtensionCredits['parserhook'][] = array( 'name' => 'Workflow', 'author' => 'User:Nad', 'description' => 'Allows dynamic content areas called tags which can be switched between pre-selected states by clicking. The states can contain normal content such as images and categorisation links.', 'url' => 'http://www.mediawiki.org/wiki/Extension:Workflow', 'version' => WORKFLOW_VERSION );

class Workflow {

# Constructor function Workflow() { global $wgParser,$wgWorkflowMagic; $wgParser->setFunctionHook($wgWorkflowMagic,array($this,'magic')); }

# Expand the tag-magic function magic(&$parser) {

# Populate $argv with both named and numeric parameters $argv = array(); foreach (func_get_args() as $arg) if (!is_object($arg)) { if (preg_match('/^(.+?)\\s*=\\s*(.+)$/',$arg,$match)) $argv[$match[1]] = $match[2]; else $argv[] = $arg; }

# Return result with available parser flags return array( $text, found => true, nowiki => false, noparse => false, noargs => false, isHTML => false );

}

# Needed in some versions to prevent Special:Version from breaking function __toString() { return 'Workflow'; }

	}
  1. Called from $wgExtensionFunctions array when initialising extensions

function wfSetupWorkflow() { global $wgWorkflow; $wgWorkflow = new Workflow(); }

  1. Needed in MediaWiki >1.8.0 for magic word hooks to work properly

function wfWorkflowLanguageGetMagic(&$magicWords,$langCode = 0) { global $wgWorkflowMagic; $magicWords[$wgWorkflowMagic] = array(0,$wgWorkflowMagic); return true; } ?>