Просмотр исходного кода

Adding XHTML1 RDFA doctype to Zend_View_Helper_Doctype. Resolves ZF-10796

git-svn-id: http://framework.zend.com/svn/framework/standard/trunk@23525 44c647ce-9c0f-0410-b52a-842ac1e357ba
gammamatrix 15 лет назад
Родитель
Сommit
81087e3b76

+ 45 - 1
documentation/manual/en/module_specs/Zend_View-Helpers-Doctype.xml

@@ -21,6 +21,7 @@
         <listitem><para><constant>XHTML1_STRICT</constant></para></listitem>
         <listitem><para><constant>XHTML1_TRANSITIONAL</constant></para></listitem>
         <listitem><para><constant>XHTML1_FRAMESET</constant></para></listitem>
+        <listitem><para><constant>XHTML1_RDFA</constant></para></listitem>
         <listitem><para><constant>XHTML_BASIC1</constant></para></listitem>
         <listitem><para><constant>HTML4_STRICT</constant></para></listitem>
         <listitem><para><constant>HTML4_LOOSE</constant></para></listitem>
@@ -86,7 +87,7 @@ if ($view->doctype()->isXhtml()) {
 ]]></programlisting>
 
         <para>
-            You can also check if the doctype represents an <acronym>HTML5</acronym> document
+            You can also check if the doctype represents an <acronym>HTML5</acronym> document.
         </para>
 
         <programlisting language="php"><![CDATA[
@@ -95,6 +96,49 @@ if ($view->doctype()->isHtml5()) {
 }
 ]]></programlisting>
     </example>
+
+    <example id="zend.view.helpers.initial.doctype.xhtml1_rdfa">
+        <title>Choosing a Doctype to Use with the Open Graph Protocol</title>
+
+        <para>
+            If you would like to implement the <ulink url="http://opengraphprotocol.org/">
+            Open Graph Protocol</ulink>, it is best to specify the XHTML1_RDFA doctype.
+            This doctype allows a developer to use the <ulink url="http://www.w3.org/TR/xhtml-rdfa-primer/">
+            Resource Description Framework</ulink> within an <acronym>XHTML</acronym> document.
+        </para>
+
+        <programlisting language="php"><![CDATA[
+$doctypeHelper = new Zend_View_Helper_Doctype();
+$doctypeHelper->doctype('XHTML1_RDFA');
+]]></programlisting>
+
+        <para>
+        It is not required to use the XHTML1_RDFA doctype to enable the Open Graph Protocol, but it is required to enable the namespaces inside the html tag:
+        </para>
+
+        <programlisting language="html"><![CDATA[
+$doctype = $view->doctype()->getDoctype();
+<html xmlns="http://www.w3.org/1999/xhtml" xmlns:og="http://opengraphprotocol.org/schema/" xmlns:fb="http://www.facebook.com/2008/fbml">
+]]></programlisting>
+
+        <para>
+            In the above example, we specifed two namespaces in the html tag. One for the Open Graph and another for <ulink url="http://developers.facebook.com/docs/opengraph">
+            Facebook Open Graph</ulink>.
+        </para>
+        
+        <para>
+            Here is how to specify a meta tag with a property:
+        </para>
+        
+        <programlisting language="html"><![CDATA[
+<meta property="og:type" content="musician" />
+]]></programlisting>
+
+        <para>
+            We set the property to og:type. The og references the Open Graph namespace we specified in the html tag. The content identifies the page as being about a musician.
+        </para>
+
+    </example>
 </sect3>
 <!--
 vim:se ts=4 sw=4 et:

+ 3 - 0
library/Zend/View/Helper/Doctype.php

@@ -43,6 +43,7 @@ class Zend_View_Helper_Doctype extends Zend_View_Helper_Abstract
     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 @@ class Zend_View_Helper_Doctype extends Zend_View_Helper_Abstract
                     self::XHTML1_STRICT       => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
                     self::XHTML1_TRANSITIONAL => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
                     self::XHTML1_FRAMESET     => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
+                    self::XHTML1_RDFA         => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
                     self::XHTML_BASIC1        => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">',
                     self::XHTML5              => '<!DOCTYPE html>',
                     self::HTML4_STRICT        => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
@@ -117,6 +119,7 @@ class Zend_View_Helper_Doctype extends Zend_View_Helper_Abstract
                 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:

+ 1 - 1
tests/Zend/View/Helper/DoctypeTest.php

@@ -117,7 +117,7 @@ class Zend_View_Helper_DoctypeTest extends PHPUnit_Framework_TestCase
 
     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());