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

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); } ?>