From 804e2f2f6882dcf7b125406acfc1e7e53a520934 Mon Sep 17 00:00:00 2001 From: Adrian Lang Date: Thu, 22 Oct 2009 14:02:17 +0200 Subject: Change inc/form.php to four space indentation darcs-hash:20091022120217-e4919-5409e48225e5ff0d8ec3fa5da02b106017c1a1dd.gz --- inc/form.php | 895 +++++++++++++++++++++++++++++------------------------------ 1 file changed, 447 insertions(+), 448 deletions(-) (limited to 'inc/form.php') diff --git a/inc/form.php b/inc/form.php index e638af4bc..650ebfa0a 100644 --- a/inc/form.php +++ b/inc/form.php @@ -7,7 +7,6 @@ */ if(!defined('DOKU_INC')) die('meh.'); -if(!defined('NL')) define('NL',"\n"); require_once(DOKU_INC.'inc/html.php'); /** @@ -29,242 +28,243 @@ require_once(DOKU_INC.'inc/html.php'); */ class Doku_Form { - // Form id attribute - var $params = array(); - - // Draw a border around form fields. - // Adds
around the elements - var $_infieldset = false; - - // Hidden form fields. - var $_hidden = array(); - - // Array of pseudo-tags - var $_content = array(); - - /** - * Constructor - * - * Sets parameters and autoadds a security token. The old calling convention - * with up to four parameters is deprecated, instead the first parameter - * should be an array with parameters. - * - * @param mixed $params Parameters for the HTML form element; Using the - * deprecated calling convention this is the ID - * attribute of the form - * @param string $action (optional, deprecated) submit URL, defaults to - * current page - * @param string $method (optional, deprecated) 'POST' or 'GET', default - * is POST - * @param string $enctype (optional, deprecated) Encoding type of the - * data - * @author Tom N Harris - */ - function Doku_Form($params, $action=false, $method=false, $enctype=false) { - if(!is_array($params)) { - $this->params = array('id' => $params); - if ($action !== false) $this->params['action'] = $action; - if ($method !== false) $this->params['method'] = $method; - if ($enctype !== false) $this->params['enctype'] = $enctype; - } else { - $this->params = $params; + // Form id attribute + var $params = array(); + + // Draw a border around form fields. + // Adds
around the elements + var $_infieldset = false; + + // Hidden form fields. + var $_hidden = array(); + + // Array of pseudo-tags + var $_content = array(); + + /** + * Constructor + * + * Sets parameters and autoadds a security token. The old calling convention + * with up to four parameters is deprecated, instead the first parameter + * should be an array with parameters. + * + * @param mixed $params Parameters for the HTML form element; Using the + * deprecated calling convention this is the ID + * attribute of the form + * @param string $action (optional, deprecated) submit URL, defaults to + * current page + * @param string $method (optional, deprecated) 'POST' or 'GET', default + * is POST + * @param string $enctype (optional, deprecated) Encoding type of the + * data + * @author Tom N Harris + */ + function Doku_Form($params, $action=false, $method=false, $enctype=false) { + if(!is_array($params)) { + $this->params = array('id' => $params); + if ($action !== false) $this->params['action'] = $action; + if ($method !== false) $this->params['method'] = $method; + if ($enctype !== false) $this->params['enctype'] = $enctype; + } else { + $this->params = $params; + } + + if (!isset($this->params['method'])) { + $this->params['method'] = 'POST'; + } + + $this->addHidden('sectok', getSecurityToken()); } - if (!isset($this->params['method'])) { - $this->params['method'] = 'POST'; + + /** + * startFieldset + * + * Add
tags around fields. + * Usually results in a border drawn around the form. + * + * @param string $legend Label that will be printed with the border. + * @author Tom N Harris + */ + function startFieldset($legend) { + if ($this->_infieldset) { + $this->addElement(array('_elem'=>'closefieldset')); + } + $this->addElement(array('_elem'=>'openfieldset', '_legend'=>$legend)); + $this->_infieldset = true; } - $this->addHidden('sectok', getSecurityToken()); - } - - /** - * startFieldset - * - * Add
tags around fields. - * Usually results in a border drawn around the form. - * - * @param string $legend Label that will be printed with the border. - * @author Tom N Harris - */ - function startFieldset($legend) { - if ($this->_infieldset) { - $this->addElement(array('_elem'=>'closefieldset')); + /** + * endFieldset + * + * @author Tom N Harris + */ + function endFieldset() { + if ($this->_infieldset) { + $this->addElement(array('_elem'=>'closefieldset')); + } + $this->_infieldset = false; } - $this->addElement(array('_elem'=>'openfieldset', '_legend'=>$legend)); - $this->_infieldset = true; - } - - /** - * endFieldset - * - * @author Tom N Harris - */ - function endFieldset() { - if ($this->_infieldset) { - $this->addElement(array('_elem'=>'closefieldset')); + + /** + * addHidden + * + * Adds a name/value pair as a hidden field. + * The value of the field (but not the name) will be passed to + * formText() before printing. + * + * @param string $name Field name. + * @param string $value Field value. If null, remove a previously added field. + * @author Tom N Harris + */ + function addHidden($name, $value) { + if (is_null($value)) + unset($this->_hidden[$name]); + else + $this->_hidden[$name] = $value; } - $this->_infieldset = false; - } - - /** - * addHidden - * - * Adds a name/value pair as a hidden field. - * The value of the field (but not the name) will be passed to - * formText() before printing. - * - * @param string $name Field name. - * @param string $value Field value. If null, remove a previously added field. - * @author Tom N Harris - */ - function addHidden($name, $value) { - if (is_null($value)) - unset($this->_hidden[$name]); - else - $this->_hidden[$name] = $value; - } - - /** - * addElement - * - * Appends a content element to the form. - * The element can be either a pseudo-tag or string. - * If string, it is printed without escaping special chars. * - * - * @param string $elem Pseudo-tag or string to add to the form. - * @author Tom N Harris - */ - function addElement($elem) { - $this->_content[] = $elem; - } - - /** - * insertElement - * - * Inserts a content element at a position. - * - * @param string $pos 0-based index where the element will be inserted. - * @param string $elem Pseudo-tag or string to add to the form. - * @author Tom N Harris - */ - function insertElement($pos, $elem) { - array_splice($this->_content, $pos, 0, array($elem)); - } - - /** - * replaceElement - * - * Replace with NULL to remove an element. - * - * @param int $pos 0-based index the element will be placed at. - * @param string $elem Pseudo-tag or string to add to the form. - * @author Tom N Harris - */ - function replaceElement($pos, $elem) { - $rep = array(); - if (!is_null($elem)) $rep[] = $elem; - array_splice($this->_content, $pos, 1, $rep); - } - - /** - * findElementByType - * - * Gets the position of the first of a type of element. - * - * @param string $type Element type to look for. - * @return array pseudo-element if found, false otherwise - * @author Tom N Harris - */ - function findElementByType($type) { - foreach ($this->_content as $pos=>$elem) { - if (is_array($elem) && $elem['_elem'] == $type) - return $pos; + + /** + * addElement + * + * Appends a content element to the form. + * The element can be either a pseudo-tag or string. + * If string, it is printed without escaping special chars. * + * + * @param string $elem Pseudo-tag or string to add to the form. + * @author Tom N Harris + */ + function addElement($elem) { + $this->_content[] = $elem; } - return false; - } - - /** - * findElementById - * - * Gets the position of the element with an ID attribute. - * - * @param string $id ID of the element to find. - * @return array pseudo-element if found, false otherwise - * @author Tom N Harris - */ - function findElementById($id) { - foreach ($this->_content as $pos=>$elem) { - if (is_array($elem) && isset($elem['id']) && $elem['id'] == $id) - return $pos; + + /** + * insertElement + * + * Inserts a content element at a position. + * + * @param string $pos 0-based index where the element will be inserted. + * @param string $elem Pseudo-tag or string to add to the form. + * @author Tom N Harris + */ + function insertElement($pos, $elem) { + array_splice($this->_content, $pos, 0, array($elem)); } - return false; - } - - /** - * findElementByAttribute - * - * Gets the position of the first element with a matching attribute value. - * - * @param string $name Attribute name. - * @param string $value Attribute value. - * @return array pseudo-element if found, false otherwise - * @author Tom N Harris - */ - function findElementByAttribute($name, $value) { - foreach ($this->_content as $pos=>$elem) { - if (is_array($elem) && isset($elem[$name]) && $elem[$name] == $value) - return $pos; + + /** + * replaceElement + * + * Replace with NULL to remove an element. + * + * @param int $pos 0-based index the element will be placed at. + * @param string $elem Pseudo-tag or string to add to the form. + * @author Tom N Harris + */ + function replaceElement($pos, $elem) { + $rep = array(); + if (!is_null($elem)) $rep[] = $elem; + array_splice($this->_content, $pos, 1, $rep); } - return false; - } - - /** - * getElementAt - * - * Returns a reference to the element at a position. - * A position out-of-bounds will return either the - * first (underflow) or last (overflow) element. - * - * @param int $pos 0-based index - * @return arrayreference pseudo-element - * @author Tom N Harris - */ - function &getElementAt($pos) { - if ($pos < 0) $pos = count($this->_content) + $pos; - if ($pos < 0) $pos = 0; - if ($pos >= count($this->_content)) $pos = count($this->_content) - 1; - return $this->_content[$pos]; - } - - /** - * printForm - * - * Output the form. - * Each element in the form will be passed to a function named - * 'form_$type'. The function should return the HTML to be printed. - * - * @author Tom N Harris - */ - function printForm() { - global $lang; - $this->params['accept-charset'] = $lang['encoding']; - print '
params) . '>
' . NL; - if (!empty($this->_hidden)) { - foreach ($this->_hidden as $name=>$value) - print form_hidden(array('name'=>$name, 'value'=>$value)); + + /** + * findElementByType + * + * Gets the position of the first of a type of element. + * + * @param string $type Element type to look for. + * @return array pseudo-element if found, false otherwise + * @author Tom N Harris + */ + function findElementByType($type) { + foreach ($this->_content as $pos=>$elem) { + if (is_array($elem) && $elem['_elem'] == $type) + return $pos; + } + return false; } - foreach ($this->_content as $element) { - if (is_array($element)) { - $elem_type = $element['_elem']; - if (function_exists('form_'.$elem_type)) { - print call_user_func('form_'.$elem_type, $element).NL; + + /** + * findElementById + * + * Gets the position of the element with an ID attribute. + * + * @param string $id ID of the element to find. + * @return array pseudo-element if found, false otherwise + * @author Tom N Harris + */ + function findElementById($id) { + foreach ($this->_content as $pos=>$elem) { + if (is_array($elem) && isset($elem['id']) && $elem['id'] == $id) + return $pos; } - } else { - print $element; - } + return false; + } + + /** + * findElementByAttribute + * + * Gets the position of the first element with a matching attribute value. + * + * @param string $name Attribute name. + * @param string $value Attribute value. + * @return array pseudo-element if found, false otherwise + * @author Tom N Harris + */ + function findElementByAttribute($name, $value) { + foreach ($this->_content as $pos=>$elem) { + if (is_array($elem) && isset($elem[$name]) && $elem[$name] == $value) + return $pos; + } + return false; + } + + /** + * getElementAt + * + * Returns a reference to the element at a position. + * A position out-of-bounds will return either the + * first (underflow) or last (overflow) element. + * + * @param int $pos 0-based index + * @return arrayreference pseudo-element + * @author Tom N Harris + */ + function &getElementAt($pos) { + if ($pos < 0) $pos = count($this->_content) + $pos; + if ($pos < 0) $pos = 0; + if ($pos >= count($this->_content)) $pos = count($this->_content) - 1; + return $this->_content[$pos]; + } + + /** + * printForm + * + * Output the form. + * Each element in the form will be passed to a function named + * 'form_$type'. The function should return the HTML to be printed. + * + * @author Tom N Harris + */ + function printForm() { + global $lang; + $this->params['accept-charset'] = $lang['encoding']; + print 'params) . '>
' . DOKU_LF; + if (!empty($this->_hidden)) { + foreach ($this->_hidden as $name=>$value) + print form_hidden(array('name'=>$name, 'value'=>$value)); + } + foreach ($this->_content as $element) { + if (is_array($element)) { + $elem_type = $element['_elem']; + if (function_exists('form_'.$elem_type)) { + print call_user_func('form_'.$elem_type, $element).DOKU_LF; + } + } else { + print $element; + } + } + if ($this->_infieldset) print form_closefieldset().DOKU_LF; + print '
'.DOKU_LF; } - if ($this->_infieldset) print form_closefieldset().NL; - print '
'.NL; - } } @@ -279,8 +279,8 @@ class Doku_Form { * @author Tom N Harris */ function form_makeTag($tag, $attrs=array()) { - $elem = array('_elem'=>'tag', '_tag'=>$tag); - return array_merge($elem, $attrs); + $elem = array('_elem'=>'tag', '_tag'=>$tag); + return array_merge($elem, $attrs); } /** @@ -295,8 +295,8 @@ function form_makeTag($tag, $attrs=array()) { * @author Tom N Harris */ function form_makeOpenTag($tag, $attrs=array()) { - $elem = array('_elem'=>'opentag', '_tag'=>$tag); - return array_merge($elem, $attrs); + $elem = array('_elem'=>'opentag', '_tag'=>$tag); + return array_merge($elem, $attrs); } /** @@ -310,7 +310,7 @@ function form_makeOpenTag($tag, $attrs=array()) { * @author Tom N Harris */ function form_makeCloseTag($tag) { - return array('_elem'=>'closetag', '_tag'=>$tag); + return array('_elem'=>'closetag', '_tag'=>$tag); } /** @@ -327,9 +327,9 @@ function form_makeCloseTag($tag) { * @author Tom N Harris */ function form_makeWikiText($text, $attrs=array()) { - $elem = array('_elem'=>'wikitext', '_text'=>$text, - 'class'=>'edit', 'cols'=>'80', 'rows'=>'10'); - return array_merge($elem, $attrs); + $elem = array('_elem'=>'wikitext', '_text'=>$text, + 'class'=>'edit', 'cols'=>'80', 'rows'=>'10'); + return array_merge($elem, $attrs); } /** @@ -347,14 +347,13 @@ function form_makeWikiText($text, $attrs=array()) { * @author Tom N Harris */ function form_makeButton($type, $act, $value='', $attrs=array()) { - if ($value == '') $value = $act; - //$name = (!empty($act)) ? 'do[$act]' : null; - $elem = array('_elem'=>'button', 'type'=>$type, '_action'=>$act, - 'value'=>$value, 'class'=>'button'); - if (!empty($attrs['accesskey']) && empty($attrs['title'])) { - $attrs['title'] = $value . ' ['.strtoupper($attrs['accesskey']).']'; - } - return array_merge($elem, $attrs); + if ($value == '') $value = $act; + $elem = array('_elem'=>'button', 'type'=>$type, '_action'=>$act, + 'value'=>$value, 'class'=>'button'); + if (!empty($attrs['accesskey']) && empty($attrs['title'])) { + $attrs['title'] = $value . ' ['.strtoupper($attrs['accesskey']).']'; + } + return array_merge($elem, $attrs); } /** @@ -376,10 +375,10 @@ function form_makeButton($type, $act, $value='', $attrs=array()) { * @author Tom N Harris */ function form_makeField($type, $name, $value='', $label=null, $id='', $class='', $attrs=array()) { - if (is_null($label)) $label = $name; - $elem = array('_elem'=>'field', '_text'=>$label, '_class'=>$class, - 'type'=>$type, 'id'=>$id, 'name'=>$name, 'value'=>$value); - return array_merge($elem, $attrs); + if (is_null($label)) $label = $name; + $elem = array('_elem'=>'field', '_text'=>$label, '_class'=>$class, + 'type'=>$type, 'id'=>$id, 'name'=>$name, 'value'=>$value); + return array_merge($elem, $attrs); } /** @@ -392,10 +391,10 @@ function form_makeField($type, $name, $value='', $label=null, $id='', $class='', * @author Tom N Harris */ function form_makeFieldRight($type, $name, $value='', $label=null, $id='', $class='', $attrs=array()) { - if (is_null($label)) $label = $name; - $elem = array('_elem'=>'fieldright', '_text'=>$label, '_class'=>$class, - 'type'=>$type, 'id'=>$id, 'name'=>$name, 'value'=>$value); - return array_merge($elem, $attrs); + if (is_null($label)) $label = $name; + $elem = array('_elem'=>'fieldright', '_text'=>$label, '_class'=>$class, + 'type'=>$type, 'id'=>$id, 'name'=>$name, 'value'=>$value); + return array_merge($elem, $attrs); } /** @@ -407,10 +406,10 @@ function form_makeFieldRight($type, $name, $value='', $label=null, $id='', $clas * @author Tom N Harris */ function form_makeTextField($name, $value='', $label=null, $id='', $class='', $attrs=array()) { - if (is_null($label)) $label = $name; - $elem = array('_elem'=>'textfield', '_text'=>$label, '_class'=>$class, - 'id'=>$id, 'name'=>$name, 'value'=>$value, 'class'=>'edit'); - return array_merge($elem, $attrs); + if (is_null($label)) $label = $name; + $elem = array('_elem'=>'textfield', '_text'=>$label, '_class'=>$class, + 'id'=>$id, 'name'=>$name, 'value'=>$value, 'class'=>'edit'); + return array_merge($elem, $attrs); } /** @@ -423,10 +422,10 @@ function form_makeTextField($name, $value='', $label=null, $id='', $class='', $a * @author Tom N Harris */ function form_makePasswordField($name, $label=null, $id='', $class='', $attrs=array()) { - if (is_null($label)) $label = $name; - $elem = array('_elem'=>'passwordfield', '_text'=>$label, '_class'=>$class, - 'id'=>$id, 'name'=>$name, 'class'=>'edit'); - return array_merge($elem, $attrs); + if (is_null($label)) $label = $name; + $elem = array('_elem'=>'passwordfield', '_text'=>$label, '_class'=>$class, + 'id'=>$id, 'name'=>$name, 'class'=>'edit'); + return array_merge($elem, $attrs); } /** @@ -438,10 +437,10 @@ function form_makePasswordField($name, $label=null, $id='', $class='', $attrs=ar * @author Michael Klier */ function form_makeFileField($name, $label=null, $id='', $class='', $attrs=array()) { - if (is_null($label)) $label = $name; - $elem = array('_elem'=>'filefield', '_text'=>$label, '_class'=>$class, - 'id'=>$id, 'name'=>$name, 'class'=>'edit'); - return array_merge($elem, $attrs); + if (is_null($label)) $label = $name; + $elem = array('_elem'=>'filefield', '_text'=>$label, '_class'=>$class, + 'id'=>$id, 'name'=>$name, 'class'=>'edit'); + return array_merge($elem, $attrs); } /** @@ -453,11 +452,11 @@ function form_makeFileField($name, $label=null, $id='', $class='', $attrs=array( * @author Tom N Harris */ function form_makeCheckboxField($name, $value='1', $label=null, $id='', $class='', $attrs=array()) { - if (is_null($label)) $label = $name; - if (is_null($value) || $value=='') $value='0'; - $elem = array('_elem'=>'checkboxfield', '_text'=>$label, '_class'=>$class, - 'id'=>$id, 'name'=>$name, 'value'=>$value); - return array_merge($elem, $attrs); + if (is_null($label)) $label = $name; + if (is_null($value) || $value=='') $value='0'; + $elem = array('_elem'=>'checkboxfield', '_text'=>$label, '_class'=>$class, + 'id'=>$id, 'name'=>$name, 'value'=>$value); + return array_merge($elem, $attrs); } /** @@ -469,11 +468,11 @@ function form_makeCheckboxField($name, $value='1', $label=null, $id='', $class=' * @author Tom N Harris */ function form_makeRadioField($name, $value='1', $label=null, $id='', $class='', $attrs=array()) { - if (is_null($label)) $label = $name; - if (is_null($value) || $value=='') $value='0'; - $elem = array('_elem'=>'radiofield', '_text'=>$label, '_class'=>$class, - 'id'=>$id, 'name'=>$name, 'value'=>$value); - return array_merge($elem, $attrs); + if (is_null($label)) $label = $name; + if (is_null($value) || $value=='') $value='0'; + $elem = array('_elem'=>'radiofield', '_text'=>$label, '_class'=>$class, + 'id'=>$id, 'name'=>$name, 'value'=>$value); + return array_merge($elem, $attrs); } /** @@ -489,27 +488,27 @@ function form_makeRadioField($name, $value='1', $label=null, $id='', $class='', * @author Tom N Harris */ function form_makeMenuField($name, $values, $selected='', $label=null, $id='', $class='', $attrs=array()) { - if (is_null($label)) $label = $name; - $options = array(); - reset($values); - // FIXME: php doesn't know the difference between a string and an integer - if (is_string(key($values))) { - foreach ($values as $val=>$text) { - $options[] = array($val,$text, (!is_null($selected) && $val==$selected)); - } - } else { - if (is_integer($selected)) $selected = $values[$selected]; - foreach ($values as $val) { - if (is_array($val)) - @list($val,$text) = $val; - else - $text = null; - $options[] = array($val,$text,$val===$selected); + if (is_null($label)) $label = $name; + $options = array(); + reset($values); + // FIXME: php doesn't know the difference between a string and an integer + if (is_string(key($values))) { + foreach ($values as $val=>$text) { + $options[] = array($val,$text, (!is_null($selected) && $val==$selected)); + } + } else { + if (is_integer($selected)) $selected = $values[$selected]; + foreach ($values as $val) { + if (is_array($val)) + @list($val,$text) = $val; + else + $text = null; + $options[] = array($val,$text,$val===$selected); + } } - } - $elem = array('_elem'=>'menufield', '_options'=>$options, '_text'=>$label, '_class'=>$class, - 'id'=>$id, 'name'=>$name); - return array_merge($elem, $attrs); + $elem = array('_elem'=>'menufield', '_options'=>$options, '_text'=>$label, '_class'=>$class, + 'id'=>$id, 'name'=>$name); + return array_merge($elem, $attrs); } /** @@ -523,30 +522,30 @@ function form_makeMenuField($name, $values, $selected='', $label=null, $id='', $ * @author Tom N Harris */ function form_makeListboxField($name, $values, $selected='', $label=null, $id='', $class='', $attrs=array()) { - if (is_null($label)) $label = $name; - $options = array(); - reset($values); - if (is_null($selected) || $selected == '') - $selected = array(); - elseif (!is_array($selected)) - $selected = array($selected); - // FIXME: php doesn't know the difference between a string and an integer - if (is_string(key($values))) { - foreach ($values as $val=>$text) { - $options[] = array($val,$text,in_array($val,$selected)); - } - } else { - foreach ($values as $val) { - if (is_array($val)) - @list($val,$text) = $val; - else - $text = null; - $options[] = array($val,$text,in_array($val,$selected)); + if (is_null($label)) $label = $name; + $options = array(); + reset($values); + if (is_null($selected) || $selected == '') + $selected = array(); + elseif (!is_array($selected)) + $selected = array($selected); + // FIXME: php doesn't know the difference between a string and an integer + if (is_string(key($values))) { + foreach ($values as $val=>$text) { + $options[] = array($val,$text,in_array($val,$selected)); + } + } else { + foreach ($values as $val) { + if (is_array($val)) + @list($val,$text) = $val; + else + $text = null; + $options[] = array($val,$text,in_array($val,$selected)); + } } - } - $elem = array('_elem'=>'listboxfield', '_options'=>$options, '_text'=>$label, '_class'=>$class, - 'id'=>$id, 'name'=>$name); - return array_merge($elem, $attrs); + $elem = array('_elem'=>'listboxfield', '_options'=>$options, '_text'=>$label, '_class'=>$class, + 'id'=>$id, 'name'=>$name); + return array_merge($elem, $attrs); } /** @@ -559,7 +558,7 @@ function form_makeListboxField($name, $values, $selected='', $label=null, $id='' * @author Tom N Harris */ function form_tag($attrs) { - return '<'.$attrs['_tag'].' '.buildAttributes($attrs).'/>'; + return '<'.$attrs['_tag'].' '.buildAttributes($attrs).'/>'; } /** @@ -572,7 +571,7 @@ function form_tag($attrs) { * @author Tom N Harris */ function form_opentag($attrs) { - return '<'.$attrs['_tag'].' '.buildAttributes($attrs,true).'>'; + return '<'.$attrs['_tag'].' '.buildAttributes($attrs,true).'>'; } /** @@ -585,7 +584,7 @@ function form_opentag($attrs) { * @author Tom N Harris */ function form_closetag($attrs) { - return ''; + return ''; } /** @@ -598,9 +597,9 @@ function form_closetag($attrs) { * @author Tom N Harris */ function form_openfieldset($attrs) { - $s = '
'; - if (!is_null($attrs['_legend'])) $s .= ''.$attrs['_legend'].''; - return $s; + $s = '
'; + if (!is_null($attrs['_legend'])) $s .= ''.$attrs['_legend'].''; + return $s; } /** @@ -612,7 +611,7 @@ function form_openfieldset($attrs) { * @author Tom N Harris */ function form_closefieldset() { - return '
'; + return '
'; } /** @@ -625,7 +624,7 @@ function form_closefieldset() { * @author Tom N Harris */ function form_hidden($attrs) { - return ''; + return ''; } /** @@ -638,13 +637,13 @@ function form_hidden($attrs) { * @author Tom N Harris */ function form_wikitext($attrs) { - // mandatory attributes - unset($attrs['name']); - unset($attrs['id']); - return ''; + // mandatory attributes + unset($attrs['name']); + unset($attrs['id']); + return ''; } /** @@ -657,8 +656,8 @@ function form_wikitext($attrs) { * @author Tom N Harris */ function form_button($attrs) { - $p = (!empty($attrs['_action'])) ? 'name="do['.$attrs['_action'].']" ' : ''; - return ''; + $p = (!empty($attrs['_action'])) ? 'name="do['.$attrs['_action'].']" ' : ''; + return ''; } /** @@ -672,14 +671,14 @@ function form_button($attrs) { * @author Tom N Harris */ function form_field($attrs) { - $s = ''; - $s .= ' '; - if (preg_match('/(^| )block($| )/', $attrs['_class'])) - $s .= '
'; - return $s; + $s = ''; + $s .= ' '; + if (preg_match('/(^| )block($| )/', $attrs['_class'])) + $s .= '
'; + return $s; } /** @@ -693,14 +692,14 @@ function form_field($attrs) { * @author Tom N Harris */ function form_fieldright($attrs) { - $s = ''; - $s .= ' '.$attrs['_text'].''; - if (preg_match('/(^| )block($| )/', $attrs['_class'])) - $s .= '
'; - return $s; + $s = ''; + $s .= ' '.$attrs['_text'].''; + if (preg_match('/(^| )block($| )/', $attrs['_class'])) + $s .= '
'; + return $s; } /** @@ -714,16 +713,16 @@ function form_fieldright($attrs) { * @author Tom N Harris */ function form_textfield($attrs) { - // mandatory attributes - unset($attrs['type']); - $s = ' '; - $s .= ''; - if (preg_match('/(^| )block($| )/', $attrs['_class'])) - $s .= '
'; - return $s; + // mandatory attributes + unset($attrs['type']); + $s = ' '; + $s .= ''; + if (preg_match('/(^| )block($| )/', $attrs['_class'])) + $s .= '
'; + return $s; } /** @@ -737,16 +736,16 @@ function form_textfield($attrs) { * @author Tom N Harris */ function form_passwordfield($attrs) { - // mandatory attributes - unset($attrs['type']); - $s = ' '; - $s .= ''; - if (preg_match('/(^| )block($| )/', $attrs['_class'])) - $s .= '
'; - return $s; + // mandatory attributes + unset($attrs['type']); + $s = ' '; + $s .= ''; + if (preg_match('/(^| )block($| )/', $attrs['_class'])) + $s .= '
'; + return $s; } /** @@ -762,17 +761,17 @@ function form_passwordfield($attrs) { * @author Michael Klier */ function form_filefield($attrs) { - $s = ' '; - $s .= ' '; + $s .= ' */ function form_checkboxfield($attrs) { - // mandatory attributes - unset($attrs['type']); - $s = ''; - $s .= ' '.$attrs['_text'].''; - if (preg_match('/(^| )block($| )/', $attrs['_class'])) - $s .= '
'; - return $s; + // mandatory attributes + unset($attrs['type']); + $s = ''; + $s .= ' '.$attrs['_text'].''; + if (preg_match('/(^| )block($| )/', $attrs['_class'])) + $s .= '
'; + return $s; } /** @@ -809,16 +808,16 @@ function form_checkboxfield($attrs) { * @author Tom N Harris */ function form_radiofield($attrs) { - // mandatory attributes - unset($attrs['type']); - $s = ''; - $s .= ' '.$attrs['_text'].''; - if (preg_match('/(^| )block($| )/', $attrs['_class'])) - $s .= '
'; - return $s; + // mandatory attributes + unset($attrs['type']); + $s = ''; + $s .= ' '.$attrs['_text'].''; + if (preg_match('/(^| )block($| )/', $attrs['_class'])) + $s .= '
'; + return $s; } /** @@ -835,34 +834,34 @@ function form_radiofield($attrs) { * @author Tom N Harris */ function form_menufield($attrs) { - $attrs['size'] = '1'; - $s = ''; - $s .= ' '.DOKU_LF; + if (!empty($attrs['_options'])) { + $selected = false; + for($n=0;$n'.formText($text).''; + } + } else { + $s .= ''; } - } else { - $s .= ''; - } - $s .= NL.''; - if (preg_match('/(^| )block($| )/', $attrs['_class'])) - $s .= '
'; - return $s; + $s .= DOKU_LF.''; + if (preg_match('/(^| )block($| )/', $attrs['_class'])) + $s .= '
'; + return $s; } /** @@ -878,27 +877,27 @@ function form_menufield($attrs) { * @author Tom N Harris */ function form_listboxfield($attrs) { - $s = ' '; - $s .= ''.DOKU_LF; + if (!empty($attrs['_options'])) { + foreach ($attrs['_options'] as $opt) { + @list($value,$text,$select) = $opt; + $p = ''; + if (!is_null($text)) + $p .= ' value="'.formText($value).'"'; + else + $text = $value; + if (!empty($select)) $p .= ' selected="selected"'; + $s .= ''.formText($text).''; + } + } else { + $s .= ''; } - } else { - $s .= ''; - } - $s .= NL.''; - if (preg_match('/(^| )block($| )/', $attrs['_class'])) - $s .= '
'; - return $s; + $s .= DOKU_LF.''; + if (preg_match('/(^| )block($| )/', $attrs['_class'])) + $s .= '
'; + return $s; } -- cgit v1.2.3