Commit da915b98 authored by Aran Dunkley's avatar Aran Dunkley

move TreeAndMenu over to new JSON loader

parent ebe549f0
<?php
/**
* TreeAndMenu extension - Adds #tree and #menu parser functions for collapsible treeview's and dropdown menus
*
* See http://www.mediawiki.org/wiki/Extension:TreeAndMenu for installation and usage details
* - Tree component uses the FancyTree jQuery plugin, see http://wwwendt.de/tech/fancytree (changed from dTree to FancyTree in version 4, March 2015)
* - Menu component uses Son of Suckerfish, see http://alistapart.com/article/dropdowns
*
* @file
* @ingroup Extensions
* @author Aran Dunkley [http://www.organicdesign.co.nz/nad User:Nad]
* @copyright © 2007-2015 Aran Dunkley
* @licence GNU General Public Licence 2.0 or later
*/
if( !defined( 'MEDIAWIKI' ) ) die( 'Not an entry point.' );
define( 'TREEANDMENU_VERSION','4.1.4, 2015-06-19' );
define( 'TREEANDMENU_TREE', 1 );
define( 'TREEANDMENU_MENU', 2 );
$wgTreeAndMenuPersistIfId = false; // Makes trees with id attributes have persistent state
$wgExtensionCredits['parserhook'][] = array(
'path' => __FILE__,
'name' => 'TreeAndMenu',
'author' => '[http://www.organicdesign.co.nz/aran Aran Dunkley]',
'url' => 'http://www.mediawiki.org/wiki/Extension:TreeAndMenu',
'descriptionmsg' => 'treeandmenu-desc',
'version' => TREEANDMENU_VERSION,
);
$wgMessagesDirs['TreeAndMenu'] = __DIR__ . '/i18n';
$wgExtensionMessagesFiles['TreeAndMenuMagic'] = __DIR__ . '/TreeAndMenu.i18n.magic.php';
require_once( __DIR__ . '/TreeAndMenu_body.php' );
new TreeAndMenu();
<?php
class TreeAndMenu {
public static $instance;
public static $instance = null;
function __construct() {
/**
* Called when the extension is first loaded
*/
public static function onLoad() {
global $wgExtensionFunctions;
$wgExtensionFunctions[] = 'TreeAndMenu::setup';
self::$instance = $this;
define( 'TREEANDMENU_TREE', 1 );
define( 'TREEANDMENU_MENU', 2 );
self::$instance = new self();
$wgExtensionFunctions[] = array( self::$instance, 'setup' );
}
/**
* Called at extension setup time, install hooks and module resources
*/
public static function setup() {
global $wgOut, $wgParser, $wgExtensionAssetsPath, $wgResourceModules;
// Add hooks
$wgParser->setFunctionHook( 'tree', array( self::$instance, 'expandTree' ) );
$wgParser->setFunctionHook( 'menu', array( self::$instance, 'expandMenu' ) );
// Add the Fancy Tree scripts and styles
$path = $wgExtensionAssetsPath . '/' . basename( __DIR__ ) . '/fancytree';
$wgResourceModules['ext.fancytree'] = array(
'scripts' => array( 'jquery.fancytree.js', 'jquery.fancytree.persist.js', 'jquery.fancytree.mediawiki.js', 'fancytree.js' ),
'dependencies' => array( 'jquery.ui.core', 'jquery.ui.widget', 'jquery.effects.blind', 'jquery.cookie' ),
'remoteBasePath' => $path,
'localBasePath' => __DIR__ . '/fancytree',
);
public function setup() {
global $wgOut, $wgParser, $wgExtensionAssetsPath, $wgAutoloadClasses, $IP, $wgResourceModules;
// Add parser hooks
$wgParser->setFunctionHook( 'tree', array( $this, 'expandTree' ) );
$wgParser->setFunctionHook( 'menu', array( $this, 'expandMenu' ) );
// This gets the remote path even if it's a symlink (MW1.25+)
$path = $wgExtensionAssetsPath . str_replace( "$IP/extensions", '', dirname( $wgAutoloadClasses[__CLASS__] ) );
// Fancytree script and styles
$wgResourceModules['ext.fancytree']['localBasePath'] = __DIR__ . '/fancytree';
$wgResourceModules['ext.fancytree']['remoteExtPath'] = "$path/fancytree";
$wgOut->addModules( 'ext.fancytree' );
$wgOut->addStyle( "$path/fancytree.css" );
$wgOut->addJsConfigVars( 'fancytree_path', $path );
// Add the Suckerfish scripts and styles
$path = $wgExtensionAssetsPath . '/' . basename( __DIR__ ) . '/suckerfish';
$wgResourceModules['ext.suckerfish'] = array(
'scripts' => array( 'suckerfish.js' ),
'dependencies' => array( 'jquery.client' ),
'remoteBasePath' => $path,
'localBasePath' => __DIR__ . '/suckerfish',
);
$wgOut->addStyle( "$path/fancytree/fancytree.css" );
$wgOut->addJsConfigVars( 'fancytree_path', "$path/fancytree" );
// Suckerfish menu script and styles
$wgResourceModules['ext.suckerfish']['localBasePath'] = __DIR__ . '/suckerfish';
$wgResourceModules['ext.suckerfish']['remoteExtPath'] = "$path/suckerfish";
$wgOut->addModules( 'ext.suckerfish' );
$wgOut->addStyle( "$path/suckerfish.css" );
$wgOut->addStyle( "$path/suckerfish/suckerfish.css" );
}
/**
......
{
"name": "TreeAndMenu",
"version": "4.2.0, 2015-06-21",
"author": ["[http://www.organicdesign.co.nz/aran Aran Dunkley]"],
"url": "http://www.mediawiki.org/wiki/Extension:TreeAndMenu",
"descriptionmsg": "treeandmenu-desc",
"license-name": "[https://www.gnu.org/licenses/gpl-2.0.html GNU General Public Licence 2.0] or later",
"type": "parserhook",
"callback": "TreeAndMenu::onLoad",
"config": {
"TreeAndMenuPersistIfId": false, "@": "Makes trees with id attributes have persistent state"
},
"AutoloadClasses": {
"TreeAndMenu": "TreeAndMenu_body.php"
},
"ExtensionMessagesFiles": {
"TreeAndMenuMagic": "TreeAndMenu.i18n.magic.php"
},
"MessagesDirs": {
"TreeAndMenu": ["i18n"]
},
"ResourceModules": {
"ext.fancytree": {
"scripts": [
"jquery.fancytree.js",
"jquery.fancytree.persist.js",
"jquery.fancytree.mediawiki.js",
"fancytree.js"
],
"dependencies": [
"jquery.ui.core",
"jquery.ui.widget",
"jquery.effects.blind",
"jquery.cookie"
]
},
"ext.suckerfish": {
"scripts": ["suckerfish.js"],
"dependencies": ["jquery.client"]
}
},
"@": "The paths will be populated later as it needs be calculated",
"ResourceFileModulePaths": {
"localBasePath": "",
"remoteExtPath": ""
}
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment