| | |
| | | /* |
| | | +-----------------------------------------------------------------------+ |
| | | | This file is part of the Roundcube Webmail client | |
| | | | Copyright (C) 2005-2011, The Roundcube Dev Team | |
| | | | Copyright (C) 2005-2013, The Roundcube Dev Team | |
| | | | | |
| | | | Licensed under the GNU General Public License version 3 or | |
| | | | any later version with exceptions for skins & plugins. | |
| | |
| | | |
| | | public static $doctype = 'xhtml'; |
| | | public static $lc_tags = true; |
| | | public static $common_attrib = array('id','class','style','title','align'); |
| | | public static $containers = array('iframe','div','span','p','h1','h2','h3','form','textarea','table','thead','tbody','tr','th','td','style','script'); |
| | | public static $common_attrib = array('id','class','style','title','align','unselectable','tabindex','role'); |
| | | public static $containers = array('iframe','div','span','p','h1','h2','h3','ul','form','textarea','table','thead','tbody','tr','th','td','style','script'); |
| | | |
| | | |
| | | /** |
| | |
| | | $attr = array('src' => $attr); |
| | | } |
| | | return self::tag('img', $attr + array('alt' => ''), null, array_merge(self::$common_attrib, |
| | | array('src','alt','width','height','border','usemap','onclick'))); |
| | | array('src','alt','width','height','border','usemap','onclick','onerror'))); |
| | | } |
| | | |
| | | /** |
| | |
| | | $attr = array('src' => $attr); |
| | | } |
| | | return self::tag('iframe', $attr, $cont, array_merge(self::$common_attrib, |
| | | array('src','name','width','height','border','frameborder','onload'))); |
| | | array('src','name','width','height','border','frameborder','onload','allowfullscreen'))); |
| | | } |
| | | |
| | | /** |
| | |
| | | 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, except aria-* and data-* |
| | | if (!empty($allowed)) { |
| | | $is_data_attr = @substr_compare($key, 'data-', 0, 5) === 0; |
| | | $is_aria_attr = @substr_compare($key, 'aria-', 0, 5) === 0; |
| | | if (!$is_aria_attr && !$is_data_attr && !isset($allowed_f[$key])) { |
| | | continue; |
| | | } |
| | | } |
| | | |
| | | // skip empty eventhandlers |
| | |
| | | $option_content = self::quote($option_content); |
| | | } |
| | | |
| | | $this->content .= self::tag('option', $attr + $option, $option_content, array('class','style','title','disabled','selected')); |
| | | $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']; |
| | |
| | | if (!empty($this->header)) { |
| | | $rowcontent = ''; |
| | | foreach ($this->header as $c => $col) { |
| | | $rowcontent .= self::tag($this->_col_tagname(), $col->attrib, $col->content); |
| | | $rowcontent .= self::tag($this->_head_tagname(), $col->attrib, $col->content); |
| | | } |
| | | $thead = $this->tagname == 'table' ? self::tag('thead', null, self::tag('tr', null, $rowcontent, parent::$common_attrib)) : |
| | | self::tag($this->_row_tagname(), array('class' => 'thead'), $rowcontent, parent::$common_attrib); |
| | |
| | | } |
| | | |
| | | /** |
| | | * Getter for the corresponding tag name for table row elements |
| | | */ |
| | | private function _head_tagname() |
| | | { |
| | | static $head_tagnames = array('table' => 'th', '*' => 'span'); |
| | | return $head_tagnames[$this->tagname] ?: $head_tagnames['*']; |
| | | } |
| | | |
| | | /** |
| | | * Getter for the corresponding tag name for table cell elements |
| | | */ |
| | | private function _col_tagname() |