User:Woozle/MoreBoxes

page type::article thing type::MediaWiki extension

About
MoreBoxes is a quick extension to allow adding additional dynamic content to a MediaWiki skin. I originally created it so I could add Flattr and Kachingle buttons to Issuepedia, but discontinued that after a few months; I am not currently using the extension, so I don't know if it works with more recent MediaWiki versions. (It's simple enough, though, so it should.)

Example Usage
...where $txtHdr is already defined (see MediaWiki/Flattr for an example): $wxgMoreBoxes = array (   'head' => array ( array (	'html' => $txtHdr     ) ),   'foot' => array (	// "foot" to put it in the footer, "side" to put it in the control sidebar array (	'title'	=> 'support free sites',	'html'	=>	 ' '      ) ), );

Code
'MoreBoxes',    'author'=>'Woozle Staddon',    //'url'=>'http://jimbojw.com/wiki/index.php?title=ShareThis',    'description'=>'Allows admin-configurable arbitrary HTML to be displayed below toolboxes',    'version'=>'0.1' );
 * 1) Credits

$wgExtensionFunctions[] = 'wfMoreBoxesExtensionSetup';
 * 1) Add Extension Functions

function wfMoreBoxesExtensionSetup { global $wgMessageCache; //, $wgParser, $wxgMoreBoxesTitle; // start a sequence of one or more toolboxes: $wgMessageCache->addMessage('more-boxes-toolbox-escape-html',       "\n\t\t\t\n\t\t \n\t "    ); // start an individual toolbox: $wgMessageCache->addMessage('more-boxes-toolbox-open-html',       "\n\t".        "\n\t\t $1 ".        "\n\t\t"    ); // close an individual toolbox: $wgMessageCache->addMessage('more-boxes-toolbox-shut-html',"\n\t "); // finish a sequence of one or more toolboxes - open empty tags for skin code to close, so everything is balanced: $wgMessageCache->addMessage('more-boxes-toolbox-return-html',"\n\t "); } /** * Parser hook for the tag extension. */ /* function wfMoreBoxesParserHook($text, $params, &$parser) {
 * 1) Sets up the parser hook and global messages

global $wgMoreBoxesHTML, $wgTitle, $wgStylePath; $output = $wgMoreBoxesHTML; return $output; } $wgHooks['MonoBookTemplateToolboxEnd'][] = 'wxfInsertMoreBoxesSidebar'; $wgHooks['SkinAfterBottomScripts'][] = 'wxfInsertMoreBoxesFooter'; $wgHooks['BeforePageDisplay'][] = 'wxfInsertMoreBoxesHeader';
 * 1) Add hook for Monobook sidebar integration
 * 1) Add hook for Monobook sidebar integration

/** * Injects MoreBoxes code into the sidebar (hooks MonoBookTemplateToolboxEnd). * Note: This must be activiated by setting $wgShowMoreBoxesSidebar = true in Localsettings */ function wxfInsertMoreBoxesSidebar($template) { global $wxgMoreBoxes;

if (is_array($wxgMoreBoxes)) { if (is_array($wxgMoreBoxes['side'])) { $arHere = $wxgMoreBoxes['side']; $out = NULL; # Close out the MonoBook toolbox and create a new "moreboxes" portlet $out .= wfMsgForContent('more-boxes-toolbox-escape-html',nz($box['title'])); $idx = 0; foreach ($arHere as $id => $box) { $idx++; $strTitle = nz($box['title']); $out .= wfMsgForContent('more-boxes-toolbox-open-html',$strTitle,$idx); $out .= nz($box['html']); $out .= wfMsgForContent('more-boxes-toolbox-shut-html'); }	   $out .= wfMsgForContent('more-boxes-toolbox-return-html'); # Output the code and close the final box: echo($out); }   }    return true; } function wxfInsertMoreBoxesFooter( $skin, &$text ) { global $wxgMoreBoxes;

if (is_array($wxgMoreBoxes)) { if (is_array($wxgMoreBoxes['foot'])) { $arHere = $wxgMoreBoxes['foot']; $out = NULL; foreach ($arHere as $id => $box) { $out .= nz($box['html']); }	   $text .= $out; }   }    return TRUE; } function wxfInsertMoreBoxesHeader( &$objOut, &$objSkin ) { global $wxgMoreBoxes;

if (is_array($wxgMoreBoxes)) { if (is_array(nz($wxgMoreBoxes['head']))) { $out = NULL; $arHere = $wxgMoreBoxes['head']; foreach ($arHere as $id => $box) { $out .= nz($box['html']); }	   $objOut->addScript($out); }   }    return TRUE; }

} # Closing MW Environment wrapper