diff --git a/HeaderFooter.class.php b/HeaderFooter.class.php index e72e2f2..45bad84 100644 --- a/HeaderFooter.class.php +++ b/HeaderFooter.class.php @@ -7,67 +7,66 @@ class HeaderFooter /** * Main Hook */ - public static function hOutputPageParserOutput( &$op, $parserOutput ) - { + public static function hOutputPageParserOutput( &$op, $parserOutput ) { + $action = $op->parserOptions()->getUser()->getRequest()->getVal("action"); - if ( ($action == 'edit') || ($action == 'submit') || ($action == 'history') ) + if ( ($action == 'edit') || ($action == 'submit') || ($action == 'history') ) { return true; - + } + global $wgTitle; - + $ns = $wgTitle->getNsText(); $name = $wgTitle->getPrefixedDBKey(); - + $text = $parserOutput->getText(); - + $nsheader = "hf-nsheader-$ns"; - $nsfooter = "hf-nsfooter-$ns"; - + $nsfooter = "hf-nsfooter-$ns"; + $header = "hf-header-$name"; - $footer = "hf-footer-$name"; + $footer = "hf-footer-$name"; $text = '
'.self::conditionalInclude( $text, '__NOHEADER__', $header ).'
'.$text; $text = '
'.self::conditionalInclude( $text, '__NONSHEADER__', $nsheader ).'
'.$text; $text .= ''; $text .= '
'.self::conditionalInclude( $text, '__NONSFOOTER__', $nsfooter ).'
'; - + $parserOutput->setText( $text ); - + return true; - } + } /** * Verifies & Strips ''disable command'', returns $content if all OK. */ - static function conditionalInclude( &$text, $disableWord, &$msgId ) - { - // is there a disable command lurking around? - $disable = strpos( $text, $disableWord ) !== false; - - // if there is, get rid of it - // make sure that the disableWord does not break the REGEX below! - $text = preg_replace('/'.$disableWord.'/si', '', $text ); - - // if there is a disable command, then don't return anything - if ($disable) - return null; - - // FIXME: make it look like this (though this doesn't work) - // $msgText = wfMessage( $msgId, array( 'parseinline' ) ); - $msgText = wfMsgExt( $msgId, array( 'parseinline' ) ); - - // don't need to bother if there is no content. - if (empty( $msgText )) - return null; - - // FIXME: make it look like this (though this may not work) - // if (wfMessage( $msgId, $msgText )) - if (wfEmptyMsg( $msgId, $msgText )) - return null; - - return $msgText; - } - + static function conditionalInclude( &$text, $disableWord, &$msgId ) { -} // END CLASS DEFINITION + // is there a disable command lurking around? + $disable = strpos( $text, $disableWord ) !== false; + + // if there is, get rid of it + // make sure that the disableWord does not break the REGEX below! + $text = preg_replace('/'.$disableWord.'/si', '', $text ); + + // if there is a disable command, then don't return anything + if ( $disable ) { + return null; + } + + $msgText = wfMessage( $msgId )->parse(); + + // don't need to bother if there is no content. + if ( empty( $msgText ) ) { + return null; + } + + if ( wfMessage( $msgId )->inContentLanguage()->isBlank() ) { + return null; + } + + return $msgText; + } + +} \ No newline at end of file diff --git a/HeaderFooter.php b/HeaderFooter.php index d801837..14ea67c 100644 --- a/HeaderFooter.php +++ b/HeaderFooter.php @@ -3,17 +3,16 @@ * @author Jean-Lou Dupont * @author Jamesmontalvo3 * @package HeaderFooter - * @version 2.1.0 - * @Id $Id: HeaderFooter.php 821 2008-01-04 02:36:30Z jeanlou.dupont $ + * @version 2.1.1 */ # Credits $GLOBALS['wgExtensionCredits']['other'][] = array( - 'name' => 'HeaderFooter', - 'version' => '2.1.0', + 'name' => 'HeaderFooter', + 'version' => '2.1.1', 'author' => 'Jean-Lou Dupont, James Montalvo, Douglas Mason', 'description' => 'Enables per-page/per-namespace headers and footers', - 'url' => 'http://mediawiki.org/wiki/Extension:HeaderFooter', + 'url' => 'http://mediawiki.org/wiki/Extension:HeaderFooter', ); # Hooks