Location: PHPKode > projects > Prsaar Social Networking Platform > PrsaarColour-0.7.alpha.6.3/pr-admin/admin-form.php
<?php
	//I created this class to reduce typing, there are so much forms to display, this class may help a little bit. -vikrant[http://vikrant.co.in/]
	class AdminForm
	{
		var $Piece;
		var $Content;
		
		//constructor
		function AdminForm($Action = false)
		{
			$Piece = "<table> <form method='post' action=\"{$Action}\"> ";
			$this->Content = $this->Content.$Piece;
		}
		
		//function to input text/password
		function Input($Type = 'text', $Name, $Value = false, $Heading, $Comment = false)
		{
			$Piece = " <tr> <td align='right'> <strong> $Heading </strong> </td> <td> <input type=\"{$Type}\" name=\"{$Name}\" value=\"{$Value}\" size='60' style='font-family:\"Courier New\", Courier, monospace; font-weight:normal; font-size:small; color:black;' /> </td> </tr> ";
			$this->Content = $this->Content.$Piece;
			$this->Error($Name);
			if($Comment != false)
			{
				$Piece = " <tr> <td> &nbsp; </td> <td> <font size='-1'> $Comment </font> </td> </tr> ";
				$this->Content = $this->Content.$Piece;
			}
		}
		
		//function to select options
		function Select($Name, $Option, $Default = false, $Heading, $Comment = false)
		{
			$Piece = " <tr> <td align='right'> <strong> $Heading </strong> </td> <td> <select name=\"{$Name}\"> ";
			$this->Content = $this->Content.$Piece;
			$Options = explode(',', $Option);
			foreach($Options as $Key => $KeyValue)
			{	
				$GetValue = explode('//', $KeyValue);
				//options are in value/text format
				if($GetValue[0] == $Default)
					$Piece = " <option value=\"{$GetValue[0]}\" selected='selected'>{$GetValue[1]}</option> ";
				else
					$Piece = " <option value=\"{$GetValue[0]}\">{$GetValue[1]}</option> ";
				$this->Content = $this->Content.$Piece;
			}
			$Piece = " </select> Currently Assigned: <strong> $Default </strong> </td> </tr> ";
			$this->Content = $this->Content.$Piece;
			$this->Error($Name);
			if($Comment != false)
			{
				$Piece = " <tr> <td> &nbsp; </td> <td> <font size='-1'> $Comment </font> </td> </tr> ";
				$this->Content = $this->Content.$Piece;
			}
		}
		
		//function to show a text area
		function Textarea($Rows = 16, $Name, $Value = false, $Heading, $Comment = false)
		{
			$Piece = " <tr> <td align='left'> <strong> $Heading </strong> </td> <td> &nbsp; </td> </tr> <tr> <td> &nbsp; </td> <td> <textarea cols='45' rows=\"{$Rows}\" name=\"{$Name}\" style='font-family:Arial, Helvetica, sans-serif; font-weight:bold; font-size:medium; color:blue;' >{$Value}</textarea> </td> </tr> ";
			$this->Content = $this->Content.$Piece;
			$this->Error($Name);
			if($Comment != false)
			{
				$Piece = " <tr> <td> &nbsp; </td> <td> <font size='-1'> $Comment </font> </td> </tr> ";
				$this->Content = $this->Content.$Piece;
			}
		}
		
		//This function displays error if any following the coloumn which caused the error
		function Error($Name) 
		{
			if(isset($this->Error[$Name]))
			{
				$Piece = " <tr> <td> &nbsp; </td> <td> <font color='red' size='-1'> ".$this->Error[$Name]." </font> </td> </tr>";
				$this->Content = $this->Content.$Piece;
			}
		}
		
		//this function catches the errors defined usually in update files
		function GetError($Name, $Value)
		{
			$this->Error[$Name] = $Value;
			$this->Error($Name);
		}
		
		function Finish($Submit = 'Update')
		{
			$Piece = "<tr> <td> &nbsp; </td> <td> &nbsp; </td> </tr> <tr> <td> &nbsp; </td> <td align='right'> <input type='submit' value=\"{$Submit} &raquo;\" style='font-size:larger;' /> </td></tr>
						</form> </table> ";
			$Content = $this->Content.$Piece;
			return $Content;
		}
		
		//show a line!
		function Line($Line)
		{
			$Piece = " <tr> <td> &nbsp; </td> <td> &nbsp; </td> </tr> <tr> <td colspan='2'> <strong> $Line &raquo; </strong> </td> </tr> ";
			$this->Content = $this->Content.$Piece;
		} 
	}
?>
Return current item: Prsaar Social Networking Platform