| | |
| | | return ''; |
| | | } |
| | | |
| | | $allowed_f = array_flip((array)$allowed); |
| | | $allowed_f = array_flip((array)$allowed); |
| | | $attrib_arr = array(); |
| | | |
| | | foreach ($attrib as $key => $value) { |
| | | // skip size if not numeric |
| | | if ($key == 'size' && !is_numeric($value)) { |
| | | continue; |
| | | } |
| | | |
| | | // ignore "internal" or not allowed attributes |
| | | if ($key == 'nl' || ($allowed && !isset($allowed_f[$key])) || $value === null) { |
| | | // ignore "internal" or empty attributes |
| | | if ($key == 'nl' || $value === null) { |
| | | continue; |
| | | } |
| | | |
| | | // ignore not allowed attributes |
| | | if (!empty($allowed)) { |
| | | $is_data_attr = @substr_compare($key, 'data-', 0, 5) === 0; |
| | | if (!isset($allowed_f[$key]) && (!$is_data_attr || !isset($allowed_f['data-*']))) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | // skip empty eventhandlers |
| | |
| | | * |
| | | * @param mixed $names Option name or array with option names |
| | | * @param mixed $values Option value or array with option values |
| | | * @param array $attrib Additional attributes for the option entry |
| | | */ |
| | | public function add($names, $values = null) |
| | | public function add($names, $values = null, $attrib = array()) |
| | | { |
| | | if (is_array($names)) { |
| | | foreach ($names as $i => $text) { |
| | | $this->options[] = array('text' => $text, 'value' => $values[$i]); |
| | | $this->options[] = array('text' => $text, 'value' => $values[$i]) + $attrib; |
| | | } |
| | | } |
| | | else { |
| | | $this->options[] = array('text' => $names, 'value' => $values); |
| | | $this->options[] = array('text' => $names, 'value' => $values) + $attrib; |
| | | } |
| | | } |
| | | |
| | |
| | | $option_content = self::quote($option_content); |
| | | } |
| | | |
| | | $this->content .= self::tag('option', $attr, $option_content); |
| | | $this->content .= self::tag('option', $attr + $option, $option_content, array('value','label','class','style','title','disabled','selected')); |
| | | } |
| | | |
| | | return parent::show(); |
| | |
| | | */ |
| | | public function __construct($attrib = array()) |
| | | { |
| | | $default_attrib = self::$doctype == 'xhtml' ? array('summary' => '', 'border' => 0) : array(); |
| | | $this->attrib = array_merge($attrib, $default_attrib); |
| | | $default_attrib = self::$doctype == 'xhtml' ? array('summary' => '', 'border' => '0') : array(); |
| | | $this->attrib = array_merge($attrib, $default_attrib); |
| | | |
| | | if (!empty($attrib['tagname']) && $attrib['tagname'] != 'table') { |
| | | $this->tagname = $attrib['tagname']; |
| | |
| | | private function _row_tagname() |
| | | { |
| | | static $row_tagnames = array('table' => 'tr', 'ul' => 'li', '*' => 'div'); |
| | | return $row_tagnames[$this->tagname] ?: $row_tagnames['*']; |
| | | return $row_tagnames[$this->tagname] ? $row_tagnames[$this->tagname] : $row_tagnames['*']; |
| | | } |
| | | |
| | | /** |
| | |
| | | private function _col_tagname() |
| | | { |
| | | static $col_tagnames = array('table' => 'td', '*' => 'span'); |
| | | return $col_tagnames[$this->tagname] ?: $col_tagnames['*']; |
| | | return $col_tagnames[$this->tagname] ? $col_tagnames[$this->tagname] : $col_tagnames['*']; |
| | | } |
| | | |
| | | } |