Extension:CreateTpl

=Creating articles with template =

Installation
To install this extension
 * Create file in your /extension directory: CreateTpl.php (see section)
 * Add the following to LocalSettings.php:

Syntax


Overview
Displays a form that creates a page with a specified template. There is a check for the existence of the article. If an article exists, then a choice: either to continue (the contents of articles will be replaced by a template), or go back.

If the template parameter types are specified, then the entry form under the appropriate entry field in parentheses indicate its type. In the presence of input values for these parameters will also be made test for compliance specified in the template type. When discrepancies such as the transition to the creation of articles will be stopped, and will display a diagnostic message.

The parameter types are described in the text of the template as follows: Param_name1: type Param_name2: type

Possible types: number - the number date - date in format dd.mm.yyyy I appreciated this library, but had some trouble getting it working just right. The changes are posted below the original code. ~Juan

Code
";	}	$tt = Title::makeTitle( 10, $tpl_name );	$output .= 'Create a page with a template : getFullURL.'">'.$tpl_name.'    Article title: getVal("articletitle").'" style="width: 200px"/> Params: '.$form_inputs.' ';	$tpl_name_enc = urlencode($tpl_name);	$output = "".str_replace("\n", "", $output)."";	return $output; }

function preloadCreateTemplate(&$editpage, &$output) { global $wgRequest; if ( ($wgRequest->getVal("action") == "edit")	&& ($wgRequest->getVal("create") == "createtpl") ) { $tplname = urldecode($wgRequest->getVal("tplname")); $post_array = $wgRequest->getValues; $editpage->textbox1 = ''; }	return true; }

function preloadCreateTemplate_initial(&$editpage) { global $wgRequest; if ( ($wgRequest->getVal("action") == "edit")	&& ($wgRequest->getVal("create") == "createtpl") ) { $editpage->formtype = "initial"; }	return true; }

function fnCreateTplPositioning ( $tpl_name_enc, &$parser, &$text) { $label = "CreateTpl_$tpl_name_enc"; $text .= "document.getElementById(\"$label\").scrollIntoView(true); "; return true; }

function is_date($i_sDate) { $blnValid = TRUE; // check the format first (may not be necessary as we use checkdate below) if(!ereg ("^[0-9]{2}\.[0-9]{2}\.[0-9]{4}$", $i_sDate)) {   $blnValid = FALSE; }  else //format is okay, check that days, months, years are okay {     $arrDate = explode(".", $i_sDate); // break up date by slash $intDay = $arrDate[0]; $intMonth = $arrDate[1]; $intYear = $arrDate[2]; $intIsDate = checkdate($intMonth, $intDay, $intYear); if(!$intIsDate) {       $blnValid = FALSE; }  }//end else return ($blnValid); } ?>

Some Possible Changes

 * Went through and commented the code.
 * Changed the parameter parsing so that it would use spaces: Param_name1:type Param_name2:type.
 * Also, I've gone ahead and made it so the input type could be changed. Now for example, it recognizes a textarea type.  Look in the switch statement below and add whatever you might need in your form.
 * Fixed the tooltips and changed the form to use CSS instead of Tables.
 * Changed the version to .2
 * The following are valid paramtypes:
 * number
 * category
 * namespace
 * select
 * date
 * textarea

In particular the select tag functions in the following way: variablename:select-option1-option2-some_other_option Note that your options can't have spaces at this point... (This would mean switching back to using newlines so that the parser doesn't break... when I get around to it.)

date and number have typechecking on them. ~Juan