Extension:CustomEdit/CustomEdit.php

');                                                                             				$wgOut->addHTML('');				$wgOut->addHTML(' ');				$wgOut->addHTML(' ');                       				$wgOut->addHTML(' ');		}		return false;	} 	//else	return true;

}

/** * Retrieves text from an article * @param name of the article as string * @return text from article as string function getArticleText ($article="Main Page") {	//ialex @ #mediawiki: you shouldn't create a title object with "new Title( ... )", always une a static method you can see at the top of title.php $t = Title::NewFromText($article); $art = Revision::newFromTitle( $t ); if($art!=null) {		return $art->getText; }	else {		return ""; } }

/** * Retrieves a list of fields available at a template (text surrounded by or {{{X| ) * @param the template * @return Simple array with field names function getTemplateFields($template) {		$templateText = getArticleText($template); //echo "TEmplatetest:".$templateText; $parts = explode("{{{", $templateText); $params= ""; foreach($parts as $part) {		$endOfBrackets = strpos($part, "}}}"); $positionOfPipe = strpos($part, "|"); if(($positionOfPipe) && ($positionOfPipe < $endOfBrackets)) {			$endOfBrackets = $positionOfPipe; }		if($endOfBrackets) {			$parameterInTemplate = trim(substr($part, 0, $endOfBrackets)); if($parameterInTemplate != "") {				$params[] = $parameterInTemplate; }		}	}	return $params; }

/** * Retrieves a list of templates stored in MediaWiki:CustomEditTemplates * @return Simple array with template names function getCustomEditTemplates {	$templates = ""; $templateNamespaceAlias = getArticleText('MediaWiki:nstab-template'); $templateList = getArticleText('MediaWiki:CustomEditTemplates'); $templateList = str_replace($templateNamespaceAlias.':', 'Template:', $templateList);

$parts = explode("\n", $templateList); foreach($parts as $part) {		$beginnOfTemplate = strpos($part, 'Template:'); if($beginnOfTemplate!=-1) {			$endOfBrackets = strpos($part, ']]', $beginnOfTemplate); $pipeInString = strpos($part, '|', $beginnOfTemplate); if($pipeInString < $endOfBrackets) {				$pipeInString = $endOfBrackets; }			$templateName = substr($part, $beginnOfTemplate + 9, $endOfBrackets - ($beginnOfTemplate + 9)); $templates[] = $templateName; }	}	return $templates; }