0) { $head = ''.implode('', $headers).''; } foreach ($rows as $row) { if (count($row) > 0) { $cells[] = ''.implode('', $row).''; } } if (count($cells) > 0) { $body = ''.implode('', $cells).''; } return ''.$head.''.$body.''.'
'; } /** * Creates the HTML for a select field * * @param $name * @param array $options * @param mixed $selected The value of the selected option, if any * @param array $attributes * @return string */ public static function select($name, array $options, $selected = NULL, array $attributes = array()) { $_options = array(); foreach ($options as $option => $value) { $_attr = array('value' => $value); if ($value == $selected) { $_attr['selected'] = 'selected'; } $_options[] = ''; } return ''; } /** * Creates the HTML for an ordered list * * Reason for separation of the different kinds of lists, are foremost that the generic "list" is a reserved keyword, * and can therefore not be used (unless in a namespace). It does however provide a much cleaner API this way. * * @param array $items * @param array $attributes * @return string */ public static function ol(array $items, array $attributes = array()) { return '
    '.self::_list($items).'
'; } /** * Creates the HTML for an unordered list * * Reason for separation of the different kinds of lists, are foremost that the generic "list" is a reserved keyword, * and can therefore not be used (unless in a namespace). It does however provide a much cleaner API this way. * * @param array $items * @param array $attributes * @return string */ public static function ul(array $items, array $attributes = array()) { return ''; } /** * Creates the HTML for an anchor (link) * * @param string $url * @param null|string $label The label for this anchor, if null it will default to $url * @param array $attributes * @return string */ public static function anchor($url, $label = NULL, array $attributes = array()) { return ' $url ) + $attributes).'>'.($label ? $label : $url).''; } /** * Creates the HTML for list items * * @param array $items * @return string */ protected static function _list(array $items) { return count($items) > 0 ? '
  • '.implode('
  • ', $items).'
  • ' : ''; } /** * Generic way of creating properties for the HTML * * @param array $attributes The properties should be set up as array(property => value) * @return string */ protected static function _attributes(array $attributes) { $_attr = array(); foreach ($attributes as $attribute => $value) { $_attr[] = $attribute.'="'.$value.'"'; } return implode(' ', $_attr); } }