<?php/** * HTML functions. Deals with common html elements, to help separate programming logic from presentation. *//** * html_a * * Link tags in HTML * * @param string $label Viewable link * @param array $attr Array of HTML attributes */function html_a($label, $attr = array()){ if (!empty($label)) { return '<a'.html_parse_attributes($attr).'>'.$label.'</a>'; }}/** * html_parseAttributes * * Function created to help deal with HTML tag attributes. * * @param array $attr Array of HTML attributes */function html_parseAttributes($attr = array()){ if (count($attr) > 0) { foreach ($attr as $key => $value) { $attributes .= ' '.$key.'="'.$value.'"'; } } return $attributes;}/** * html_genericElement * * Generic HTML element function to help create html elements. * * @param string $name * @param array $attr Array of HTML attributes */function html_genericElement($name, $attr = array()){ $element = '<'.$name.html_parse_attributes($attr); if (W3C_STANDARD == 'XHTML') { $element .= ' /'; } $element .= '>'; return $element;}/** * html_form_select * * HTML form element, select. * * @param array $attr Array of HTML attributes */function html_form_select($attr = array(), $options = array()){ $numOptions = count($options); $select = '<select'.html_parse_attributes($attr).'>'; foreach ($options as $name => $value) { $select .= '<option value="'.$value.'">'.$name.'</option>'; } return $select;}/** * html_form_select * * HTML form element, select. * * @param string $value Value of the textarea field. This isn't an explicit HTML textarea attribute, so is provided separately. * @param array $attr Array of HTML attributes */function html_form_textarea($value, $attr = array()){ return '<textarea'.html_parseAttributes($attr).'>'.$value.'</textarea>';}?>