label = $label; $this->name = $name; $this->value = $value; } function render($indent = "") { $str = $indent . "
\n"; $str .= $indent . "
". $this->label ."
\n"; $str .= $indent . "
name."]\" value=\"".$this->value."\"/>
\n"; $str .= $indent . "
\n"; return $str; } } class FileUpload { public $label, $name, $accept; public function FileUpload($label, $name, $accept = "*") { $this->label = $label; $this->name = $name; $this->accept = $accept; } public function render($indent = "") { $str = $indent . "
\n"; $str .= $indent . "
". $this->label . "
\n"; $str .= $indent . "
name. "\" accept=\"". $this->accept ."\"/>
\n"; $str .= $indent . "
\n"; return $str; } } class Button { public $label; public function Button($label) { $this->label = $label; } public function render($indent = "") { $str = $indent . "
\n"; $str .= $indent . "
\n"; $str .= $indent . "
\n"; $str .= $indent . "
\n"; return $str; } } class CheckBox { public $label, $name, $value; public function CheckBox($label, $name, $value = "") { $this->label = $label; $this->name = $name; $this->value = $value; } public function render($indent = "") { $str = $indent . "
\n"; $str .= $indent . "
". $this->label ."
\n"; $str .= $indent . "
name."]\" value=\"".$this->value."\"/>
\n"; $str .= $indent . "
\n"; return $str; } } class ComboBox { public $label, $name, $value, $values; public function ComboBox($label, $name, $value, $values) { $this->label = $label; $this->name = $name; $this->value = $value; $this->values = $values; } public function render($indent = "") { $str = $indent . "
\n"; $str .= $indent . "
".$this->label."
\n"; $str .= $indent . "
\n"; $str .= $indent . " \n"; $str .= $indent . "
\n"; $str .= $indent . "
\n"; return $str; } } class Hidden { public $values; public function Hidden($values) { $this->values = $values; } public function render($indent = "") { $str = ""; foreach($this->values as $key => $value) { $str .= $indent . "\n"; } return $str; } } class TextEdit { public $label, $name, $value; function TextEdit($label, $name, $value = "", $lines = "20") { $this->label = $label; $this->name = $name; $this->value = $value; $this->lines = $lines; } function render($indent = "") { $str = $indent . "
\n"; $str .= $indent . "
". $this->label ."
\n"; $str .= $indent . "
\n"; $str .= $indent . "
\n"; return $str; } } class DateTimeEdit { public $label, $name, $timestamp; function DateTimeEdit($label, $name, $timestamp = 0) { $this->label = $label; $this->name = $name; $this->timestamp = $timestamp; } function render($indent = "") { if($this->timestamp == 0) $t = time(); else $t = $this->timestamp; $second = date('s',$t); $minute = date('i',$t); $hour = date('G',$t); $day = date('d',$t); $month = date('m',$t); $year = date('Y',$t); $str = $indent . "
\n"; $str .= $indent . "
".$this->label."
\n"; $str .= $indent . "
\n"; $str .= $indent . " name."_year]\" value=\"".$year."\"/>"; $str .= "/name."_month]\" value=\"".$month."\"/>"; $str .= "/name."_day]\" value=\"".$day."\"/>"; $str .= " - "; $str .= "name."_hour]\" value=\"".$hour."\"/>"; $str .= ":name."_minute]\" value=\"".$minute."\"/>"; $str .= ":name."_second]\" value=\"".$second."\"/>\n"; $str .= $indent . "
\n"; $str .= $indent . "
\n"; return $str; } public function toTimestamp($t, $name) { $timestring = sprintf("%d", $t[$name."_year"]) ."/". sprintf("%d", $t[$name."_month"]) ."/". sprintf("%d", $t[$name."_day"]) ." ". sprintf("%d", $t[$name."_hour"]) .":". sprintf("%02d", $t[$name."_minute"]).":". sprintf("%02d", $t[$name."_second"]); return strtotime($timestring); } } class ImageComboBox { public $label, $name, $value, $values; public function ImageComboBox($label, $name, $value, $values) { $this->label = $label; $this->name = $name; $this->value = $value; $this->values = $values; } public function render($indent = "") { $selheight = 64; $height = $selheight * 0.8; if(get_class($this->values) == "Icons") $numicons = sizeof($this->values->icons); else $numicons = sizeof($this->values); $str = $indent . "
\n"; $str .= $indent . "
".$this->label."
\n"; $str .= $indent . "
\n"; $str .= $indent . " \n"; $str .= $indent . "
\n"; $str .= $indent . "
\n"; $str .= $indent . " name."\" name=\"vars[".$this->name."]\" type=\"hidden\" value=\"\"/>\n"; if(get_class($this->values) == "Icons") { foreach($this->values->icons as $icon) { $str .= $indent . " \"".$icon-file."\" src=\"".$icon->prefix.$icon->file."\" onclick=\"setSelection('".$icon->file."')\"/>\n"; } } else { foreach($this->values as $k => $v) { $str .= $indent . " \"".$v."\"\n"; } } $str .= $indent . "
\n"; // box $str .= $indent . "
\n"; // overflow $str .= $indent . " \n"; $str .= $indent . "
\n"; // widget $str .= $indent . "
\n"; // input return $str; } } class ListEditor { public $label, $name, $namewidget, $valuewidget, $values; public function ListEditor($label, $name, $namewidget, $valuewidget, $values = array()) { $this->label = $label; $this->name = $name; $this->namewidget = $namewidget; $this->valuewidget = $valuewidget; $this->values = $values; } public function render($indent = "") { $str = $indent . "\n"; $str .= $indent . "
\n"; $str .= $indent . "
/\

\n"; $str .= $indent . "
\/

\n"; $str .= $this->namewidget->render($indent); $str .= $this->valuewidget->render($indent); $str .= "
+

\n"; $str .= $indent . "
-

\n"; return $str; } public function splitValues($values) { $out = array(); foreach($values as $value) { $vals = explode(":", $value); $out[$vals[0]]=$vals[1]; } return $out; } } class Form { public $widgets = array(); public $action; public $hasFileUpload = false; public $hasListEditor = false; public function addWidget($widget) { if(get_class($widget) == "FileUpload") $this->hasFileUpload = true; if(get_class($widget) == "ListEditor") $this->hasListEditor = true; array_push($this->widgets, $widget); } public function render($indent = "") { global $m, $s; $str = $indent . "
hasFileUpload) $str .= $indent . " enctype=\"multipart/form-data\"\n"; if($this->hasListEditor) $str .= $indent . " onsubmit=\"selectAll();\"\n"; $str .= $indent . " action=\"?page=admin&m=".$m."&s=".$s."&a=".$this->action."\">\n"; foreach($this->widgets as $widget) { $str .= $widget->render($indent . " "); } $str .= $indent . "
\n"; echo $str; } public function Form($action) { $this->action = $action; } } ?>