<?php
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// MyFORM class v0.3
//
// Created by LL
// Copyright by SP
// -----------------------------------------------------------------------------
//
//
//
//
//
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// Command Function
// -----------------------------------------------------------------------------
// __construct Initial a form
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
class MyFORM
{
private $action; // target for Form data
private $method; // POST (Standart) or GET = 1
private $form_n; //
private $FORM = array(); //
private $FORM_INDEX = 0; //
private $only = 0; //
private $c_head = 0; //
private $c_feed = 0; //
private $c_fs_head = 0; //
private $c_fs_feed = 0; //
private $c_radio = 0; //
private $c_select_head = 0; //
private $c_select_multi = 0; //
private $c_select_group = 0; //
private $c_select_selected = 0; //
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function __construct( $Myform_n = NULL, $MYaction = NULL, $MYmethod = NULL )
{
if( !isset( $MYaction ) ) $this-> only = 1;
$this-> action = $MYaction;
$this-> form_n = $Myform_n;
if( $MYmethod == 1 )
{
$this-> method = "GET";
}
else
{
$this-> method = "POST";
}
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function create_Form()
{
if( $this-> c_feed == 1 )
{
for( $i = 0; $i <= $this-> FORM_INDEX; $i++ )
{
echo $this-> FORM[$i];
}
}else echo "ERROR - Don't FEED define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function getForm()
{
$varForm = NULL;
if( $this-> c_feed == 1 )
{
for( $i = 0; $i <= $this-> FORM_INDEX; $i++ )
{
$varForm = varForm . FORM[$i];
}
return $varForm;
}else echo "ERROR - Don't FEED define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function fHead( $id = "" )
{
$stuff = '<form ';
if( strlen( $id ) > 0 )
{
$stuff = $stuff . 'id="' . $id . '" ';
}
$stuff = $stuff . 'action="' . $this->action . '" method="'. $this->method . '">'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
else
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
$this-> c_head = 1;
}
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function fFeed()
{
$stuff = '</form>'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
$this-> c_feed = 1;
}else echo "ERROR - Don't HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function fs_head( $id = "" )
{
$stuff = '<fieldset';
if( strlen( $id ) > 0 )
{
$stuff = $stuff . ' id="' . $id . '" ';
}
$stuff = $stuff . '>'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
else
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
$this-> c_fs_head = 1;
}
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function fs_legend( $value, $id = "" )
{
$stuff = '<legend';
if( strlen( $id ) > 0 )
{
$stuff = $stuff . ' id="' . $id . '" ';
}
$stuff = $stuff . '>' . $value . '</legend>'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_fs_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
}else echo "ERROR - Don't Fieldset HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function fs_label( $id, $value )
{
$stuff = '<label for="' . $id .'">' . $value .'</label>'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_fs_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
}else echo "ERROR - Don't Fieldset HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function fs_feed()
{
$stuff = '</fieldset>'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_fs_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
$this-> c_fs_feed = 1;
}else echo "ERROR - Don't Fieldset HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function input_text( $name, $value = NULL, $id = "", $ro = 0, $disabled = 0 )
{
$stuff = '<input ';
if( strlen( $id ) > 0 )
{
$stuff = $stuff . 'id="' . $id . '" ';
}
$stuff = $stuff . 'name="' . $name . '" type="text" value="' . $value .'"';
if( $ro == 1 )
{
$stuff = $stuff . ' readonly="readonly"';
}
if( $disabled == 1 )
{
$stuff = $stuff . ' disabled="disabled"';
}
$stuff = $stuff . '>'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
}else echo "ERROR - Don't HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function input_password( $name, $value = NULL, $id = "" )
{
$stuff = '<input ';
if( strlen( $id ) > 0 )
{
$stuff = $stuff . 'id="' . $id . '" ';
}
$stuff = $stuff . 'name="' . $name . '" type="password" value="' . $value . '">'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
}else echo "ERROR - Don't HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function input_hidden( $name, $value = NULL, $id = "" )
{
$stuff = '<input ';
if( strlen( $id ) > 0 )
{
$stuff = $stuff . 'id="' . $id . '" ';
}
$stuff = $stuff . 'name="' . $name . '" type="hidden" value="' . $value . '">'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
}else echo "ERROR - Don't HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function checkbox( $name, $value = NULL, $id = "", $desc = NULL, $checked = 0)
{
$stuff = '<input ';
if( strlen( $id ) > 0 )
{
$stuff = $stuff . 'id="' . $id . '" ';
}
$stuff = $stuff . 'type="checkbox" name="' . $name . '" value="' . $value . '"';
if( $checked == 1 )
{
$stuff = $stuff . ' checked="checked"';
}
$stuff = $stuff . '>' . $desc ."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
}else echo "ERROR - Don't HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function radio( $name, $value = NULL, $id = "", $desc = NULL, $checked = 0 )
{
$stuff = '<input ';
if( strlen( $id ) > 0 )
{
$stuff = $stuff . 'id="' . $id . '" ';
}
$stuff = $stuff . 'type="radio" name="' . $name . '" value="' . $value . '"';
if( $checked == 1 && $this-> c_radio == 0 )
{
$stuff = $stuff . ' checked="checked"';
$this-> c_radio = 1;
}
$stuff = $stuff . '>' . $desc ."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
}else echo "ERROR - Don't HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function upload( $name, $id = "", $accept = '*' )
{
$stuff = '<input ';
if( strlen( $id ) > 0 )
{
$stuff = $stuff . 'id="' . $id . '" ';
}
$stuff = $stuff . 'name="' . $name . '" type="file" accept="' . $accept . '">'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
}else echo "ERROR - Don't HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function textarea( $name, $cols, $rows, $value = NULL, $id = "", $ro = 0, $disabled = 0 )
{
$stuff = '<textarea ';
if( strlen( $id ) > 0 )
{
$stuff = $stuff . 'id="' . $id . '" ';
}
$stuff = $stuff . 'name="' . $name . '" cols="' . $cols . '" rows="' . $rows . '"';
if( $ro == 1 )
{
$stuff = $stuff . ' readonly="readonly"';
}
if( $disabled == 1 )
{
$stuff = $stuff . ' disabled="disabled"';
}
$stuff = $stuff . '>' . $value . '</textarea>'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
}else echo "ERROR - Don't HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function submit( $name, $value, $id = "" )
{
$stuff = '<input ';
if( strlen( $id ) > 0 )
{
$stuff = $stuff . 'id="' . $id . '" ';
}
$stuff = $stuff . 'type="submit" name="' . $name . '" value="' . $value . '">'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
}else echo "ERROR - Don't HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function reset( $value, $id = "" )
{
$stuff = '<input ';
if( strlen( $id ) > 0 )
{
$stuff = $stuff . 'id="' . $id . '" ';
}
$stuff = $stuff . 'type="reset" value="' . $value . '">'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
}else echo "ERROR - Don't HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function button( $name, $value, $oc = "", $id = "" )
{
$stuff = '<input ';
if( strlen( $id ) > 0 )
{
$stuff = $stuff . 'id="' . $id . '" ';
}
$stuff = $stuff . 'type="button" name="' . $name . '" value="' . $value . '" onclick="' . $oc . '">'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
}else echo "ERROR - Don't HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function select_head( $name, $size, $multi = 0, $id = "" )
{
$stuff = '<select ';
if( strlen( $id ) > 0 )
{
$stuff = $stuff . 'id="' . $id . '" ';
}
$stuff = $stuff . 'name="' . $name . '" size="' . $size . '"';
if( $multi == 1 )
{
$stuff = $stuff . ' multiple="multiple"';
$this-> c_select_multi = 1;
}
$stuff = $stuff . '>'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
$this-> c_select_head = 1;
}else echo "ERROR - Don't HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function s_group_head( $label )
{
$stuff = '<optgroup label="' . $label . '">'."\n";
if( $this-> c_select_head == 1 )
{
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
$this-> c_select_group = 1;
}else echo "ERROR - Don't HEAD define\n";
}else echo "ERROR - Don't Select HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function s_option( $name, $value, $selected = 0 )
{
$stuff = '<option';
if( $this-> c_select_head == 1 )
{
if( $selected == 1 && $this-> c_select_selected == 0 )
{
$stuff = $stuff . ' selected="selected"';
if( $this-> c_select_multi != 1 )
{
$this-> c_select_selected = 1;
}
}
$stuff = $stuff . ' value="' . $value . '">' . $name . '</option>'."\n";
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
$this-> c_select_group = 1;
}else echo "ERROR - Don't HEAD define\n";
}else echo "ERROR - Don't Select HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function s_group_feed()
{
if( $this-> c_select_group == 1 )
{
$stuff = '</optgroup>'."\n";
$this-> c_select_group = 0;
}
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
}else echo "ERROR - Don't HEAD define\n";
}
/////////////////////////////////////////////////////////////////////////////////
// -----------------------------------------------------------------------------
// NAME:
// DESCRIPTION:
// ARGUMENTS:
// USES GLOBAL:
// MODIFIES GL:
// RETURNS:
// DATE:
// -----------------------------------------------------------------------------
/////////////////////////////////////////////////////////////////////////////////
public function select_feed()
{
if( $this-> c_select_head == 1 )
{
$stuff = '</select>'."\n";
$this-> c_select_head = 0;
$this-> c_select_multi = 0;
$this-> c_select_selected = 0;
if( $this-> only == 1 )
{
echo $stuff;
}
elseif( $this-> c_head == 1 )
{
$this-> FORM[$this-> FORM_INDEX] = $stuff;
$this-> FORM_INDEX++;
}else echo "ERROR - Don't HEAD define\n";
}else echo "ERROR - Don't Select HEAD define\n";
}
}
?>