Index: HeadMeta.php =================================================================== --- HeadMeta.php (revision 17886) +++ HeadMeta.php (working copy) @@ -39,7 +39,7 @@ * Types of attributes * @var array */ - protected $_typeKeys = array('name', 'http-equiv'); + protected $_typeKeys = array('name', 'http-equiv', 'charset'); protected $_requiredKeys = array('content'); protected $_modifierKeys = array('lang', 'scheme'); @@ -162,6 +162,17 @@ return parent::__call($method, $args); } + public function setCharset($charset) + { + $item = new stdClass; + $item->type = 'charset'; + $item->charset = $charset; + $item->content = null; + $item->modifiers = array(); + $this->set($item); + return $this; + } + /** * Determine if item is valid * @@ -172,12 +183,17 @@ { if ((!$item instanceof stdClass) || !isset($item->type) - || !isset($item->content) || !isset($item->modifiers)) { return false; } + if (!isset($item->content) + && ($this->view->doctype()->getDoctype() !== 'HTML5' + || ($this->view->doctype()->getDoctype() == 'HTML5' && $item->type !== 'charset'))) { + return false; + } + return true; } @@ -293,6 +309,12 @@ $modifiersString = ''; foreach ($item->modifiers as $key => $value) { + if ($this->view->doctype()->getDoctype() == 'HTML5' + && $key == 'scheme') { + require_once 'Zend/View/Exception.php'; + throw new Zend_View_Exception('Invalid modifier ' + . '"scheme" provided; not supported by HTML 5'); + } if (!in_array($key, $this->_modifierKeys)) { continue; } @@ -300,9 +322,14 @@ } if ($this->view instanceof Zend_View_Abstract) { - $tpl = ($this->view->doctype()->isXhtml()) - ? '' - : ''; + if ($this->view->doctype()->getDoctype() == 'HTML5' + && $type == 'charset') { + $tpl = ''; + } elseif ($this->view->doctype()->isXhtml()) { + $tpl = ''; + } else { + $tpl = ''; + } } else { $tpl = ''; }