Skip to content

Instantly share code, notes, and snippets.

@hartman
Forked from jdlrobson/Resources.php
Created May 9, 2014 12:48
Show Gist options
  • Save hartman/db00269fa64de9656747 to your computer and use it in GitHub Desktop.
Save hartman/db00269fa64de9656747 to your computer and use it in GitHub Desktop.
<?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 onAfterFinalPageOutput( $out ) {
$out->clearHtml();
$out->addHtml( 'yo' );
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' => 'Geo.hooks.php',
);
foreach ( $autoloadClasses as $className => $classFilename ) {
$wgAutoloadClasses[$className] = __DIR__ . "/$classFilename";
}
$wgHooks['CustomEditor'][] = 'GeoHooks::onCustomEditor';
$wgHooks['AfterFinalPageOutput'][] = 'GeoHooks::onAfterFinalPageOutput';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment