value - default is empty array var $method; // default is POST, can be changed with options var $onSubmit; // can be set with options var $onReset; // can be set with options function PlekitForm ($full_url, $values, $options=NULL) { // so we can use the various l_* functions: // we parse the url to extract var-values pairs, // and add them to the 'values' argument if any // extract var=value settings from url if any $split=plekit_split_url($full_url); $this->url=$split['url']; $url_values=$split['values']; if ( ! $values ) $values = array(); if ( $url_values ) $values=array_merge($values,$url_values); $this->values=$values; // make strict xhtml happy $this->method="post"; if (isset($options['method']) && (!empty($options['method']))) $this->method=strtolower($options['method']); $this->onSubmit=NULL; if (isset($options['onSubmit']) && (!empty($options['onSubmit']))) $this->onSubmit=$options['onSubmit']; $this->onReset=NULL; if (isset($options['onReset']) && (!empty($options['onReset']))) $this->onReset=$options['onReset']; } function start () { print $this->start_html(); } function start_html () { $html="
onSubmit) $html .= " onSubmit='$this->onSubmit'"; if ($this->onReset) $html .= " onReset='$this->onReset'"; $html .= ">"; if ($this->values) foreach ($this->values as $key=>$value) $html .= $this->hidden_html($key,$value); return $html; } function end() { print $this->end_html(); } function end_html() { return "
"; } static function attributes ($options) { $html=""; $names=array('id','size','selected', 'checked', 'onfocus','onselect', 'onchange', 'onkeyup', 'onmouseup', 'onclick', 'onsubmit'); if ($options['selected']) $options['selected']='selected'; if ($options['checked']) $options['checked']='checked'; if ($options) foreach ($options as $key=>$value) { if (in_array(strtolower($key),$names)) $html .= " $key='$value'"; } return $html; } // options // (*) width to set the text size // (*) callbacks, e.g. onFocus=>'your javascript code' static function input_html ($type,$name,$value,$options=NULL) { if ( ! $options) $options=array(); $html="$display"; } static function textarea_html ($name,$value,$cols,$rows) { return ""; } // selectors is an array of hashes with the following keys // (*) display // (*) value : the value that the 'name' variable will be assigned // (*) optional 'selected': the entry selected initially // (*) optional 'disabled': the entry is displayed but not selectable // options // (*) id // (*) label : displayed as the first option, with no value attached // (*) autosubmit : equivalent to onChange=>'submit()' // (*) standard callbacks static function select_html ($name,$selectors,$options=NULL) { if ( ! $options) $options=array(); if ( $options ['autosubmit'] ) $options['onChange']='submit()'; $html=""; $html.="