Skip to content

Instantly share code, notes, and snippets.

@jdlrobson
Last active August 29, 2015 14:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save jdlrobson/f9af964eec72f29797d0 to your computer and use it in GitHub Desktop.
Save jdlrobson/f9af964eec72f29797d0 to your computer and use it in GitHub Desktop.
A boiler plate for a map extension
<?php
/**
* A boilerplate for resource loader modules
*/
$wgMFResourceBoilerplate = array(
'localBasePath' => __DIR__,
'remoteExtPath' => 'WikiMaps',
);
$modules = array(
);
$wgResourceModules = array_merge( $wgResourceModules, $modules );
<?php
/**
* Hooks for Geo extension.
*
* @file
*
* @ingroup Extensions
* @ingroup EventLogging
*
*/
class GeoHooks {
/**
* CustomEditor hook handler
* @see https://www.mediawiki.org/wiki/Manual:Hooks/CustomEditor
*
* @param Article $article
* @param User $user
* @return bool
*/
public static function onCustomEditor( $article, $user ) {
if( $article->getTitle()->getNamespace() === NS_MAP ) {
$output = $article->getContext()->getOutput();
$output->addHtml( 'DO THE MAP EDIT INTERFACE' );
return false;
}
return true;
}
public static function onBeforePageDisplay( $out, $skin ) {
$out->clearHtml();
$out->addHtml( 'PRINT MAP HERE' );
return true;
}
}
<?php
/*
* This file is part of the MediaWiki extension Geo
*
* VectorBeta is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 2 of the License, or
* (at your option) any later version.
*
* VectorBeta is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with Geo. If not, see <http://www.gnu.org/licenses/>.
*
* @file
* @ingroup extensions
*/
define( 'NS_MAP', 42 );
define( 'NS_MAP_TALK', 43 );
$wgExtraNamespaces[NS_MAP] = "Map";
$wgExtraNamespaces[NS_MAP_TALK] = "Map_talk";
// autoload extension classes
$autoloadClasses = array (
'GeoHooks' => 'includes/WikiMaps.hooks.php',
);
foreach ( $autoloadClasses as $className => $classFilename ) {
$wgAutoloadClasses[$className] = __DIR__ . "/$classFilename";
}
$wgHooks['CustomEditor'][] = 'GeoHooks::onCustomEditor';
$wgHooks['BeforePageDisplay'][] = 'GeoHooks::onBeforePageDisplay';
// ResourceLoader modules
require_once __DIR__ . "/includes/Resources.php";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment