From Wikipedia, the free encyclopedia
<?
if (!defined('MEDIAWIKI')) die();
/** fnProjectStaticTopText
*
* Adds static text to the top of specified project pages. It particular, it forces the verbiage
* about the Sandbox and Introduction instructions to automatically appear at the top of the
* respective pages, eliminating the need for a template (and thus preventing vandalism).
* The text itself is controlled by corresponding MediaWiki-namespace pages (in the form
* "MediaWiki:Header-pagename").
*
* ©2006 by It's dot com; released under the GNU Free Documentation License, Version 1.2 or any later version
*/
$wgProjectStaticTopTextPages = array('Sandbox', 'Introduction'); // array of pages to be used in hook
# Call the hook function
$wgHooks['ArticleViewHeader'][] = 'fnProjectStaticTopText';
$wgExtensionFunctions[] = 'exfAddProjectStaticTopTextMessages';
# Extension to enable static-text pages to appear in the list of system messages
function exfAddProjectStaticTopTextMessages() {
global $wgMessageCache, $wgProjectStaticTopTextPages;
foreach ($wgProjectStaticTopTextPages as $i) $wgMessageCache->addMessages( array( strtolower( "header-$i" ) => '' ) ); // add to message cache
}
# The hook function
function fnProjectStaticTopText( &$article, $outputDone, $pcache ) {
global $wgOut, $wgProjectStaticTopTextPages;
$title = $article->mTitle->mTextform;
if ( $article->mTitle->mNamespace == NS_PROJECT &&
in_array( $title, $wgProjectStaticTopTextPages ) ) {
$wgOut->addWikiText( wfMsg( strtolower( "header-$title" ) ) );
}
return true;
}
?>