Extension:InputBox/Align

 * namespaces search improvements partially by *  Leonardo Pimenta  * @copyright Public domain * @license Public domain * @version 0.1.1 * * inputbox align made customizable by Ryan Bilesky  */ /** * Register the Inputbox extension with MediaWiki */ $wgExtensionFunctions[] = 'registerInputboxExtension'; $wgExtensionCredits['parserhook'][] = array(	'name' => 'Inputbox',	'author' => 'Erik Moeller',	'url' => 'http://meta.wikimedia.org/wiki/Help:Inputbox',	'description' => 'Allow inclusion of predefined HTML forms.', );

/** * Sets the tag that this extension looks for and the function by which it * operates */ function registerInputboxExtension {   global $wgParser; $wgParser->setHook('inputbox', 'renderInputbox'); }

/** * Renders an inputbox based on information provided by $input. */ function renderInputbox($input, $params, &$parser) {	$inputbox=new Inputbox( $parser ); getBoxOption($inputbox->type,$input,'type'); getBoxOption($inputbox->width,$input,'width',true); getBoxOption($inputbox->preload,$input,'preload'); getBoxOption($inputbox->editintro,$input,'editintro'); getBoxOption($inputbox->defaulttext,$input,'default'); getBoxOption($inputbox->bgcolor,$input,'bgcolor'); getBoxOption($inputbox->buttonlabel,$input,'buttonlabel'); getBoxOption($inputbox->searchbuttonlabel,$input,'searchbuttonlabel'); getBoxOption($inputbox->namespaces,$input,'namespaces');

getBoxOption($inputbox->align,$input,'align'); getBoxOption($inputbox->id,$input,'id'); getBoxOption($inputbox->labeltext,$input,'labeltext'); getBoxOption($inputbox->br, $input, 'break'); getBoxOption($inputbox->hidden, $input, 'hidden'); $inputbox->lineBreak; $inputbox->checkWidth; $boxhtml=$inputbox->render; # Maybe support other useful magic words here $boxhtml=str_replace("",$parser->getTitle->getText,$boxhtml); if($boxhtml) { return $boxhtml; } else { return ' Input box: type not defined. ';	} }

function getBoxOption(&$value,&$input,$name,$isNumber=false) {

if(preg_match("/^\s*$name\s*=\s*(.*)/mi",$input,$matches)) { if($isNumber) { $value=intval($matches[1]); } else { $value=htmlspecialchars($matches[1]); }	} }

class Inputbox { var $type,$width,$preload,$editintro, $align, $br; var $defaulttext,$bgcolor,$buttonlabel,$searchbuttonlabel; var $hidden; function InputBox( &$parser ) { $this->parser =& $parser; }	function render { if($this->type=='create' || $this->type=='comment') { return $this->getCreateForm; } elseif($this->type=='search') { return $this->getSearchForm; } elseif($this->type=='search2') { return $this->getSearchForm2; } else { return false; }		}	function getSearchForm { global $wgUser, $wgContLang; $sk=$wgUser->getSkin; $searchpath = $sk->escapeSearchLink; if(!$this->buttonlabel) { $this->buttonlabel = wfMsgHtml( 'tryexact' ); }		if(!$this->searchbuttonlabel) { $this->searchbuttonlabel = wfMsgHtml( 'searchfulltext' ); }

$type = $this->hidden ? 'hidden' : 'text'; $searchform=<<getSkin; $searchpath = $sk->escapeSearchLink; if(!$this->buttonlabel) { $this->buttonlabel = wfMsgHtml( 'tryexact' ); }

$output = $this->parser->parse( $this->labeltext,			$this->parser->getTitle, $this->parser->getOptions, false, false ); $this->labeltext = $output->getText; $this->labeltext = str_replace(' ', '', $this->labeltext); $this->labeltext = str_replace(' ', '', $this->labeltext); $type = $this->hidden ? 'hidden' : 'text'; $searchform=<<id}"> id}">{$this->labeltext} width}" class="bodySearchIput" id="bodySearchIput{$this->id}" />buttonlabel}" class="bodySearchBtnGo" /> ENDFORM;

if ( !empty( $this->fulltextbtn ) ) // this is wrong... $searchform .= 'searchbuttonlabel}" />';

$searchform .= ' ';

return $searchform; }

function getCreateForm { global $wgScript; $action = htmlspecialchars( $wgScript ); if($this->type=="comment") { $comment=''; if(!$this->buttonlabel) { $this->buttonlabel = wfMsgHtml( "postcomment" ); }		} else { $comment=''; if(!$this->buttonlabel) { $this->buttonlabel = wfMsgHtml( "createarticle" ); }		}				$type = $this->hidden ? 'hidden' : 'text'; $createform=<<br ) == "no" ); $this->br = $cond ? '' : ' ';	}

/**	 * If the width is not supplied, set it to 50 */	function checkWidth { if( !$this->width || trim( $this->width ) == '' ) $this->width = 50; }	} ?>