Location: PHPKode > projects > Top Music module > Top Music 3.0.7/html/modules/topMusic/admin/lib/com/sergids/topmusic/view/GenericAdminView.php
<?php
class GenericAdminView{
	/**
	* Prints a select field in a form with de argument pairs name-value
	* @param $name string name of form field
	* @param $aSelect Array pairs of value (position 0) and name (position 1)
	* @return void
	*/
	function printSelect($name,$aSelect,$value=null,$behavior=""){
		if($behavior=="")
			echo "<select id=\"".$name."\" name=\"".$name."\">\n";
		else
			echo "<select id=\"".$name."\" name=\"".$name."\" onChange=\"".$behavior."\">\n";
		echo "	<option value=\"...\">...</option>\n";
		for ($i = 0; $i < sizeof($aSelect); $i++) {
			if($value==$aSelect[$i][0])
				$sel="selected";
			else
				$sel="";
			echo "	<option value=\"".$aSelect[$i][0]."\" ".$sel.">".$aSelect[$i][1]."</option>\n";
		}
		echo "</select>\n";
	}
	function printText($name,$value,$behavior=""){
		echo "<input type=\"text\" name=\"".$name."\" value=\"".$value."\" ".$behavior.">";
	}
	function printHidden($name,$value,$behavior=""){
		echo "<input type=\"hidden\" name=\"".$name."\" value=\"".$value."\" ".$behavior.">";
	}
	function printCheckbox($name,$checked){
		$val="";
		if($checked)
			$val="checked";
		echo "<input type=\"checkbox\" name=\"".$name."\" ".$val.">";
	}
	function printCustomField($field){
     	switch($field->type){
     		default:
     		case "text":
     		case "link":
     			$code = "<input type=\"text\" name=\"".$field->name."\" value=\"".$field->value."\">";
     			break;
     		case "textarea":
     			$code = "<textarea name=\"".$field->name."\" rows=\"8\" cols=\"70\">".$field->value."</textarea>";
     			break;
			case "select":
				$code="<select name=\"".$field->name."\">\n";
				$code.="<option></option>\n";
				foreach(explode(";",$field->select_values) as $value){
					if(trim($field->value)==trim($value))
						$sel="selected";
					else
						$sel="";
					$code.="<option ".$sel.">".$value."</option>\n";
				}
				$code.="</select>";
				break;
			case "file":
				$code="<input type=\"file\" name=\"".$field->name."\">&nbsp;";
				if($field->value!=""){
					$code.="<a href=\"modules/topMusic/".$field->file_path."/".$field->value."\" target=\"_blank\">";
					if($field->file_icon!="")
						$code.="<img src=\"modules/topMusic/".$field->file_icon."\" border=\"0\">";
					else
						$code.="<img src=\"modules/topMusic/images/download.gif\">";
					$code.="</a>";
				}
				break;
			case "image":
				$code="<input type=\"file\" name=\"".$field->name."\">&nbsp;";
				if($field->value!=""){
					$code.="<a href=\"modules/topMusic/".$field->file_path."/".$field->value."\" target=\"_blank\">";
					$code.="<img src=\"modules/topMusic/".$field->file_path."/".$field->value."\" width=\"".$field->image_width."\">";
					$code.="</a>";
				}
				break;
     	}
     	return $code;
     }
}
?>
Return current item: Top Music module