Hab grad gesehen, dass meine inzwischen ein wenig anders aussieht, vielleicht gehts mit der besser:
[php]<?php
function showform($layout,$row,$nosave = false)
{
global $output;
$js = '
<script language="JavaScript">
var setting = 0;
function show(setting)
{
if (document.getElementById
&& document.getElementById(setting).style.visibility == "hidden")
{
document.getElementById(setting).style.visibility = "visible";
document.getElementById(setting).style.display = "inline";
document.getElementById("link_"+setting).style.color = "#FFFF00";
document.getElementById("link_"+setting).style.background = "#550000";
}
else
{
document.getElementById(setting).style.visibility = "hidden";
document.getElementById(setting).style.display = "none";
document.getElementById("link_"+setting).style.color = "#0099FF";
document.getElementById("link_"+setting).style.background = "#303030";
}
}
function hidden()
{
for(var x = 1; x <{count}; x++)
{
var elements = document.getElementById(x);
elements.style.visibility = "hidden";
elements.style.display = "none";
document.getElementById("link_"+x).style.color = "#0099FF";
document.getElementById("link_"+x).style.background = "#303030";
}
}
function set_setting(setting)
{
hidden();
show(setting);
}
</script>';
// $reiter = "<table cellpadding='0' cellspacing='0' border='0'><tr>";
$countt = 1;
$count_lines = 0;
while(list($key,$val)=each($layout))
{
$info = split(",",$val);
if ($info[1]=="title")
{
if($countt > 1) $table.="</div>";
$table.="<div id='$countt' style='"
.($countt>1?"visibility: hidden; display: none;":"visibility: visible; display: inline;")
."'>";
$table.="<div style=' background: #880000; height: 2em; vertical-align: middle;'>";
$table.=appoencode("`b`^$info[0]`0`b");
$reiter.="<div id='link_".$countt."' onClick=\"javascript:set_setting('".$countt."')\" style='float: left; cursor: pointer; padding: 5px; border: 1px solid #000000; color: ".($countt>1?"#0099FF":"#FFFF00")."; background: ".($countt>1?"#303030":"#550000").";'>";
$reiter.=' '.$info[0].' ';
$reiter.='</div>';
$countt++;
}
else
{
$class = $count_lines%2?"class = 'trlight'":"class = 'trdark'";
$table.="<div style='float: left; clear: both; text-align: left;' $class>";
$table.=appoencode("$info[0]");
$table.="</div> <div style='text-align: right;' $class>";
}
switch($info[1])
{
case "title":
break;
case "textarea":
$table.="<textarea name='$key' class='input' cols='$info[2]' rows='$info[3]'>".str_replace("`","``",HTMLEntities($row[$key]))."</textarea>";
break;
case 'file':
$table .= "<input name='$key' type='file'>";
break;
case "enum":
reset($info);
list($k,$v)=each($info);
list($k,$v)=each($info);
$table.="<select name='$key'>";
while (list($k,$v)=each($info)){
$optval = str_replace("`","``",$v);
list($k,$v)=each($info);
$optdis = $v;
$table.="<option value='$optval'".($row[$key]==$optval?" selected":"").">".HTMLEntities("$optval : $optdis")."</option>";
}
$table.="</select>";
break;
case "select":
reset($info);
list($k,$v)=each($info);
list($k,$v)=each($info);
$table.="<select name='$key'>";
while (list($k,$v)=each($info)){
$optval = str_replace("`","``",$v);
list($k,$v)=each($info);
$optdis = $v;
$table.="<option value='$optval'".($row[$key]==$optval?" selected":"").">".HTMLEntities("$optdis")."</option>";
}
$table.="</select>";
break;
case "password":
$table.="<input type='password' name='$key' value='".str_replace("`","``",HTMLEntities($row[$key]))."'>";
break;
case "bool":
$table.="<select name='$key'>";
$table.="<option value='0'".($row[$key]==0?" selected":"").">Nein</option>";
$table.="<option value='1'".($row[$key]==1?" selected":"").">Ja</option>";
$table.="</select>";
break;
case "hidden":
$table.="<input type='hidden' name='$key' value=\"".str_replace("`","``",HTMLEntities($row[$key]))."\">".HTMLEntities($row[$key]);
break;
case "viewonly":
$table.= dump_item($row[$key]);
break;
case "int":
$table.="<input name='$key' value=\"".str_replace("`","``",HTMLEntities($row[$key]))."\" size='5'>";
break;
default:
$table.="<input size='50' name='$key' value=\"".str_replace("`","``",HTMLEntities($row[$key]))."\">";
}
$table.="</div>";
$count_lines++;;
}
// $table.="</div>";
$reiter.="<div style='clear: both;'></div>";
$table = str_replace("{count}",$countt,$js).$table;
$table = str_replace("><",">\n<",$table);
$reiter = str_replace("><",">\n<",$reiter);
$table .= "<div style='clear: both;'></div></div>";
if ($nosave==false) $table.="<input type='submit' class='button' value='Speichern'>";
output($reiter.$table,true);
}
?>[/php]
|