<?php
##################################################################################
# Class: table Date: 07-Apr-2002
# Author: Ariel Filipiak <hapu@correo.com.ar>
# This code is released under GPL (GNU Public License)
# Feel free to edit/use so long as you keep this copyright.USE at your own risk!
class table {
var $ini;
var $tbset = array();
var $trset = array();
var $tdset = array();
function table($i_border = "", $i_padding = "", $i_spacing = "", $s_width = "", $s_bgcolor = "", $s_class = "", $s_add = "", $s_tab = "") {
if (is_array($i_border)) {
$this->tbset = $i_border;
$i_border = $this->tbset["border"];
$i_padding = $this->tbset["padding"];
$i_spacing = $this->tbset["spacing"];
$s_width = $this->tbset["tbwidth"];
$s_bgcolor = $this->tbset["tbcolor"];
$s_class = $this->tbset["tbclass"];
$s_add = $this->tbset["tbadd"];
}
if (!$i_border) $i_border = 0;
if (!$i_padding) $i_padding = 0;
if (!$i_spacing) $i_spacing = 0;
if (!$s_tab) $s_tab = $this->tbset["tab"];
$this->ini = "$s_tab<table border='$i_border' cellpadding='$i_padding' cellspacing='$i_spacing'".
($s_bgcolor ? " bgcolor='$s_bgcolor'" : "").($s_width ? " width='$s_width'" : "").
($s_class ? " class='$s_class'" : "").($s_add ? " $s_add" : "").">\n".$this->tbset["tab"];
}
function tr($s_bgcolor = "", $s_class = "", $s_add = "") {
$this->trset = $this->tbset;
if (is_array($s_bgcolor)) {
$a_trset = $s_bgcolor;
if ($a_trset["trcolor"]) $this->trset["trcolor"] = $a_trset["trcolor"];
if ($a_trset["trclass"]) $this->trset["trclass"] = $a_trset["trclass"];
if ($a_trset["tradd"]) $this->trset["tradd"] = $a_trset["tradd"];
if ($a_trset["tdalign"]) $this->trset["tdalign"] = $a_trset["tdalign"];
if ($a_trset["tdvalign"]) $this->trset["tdvalign"] = $a_trset["tdvalign"];
if ($a_trset["tdwidth"]) $this->trset["tdwidth"] = $a_trset["tdwidth"];
if ($a_trset["tdcolor"]) $this->trset["tdcolor"] = $a_trset["tdcolor"];
if ($a_trset["tdclass"]) $this->trset["tdclass"] = $a_trset["tdclass"];
if ($a_trset["tdadd"]) $this->trset["tdadd"] = $a_trset["tdadd"];
$s_bgcolor = $this->trset["trcolor"];
}
if (!$s_bgcolor) $s_bgcolor = $this->trset["trcolor"];
if (!$s_class) $s_class = $this->trset["trclass"];
if (!$s_add) $s_add = $this->trset["tradd"];
return "<tr".($s_bgcolor ? " bgcolor='$s_bgcolor'" : "").($s_class ? " class='$s_class'" : "").
($s_add ? " $s_add" : "").">\n".$this->tbset["tab"];
}
function td($i_cols = "", $i_rows = "", $s_align = "", $s_valign = "", $s_width = "", $s_bgcolor = "", $s_class = "", $s_add = "") {
$this->tdset = $this->trset;
if (is_array($s_align)) {
$a_tdset = $s_align;
if ($a_tdset["tdalign"]) $this->tdset["tdalign"] = $a_tdset["tdalign"];
if ($a_tdset["tdvalign"]) $this->tdset["tdvalign"] = $a_tdset["tdvalign"];
if ($a_tdset["tdwidth"]) $this->tdset["tdwidth"] = $a_tdset["tdwidth"];
if ($a_tdset["tdcolor"]) $this->tdset["tdcolor"] = $a_tdset["tdcolor"];
if ($a_tdset["tdclass"]) $this->tdset["tdclass"] = $a_tdset["tdclass"];
if ($a_tdset["tdadd"]) $this->tdset["tdadd"] = $a_tdset["tdadd"];
$s_align = $this->tdset["tdalign"];
}
if (!$s_align) $s_align = $this->tdset["tdalign"];
if (!$s_valign) $s_valign = $this->tdset["tdvalign"];
if (!$s_width) $s_width = $this->tdset["tdwidth"];
if (!$s_bgcolor) $s_bgcolor = $this->tdset["tdcolor"];
if (!$s_class) $s_class = $this->tdset["tdclass"];
if (!$s_add) $s_add = $this->tdset["tdadd"];
return "\t<td".($s_align ? " align='$s_align'" : "").($s_valign ? " valign='$s_valign'" : "").
($i_cols ? " colspan='$i_cols'" : "").($i_rows ? " rowspan='$i_rows'" : "").
($s_bgcolor ? " bgcolor='$s_bgcolor'" : "").($s_width ? " width='$s_width'" : "").
($s_class ? " class='$s_class'" : "").($s_add ? " $s_add" : "").">";
}
function end($a_tags = "td, tr, table") {
$a_tag = explode(",",$a_tags);
for ($i = 0; $i < count($a_tag); $i++) {
$s_tags .= "</".trim($a_tag[$i]).">\n".$this->tbset["tab"];
}
return $s_tags;
}
}
##################################################################################
# Class: form Date: 07-Apr-2002
# Author: Ariel Filipiak <hapu@correo.com.ar>
# This code is released under GPL (GNU Public License)
# Feel free to edit/use so long as you keep this copyright.USE at your own risk!
class form {
var $ini;
var $formset = array();
var $end = "</form>";
function form($s_name = "", $s_action = "", $s_method = "", $s_onsubmit = "", $s_class = "", $s_add = "") {
if (is_array($s_name)) {
$this->formset = $s_name;
$s_name = $this->formset["name"];
$s_action = $this->formset["action"];
$s_method = $this->formset["method"];
$s_onsubmit = $this->formset["onsubmit"];
$s_class = $this->formset["form_class"];
$s_add = $this->formset["form_add"];
}
if (!$s_action) $s_action = $GLOBALS["PHP_SELF"];
if (!$s_method) $s_method = "POST";
$this->ini = "<form action='$s_action' method='$s_method'".
($s_name ? " name='$s_name'" : "").($s_onsubmit ? " onSubmit=\"$s_onsubmit\"" : "").
($s_class ? " class='$s_class'" : "").($s_add ? " $s_add" : "").">\n";
}
function hidden($s_name, $s_value = "") {
if (is_array($s_name)) {
$a_hidden = $s_name;
reset($a_hidden);
while (list ($s_name , $s_value) = each ($a_hidden)) {
$s_hidden .= "<input type='hidden' name='$s_name' value='$s_value'>";
}
} else {
$s_hidden = "<input type='hidden' name='$s_name' value='$s_value'>";
}
return $s_hidden;
}
function text($s_name, $i_size = "", $i_maxlen = "", $s_value = "", $s_class = "", $s_add = "") {
if (!$s_class) $s_class = $this->formset["text_class"];
return "<input type='text' name='$s_name' value='$s_value'".
($i_size ? " size='$i_size'" : "").($i_maxlen ? " maxlength='$i_maxlen'" : "").
($s_class ? " class='$s_class'" : "").($s_add ? " $s_add" : "").">";
}
function check($s_option, $s_selected, $c_type="s") {
$s_tag = ($c_type == "c" ? " checked" : " selected");
if ($s_option == $s_selected) return $s_tag;
return "";
}
function select($s_name, $a_option, $s_default = "", $s_selected = "", $s_class = "", $s_add = "") {
if (!$s_class) $s_class = $this->formset["select_class"];
$s_select = "<select name='$s_name'".($s_class ? " class='$s_class'" : "").
($s_add ? " $s_add" : "").">\n";
if ($s_selected == "") $s_selected = $s_default;
reset ($a_option);
while (list ($s_value , $s_option) = each ($a_option)) {
$s_select .= "<option value='$s_value'".$this->check($s_value, $s_selected);
if (is_array($s_option)) {
$s_select .= ($s_option[1] ? " class = '".$s_option[1]."'" : "");
$s_select .= ($s_option[2] ? " ".$s_option[2]."'" : "");
$s_option = $s_option[0];
}
$s_select .= ">".($s_option ? $s_option : $s_value)."\n";
}
$s_select .= "</select>";
return $s_select;
}
function checkbox($s_name, $s_value = "1", $s_default = "", $s_selected = "", $s_class = "", $s_add = "") {
if (!$s_class) $s_class = $this->formset["checkbox_class"];
if ($s_selected == "") $s_selected = $s_default;
$s_checkbox = "<input type=checkbox name='$s_name' value='$s_value'";
$s_checkbox.= $this->check($s_value, $s_selected, "c");
$s_checkbox.= ($s_class ? " class='$s_class'" : "").($s_add ? " $s_add" : "").">";
return $s_checkbox;
}
function radio($s_name, $a_option, $s_default = "", $s_selected = "", $s_class = "", $s_add = "") {
if (!$s_class) $s_class = $this->formset["radio_class"];
if ($s_selected == "") $s_selected = $s_default;
$i = 0;
reset ($a_option);
while (list ($s_value , $s_option) = each ($a_option)) {
$a_radio[$i][0] = "<input type=radio name='$s_name' value='$s_value'";
$a_radio[$i][0] .= $this->check($s_value, $s_selected, "c");
if (is_array($s_option)) {
$a_radio[$i][0] .= ($s_option[1] ? " class = '".$s_option[1]."'" : "");
$a_radio[$i][0] .= ($s_option[2] ? " ".$s_option[2]."'" : "");
$s_option = $s_option[0];
}
$a_radio[$i][0] .= ">";
$a_radio[$i][1] = ($s_option ? $s_option : $s_value);
$i++;
}
return $a_radio;
}
function textarea($s_name, $i_cols = "", $i_rows = "", $s_content = "", $s_class = "", $s_add = "") {
if (!$s_class) $s_class = $this->formset["textarea_class"];
return "<textarea name='$s_name'".
($i_cols ? " cols='$i_cols'" : "").($i_rows ? " rows='$i_rows'" : "").
($s_class ? " class='$s_class'" : "").($s_add ? " $s_add" : "").">".
"$s_content</textarea>";
}
function button($s_type = "submit", $s_name = "", $s_value = "", $s_class = "", $s_add = "") {
if (!$s_class) $s_class = $this->formset["button_class"];
$s_button = "<input type='$s_type'".($s_name ? " name='$s_name'" : "");
if ($s_type == "image") {
$s_button .= " src='$s_value'";
} else {
$s_button .= ($s_value ? " value='$s_value'" : "");
}
$s_button .= ($s_class ? " class='$s_class'" : "").($s_add ? " $s_add" : "").">";
return $s_button;
}
}
?> |