Extension:BoilerplateSelection

What can this extension do?
This extension, based on the original work by User:RouslanZenetl, Extension:Boilerplate, was written to allow use of various Boilerplates based on the articles title.

We are documenting various functions of our system. We want predefined Boilerplate templates used but don't want the user to have to cut/paste the 'template' into a blank page. There are 'User Request', 'Technical Design', 'Functional Design' 'Data Design' and 'Scope' documents (templates). We have defined that articles of these types will have titles like '999 Purchasing Request' or '999 Make Wiki Better Functional'. So we add 'keyword' trigger to the title.

Boilerplateselection depending on article title, will be retrieved on any NEW page and presented to the user in edit mode.

If the user is creating a page which we have no Boilerplate for, we will create a new page using the default Boilerplate template.

Usage
Once installed simply create Boilerplate templates. Then modify $wgBoilerPlateAry as needed.

Installation

 * Create a the directory Boilerplateselection in your extensions folder. Then copy/paste the code into Boilerplateselection.php in that folder.
 * Make noted changes to LocalSettings.php
 * Create template Boilerplate and copy this code as the default 'new page'
 * Modify $wgBoilerPlateAry in LocalSettings.php to match your new article keywords and associated boilerplate templates

Parameters
none

Changes to LocalSettings.php
require_once("$IP/extensions/Boilerplateselection/Boilerplateselection.php"); global $wgBoilerPlateAry; $wgBoilerPlateAry = array('Sandbox' => 'Boilerplate');

Code
 (based on work by RouslanZenetl) * @addtogroup Extensions * @copyright © 2007 David Tod Sigafoos * @licence GNU General Public Licence 2.0 or later */

if( !defined( 'MEDIAWIKI' ) ) { echo( "This file is part of an extension to the MediaWiki software and cannot be used standalone.\n" ); die( true ); }
 * 1) 	get out if not part of mediawiki ..

$wgExtensionCredits['other'][] = array( 	'name' => 'BoilerPlateSelection', 	'author' => 'David Tod Sigafoos (based on work by RouslanZenetl)',	'url' => 'http://www.mediawiki.org/wiki/Extension:BoilerPlateSelection',	'description' => 'Create new pages based on new page title' );

/** * Set up hooks for discussion threading * * @param $wgBoilerPlateAry global array of Title key words and associated templates */

$wgHooks['EditPage::showEditForm:initial'][] = array('boilerplateselection');

function boilerplateselection($editpage) { // EditFormPreloadText global $wgOut; global $wgBoilerPlateAry;

$wgOut->enableClientCache(false); //	be sure that our var has been set else just default behavior if ( !isset($wgBoilerPlateAry) ) { $wgBoilerPlateAry = ''; }   if (!$editpage->preview     	&& !$editpage->mArticle->mContentLoaded     	&& $editpage->mArticle->mTitle->mNamespace==0) {

//	set default for article $boilerPlateArticle = 'Boilerplate';

//	get the title for the current article $articleTitle = $editpage->mArticle->mTitle->getText;

// loop through the array to find 'Key Word' in the array and // associated template name if (is_array( $wgBoilerPlateAry )) { foreach ($wgBoilerPlateAry as $bpKey => $bpValue) { if ( ereg($bpKey, $articleTitle) ) { $boilerPlateArticle = $bpValue; }			}		}

/*			boilerPlateArticle is the associated name with the current title. 'Boilerplate' is the default "NO HIT" which will cause a blank page to be displayed. */		$boilerplate_title = Title::newFromText('Template:' . $boilerPlateArticle); $boilerplate_article = new Article($boilerplate_title); $editpage->textbox1=$boilerplate_article->GetContent; $editpage->textbox2=$editpage->textbox1; }

return true; } ?>

Boilerplate Template
If wgBoilerPlateAry is not defined or you have not used a name the process recognizes then the default is 'Boilerplate' template. This is an example of the template we use.

{| style="background:white; color:black; width:100%;" border="0" cellpadding="5" cellspacing="2" align="center" style="width:100%; background:#f5fffa; border:1px solid #cef2e0; color:black; align=center; vertical-align:top"



Author Info
Article Author: enter your name Article Date:   mm/dd/yyyy Last Update:  click on the signature button