Issues

ZF-2965: Zend_View_Helper_Doctype add xHTML 1.1 doctype

Description

Right now you can only specify HTML4 or xHTML1 doctypes using this helper. There should be a possibility to handle also xHTML 1.1 doctype. Below is the code that needs to be added in Doctype.php file in order to achieve this.

current:


const XHTML1_STRICT       = 'XHTML1_STRICT';
const XHTML1_TRANSITIONAL = 'XHTML1_TRANSITIONAL';
const XHTML1_FRAMESET     = 'XHTML1_FRAMESET';
const HTML4_STRICT        = 'HTML4_STRICT';
const HTML4_LOOSE         = 'HTML4_LOOSE';
const HTML4_FRAMESET      = 'HTML4_FRAMESET';
const CUSTOM_XHTML        = 'CUSTOM_XHTML';
const CUSTOM              = 'CUSTOM';

new:


const XHTML11             = 'XHTML11';
const XHTML1_STRICT       = 'XHTML1_STRICT';
const XHTML1_TRANSITIONAL = 'XHTML1_TRANSITIONAL';
const XHTML1_FRAMESET     = 'XHTML1_FRAMESET';
const HTML4_STRICT        = 'HTML4_STRICT';
const HTML4_LOOSE         = 'HTML4_LOOSE';
const HTML4_FRAMESET      = 'HTML4_FRAMESET';
const CUSTOM_XHTML        = 'CUSTOM_XHTML';
const CUSTOM              = 'CUSTOM';

current:


    public function __construct()
    {
        if (!Zend_Registry::isRegistered($this->_regKey)) {
            $this->_registry = new ArrayObject(array(
                'doctypes' => array(
                    self::XHTML1_STRICT       => 'ofollow" href="www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
                    self::XHTML1_TRANSITIONAL => 'ofollow" href="www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
                    self::XHTML1_FRAMESET     => 'ofollow" href="www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
                    self::HTML4_STRICT        => 'ofollow" href="www.w3.org/TR/html4/strict.dtd">www.w3.org/TR/html4/strict.dtd">',
                    self::HTML4_LOOSE         => 'ofollow" href="www.w3.org/TR/html4/loose.dtd">www.w3.org/TR/html4/loose.dtd">',
                    self::HTML4_FRAMESET      => 'ofollow" href="www.w3.org/TR/html4/frameset.dtd">www.w3.org/TR/html4/frameset.dtd">',
                )
            ));
            Zend_Registry::set($this->_regKey, $this->_registry);
            $this->setDoctype($this->_defaultDoctype);
        } else {
            $this->_registry = Zend_Registry::get($this->_regKey);
        }
    }

new:


    public function __construct()
    {
        if (!Zend_Registry::isRegistered($this->_regKey)) {
            $this->_registry = new ArrayObject(array(
                'doctypes' => array(
                    self::XHTML11             => 'ofollow" href="www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
                    self::XHTML1_STRICT       => 'ofollow" href="www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
                    self::XHTML1_TRANSITIONAL => 'ofollow" href="www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
                    self::XHTML1_FRAMESET     => 'ofollow" href="www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
                    self::HTML4_STRICT        => 'ofollow" href="www.w3.org/TR/html4/strict.dtd">www.w3.org/TR/html4/strict.dtd">',
                    self::HTML4_LOOSE         => 'ofollow" href="www.w3.org/TR/html4/loose.dtd">www.w3.org/TR/html4/loose.dtd">',
                    self::HTML4_FRAMESET      => 'ofollow" href="www.w3.org/TR/html4/frameset.dtd">www.w3.org/TR/html4/frameset.dtd">',
                )
            ));
            Zend_Registry::set($this->_regKey, $this->_registry);
            $this->setDoctype($this->_defaultDoctype);
        } else {
            $this->_registry = Zend_Registry::get($this->_regKey);
        }
    }

current:


    public function doctype($doctype = null)
    {
        if (null !== $doctype) {
            switch ($doctype) {
                case self::XHTML1_STRICT:
                case self::XHTML1_TRANSITIONAL:
                case self::XHTML1_FRAMESET:
                case self::HTML4_STRICT:
                case self::HTML4_LOOSE:
                case self::HTML4_FRAMESET:
                    $this->setDoctype($doctype);
                    break;

new:


    public function doctype($doctype = null)
    {
        if (null !== $doctype) {
            switch ($doctype) {
                case self::XHTML11:
                case self::XHTML1_STRICT:
                case self::XHTML1_TRANSITIONAL:
                case self::XHTML1_FRAMESET:
                case self::HTML4_STRICT:
                case self::HTML4_LOOSE:
                case self::HTML4_FRAMESET:
                    $this->setDoctype($doctype);
                    break;

Comments

Resolved in SVN r9063. I added two doctypes, XHTML1.1 and XHTML BASIC 1.0 .