Extension:ApiMagicWord/ApiMagicWord.php
From MediaWiki.org
<?php /** * ApiMagicWord extension provide a wiki text access to enabled Application Programming Interfaces (API) of MediaWiki Web sites. Local site API included, if enabled. By this way, it permits, from within each wiki page, to interact (get and post data) with all concerned sites contents. * If set $wgApiMagicWordUseNoPrefixHash to true, then the functions are without the preceeding hash symbol, and more like the built in variables. * * * @package MediaWiki * @subpackage Extensions * * @link http://www.mediawiki.org/wiki/Extension:ApiMagicWord Documentation * * @authors Eric Larcher <eric.larcher@yahoo.fr> * @copyright Copyright © 2009 Eric Larcher * @license http://www.gnu.org/copyleft/gpl.html GNU General Public License 2.0 or later * @version 0.1 * @version 0.1b somes bugs fixe. Debug mode off. * @version 0.1c Add "delimiter" parameter for list of lists of results. */ # Not a valid entry point, skip unless MEDIAWIKI is defined if (!defined('MEDIAWIKI')) { echo <<<EOT To install ApiMagicWord as a parser hook, put the following line in LocalSettings.php: require_once( "\$IP/extensions/ApiMagicWord/ApiMagicWord.php" ); EOT; exit( 1 ); } # For defining ways to others extension files $dir = dirname(__FILE__) .'/'; /** REGISTRATION */ # Define the setup function $wgExtensionFunctions[] = 'wfSetupApiMagicWord'; $wgExtensionCredits['parserhook'][] = array( 'path' => __FILE__, 'name' => 'ApiMagicWord', 'version' => '0.1b', 'author' => '[http://ericlarcher.fr Eric Larcher]', 'email' => 'Eric Larcher <{firstname}.{surname}@yahoo.fr>', 'description' => 'ApiMagicWord extension provide a wiki text access to enabled Application Programming Interfaces (API) of MediaWiki Web sites.', 'descriptionmsg' => 'apimw-desc', 'url' => 'http://www.mediawiki.org/wiki/Extension:ApiMagicWord', ); $wgAutoloadClasses['ApiMagicWord'] = $dir . 'ApiMagicWord_body.php'; # Defining messages file $wgExtensionMessagesFiles['ApiMagicWord'] = $dir . 'ApiMagicWord.i18n.php'; # Define the function for the magic word translation $wgHooks['LanguageGetMagic'][] = 'wfApiMagicWordLanguageGetMagic'; function wfSetupApiMagicWord() { global $wgParser, $wgApiMagicWord, $wgMessageCache, $wgApiMagicWordMessages, $wgApiMagicWordUseNoPrefixHash; $wgApiMagicWord = new ApiMagicWord(); $flags = $wgApiMagicWordUseNoPrefixHash ? SFH_NO_HASH : 0; $wgParser->setFunctionHook( 'api', array( &$wgApiMagicWord, 'api' ), $flags ); } function wfApiMagicWordLanguageGetMagic( &$magicWords, $langCode ) { require_once( dirname( __FILE__ ) . '/ApiMagicWord.i18n.magic.php' ); foreach( efApiMagicWordWords( $langCode ) as $word => $trans ) $magicWords[$word] = $trans; # unless we return true, other parser functions extensions won't get loaded. return true; }
