Issues

ZF-10796: Add XHTML1 RDFA doctype to Zend_View_Helper_Doctype

Issue Type: New Feature Created: 2010-12-08T12:48:16.000+0000 Last Updated: 2010-12-18T12:53:25.000+0000 Status: Resolved Fix version(s): - 1.11.2 (30/Dec/10)

Reporter: Jeremy Postlethwaite (gammamatrix) Assignee: Jeremy Postlethwaite (gammamatrix) Tags: - Zend_View

Related issues: - ZF-9743

Attachments: - ZF-10796-docs-code-tests.patch

Description

This doctype allows a developer to use the Resource Description Framework:

http://www.w3.org/TR/xhtml-rdfa-primer/

Using this doctype is necessary if you wish to specify the property or rel component of a tag.

This allows labeling items to be picked up by the browser:

  1. Set the title and creator - uses Dublin Core (dc from purl.org)

The trouble with Bob

Alice

...

  1. You can also attribute a license:

All content on this site is licensed under a Creative Commons License .

  1. This is also needed to get pages to validate when using the Open Graph Protocol:

http://opengraphprotocol.org/

This is used for Facebook enhanced pages.

Comments

Posted by Jeremy Postlethwaite (gammamatrix) on 2010-12-08T12:50:16.000+0000

Here is the diff to the DocTypeTest:

<pre class="highlight">
svn diff tests/Zend/View/Helper/DoctypeTest.php



<pre class="highlight">
Index: tests/Zend/View/Helper/DoctypeTest.php
===================================================================
--- tests/Zend/View/Helper/DoctypeTest.php  (revision 23481)
+++ tests/Zend/View/Helper/DoctypeTest.php  (working copy)
@@ -122,7 +122,7 @@
 
     public function testIsXhtmlReturnsTrueForXhtmlDoctypes()
     {
-        foreach (array('XHTML1_STRICT', 'XHTML1_TRANSITIONAL', 'XHTML1_FRAMESET', 'XHTML5') as $type) {
+        foreach (array('XHTML1_STRICT', 'XHTML1_TRANSITIONAL', 'XHTML1_FRAMESET', 'XHTML1_RDFA', 'XHTML5') as $type) {
             $doctype = $this->helper->doctype($type);
             $this->assertEquals($type, $doctype->getDoctype());
             $this->assertTrue($doctype->isXhtml());

Posted by Jeremy Postlethwaite (gammamatrix) on 2010-12-08T12:55:16.000+0000

Here is the diff to the view helper

<pre class="highlight">
svn diff library/Zend/View/Helper/Doctype.php



<pre class="highlight">
Index: library/Zend/View/Helper/Doctype.php
===================================================================
--- library/Zend/View/Helper/Doctype.php    (revision 23481)
+++ library/Zend/View/Helper/Doctype.php    (working copy)
@@ -43,6 +43,7 @@
     const XHTML1_STRICT       = 'XHTML1_STRICT';
     const XHTML1_TRANSITIONAL = 'XHTML1_TRANSITIONAL';
     const XHTML1_FRAMESET     = 'XHTML1_FRAMESET';
+    const XHTML1_RDFA         = 'XHTML1_RDFA';
     const XHTML_BASIC1        = 'XHTML_BASIC1';
     const XHTML5              = 'XHTML5';
     const HTML4_STRICT        = 'HTML4_STRICT';
@@ -87,6 +88,7 @@
                     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::XHTML1_RDFA         => 'ofollow" href="www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
                     self::XHTML_BASIC1        => 'ofollow" href="www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">',
                     self::XHTML5              => '',
                     self::HTML4_STRICT        => 'ofollow" href="www.w3.org/TR/html4/strict.dtd">www.w3.org/TR/html4/strict.dtd">',
@@ -117,6 +119,7 @@
                 case self::XHTML1_TRANSITIONAL:
                 case self::XHTML1_FRAMESET:
                 case self::XHTML_BASIC1:
+                case self::XHTML1_RDFA:
                 case self::XHTML5:
                 case self::HTML4_STRICT:
                 case self::HTML4_LOOSE:

Posted by Marc Hodgins (mjh_ca) on 2010-12-08T14:22:31.000+0000

Hi Jeremy, I like this idea of building in convenience for implementing RDFa, especially since Facebook implements opengraph.

A few questions -

  1. Doesn't adding the namespace as an attribute to the tag also accomplish the same thing without adding a new doctype? (The opengraph site documents this approach). It would allow this to apply to more than one version of HTML (i.e. HTML5).
<pre class="literal">
  1. If approaching it like this via adding a DOCTYPE, why not add an HTML5 RDFa doctype as well? (i.e. Zend_View_Helper_Doctype::HTML5_RDFA) - see [http://dev.w3.org/html5/rdfa/]

Posted by Jeremy Postlethwaite (gammamatrix) on 2010-12-08T14:50:55.000+0000

Hi Marc, you do not need to have the RDFa doctype to implement Open Graph. Using RDFa ensures your page will validate. If you use any other doctype, you will get flagged by a validator for using "property"

<pre class="highlight">
ofollow" href="www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">
www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://<a href="www.facebook.com/2008/fbml">www.facebook.com/2008/fbml</a>">

Posted by Jeremy Postlethwaite (gammamatrix) on 2010-12-08T14:54:59.000+0000

HTML5_RFDA

test

Posted by Marc Hodgins (mjh_ca) on 2010-12-08T20:29:10.000+0000

Revised patch attached which consolidates Jeremy's changes, adds documentation and adds an isRdfa1() method to allow view helpers to differentiate behavior.

Posted by Jeremy Postlethwaite (gammamatrix) on 2010-12-10T10:27:44.000+0000

I attached another patch.

This includes the previous patch with the test and code. It also adds documentation in English on how to use the doctype with Open Graph.

Posted by Jeremy Postlethwaite (gammamatrix) on 2010-12-16T14:49:40.000+0000

Committed code in r23525

Posted by Marc Hodgins (mjh_ca) on 2010-12-17T22:38:06.000+0000

isRdfa() method of Zend_View_HelperDoctype added in r23538, merged to 1.11 release branch in r23539

Posted by Jeremy Postlethwaite (gammamatrix) on 2010-12-18T12:53:25.000+0000

It is in there:

http://framework.zend.com/svn/framework/…

I did forget to include your patch the first time I checked it in.

I am not sure which revision.

Have you found an issue?

See the Overview section for more details.

Copyright

© 2006-2016 by Zend, a Rogue Wave Company. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts