Index: tests/Zend/View/Helper/HeadMetaTest.php
===================================================================
--- tests/Zend/View/Helper/HeadMetaTest.php (revision 23566)
+++ tests/Zend/View/Helper/HeadMetaTest.php (working copy)
@@ -363,6 +363,61 @@
}
/**
+ * @group ZF-9743
+ */
+ public function testPropertyIsSupportedWithRdfaDoctype()
+ {
+ $this->view->doctype('XHTML1_RDFA');
+ $this->helper->headMeta('foo', 'og:title', 'property');
+ $this->assertEquals('',
+ $this->helper->toString()
+ );
+ }
+
+ /**
+ * @group ZF-9743
+ */
+ public function testPropertyIsNotSupportedByDefaultDoctype()
+ {
+ try {
+ $this->helper->headMeta('foo', 'og:title', 'property');
+ $this->fail('meta property attribute should not be supported on default doctype');
+ } catch (Zend_View_Exception $e) {
+ $this->assertContains('Invalid value passed', $e->getMessage());
+ }
+ }
+
+ /**
+ * @group ZF-9743
+ * @depends testPropertyIsSupportedWithRdfaDoctype
+ */
+ public function testOverloadingAppendPropertyAppendsMetaTagToStack()
+ {
+ $this->view->doctype('XHTML1_RDFA');
+ $this->_testOverloadAppend('property');
+ }
+
+ /**
+ * @group ZF-9743
+ * @depends testPropertyIsSupportedWithRdfaDoctype
+ */
+ public function testOverloadingPrependPropertyPrependsMetaTagToStack()
+ {
+ $this->view->doctype('XHTML1_RDFA');
+ $this->_testOverloadPrepend('property');
+ }
+
+ /**
+ * @group ZF-9743
+ * @depends testPropertyIsSupportedWithRdfaDoctype
+ */
+ public function testOverloadingSetPropertyOverwritesMetaTagStack()
+ {
+ $this->view->doctype('XHTML1_RDFA');
+ $this->_testOverloadSet('property');
+ }
+
+ /**
* @issue ZF-2663
*/
public function testSetNameDoesntClobber()
Index: library/Zend/View/Helper/HeadMeta.php
===================================================================
--- library/Zend/View/Helper/HeadMeta.php (revision 23572)
+++ library/Zend/View/Helper/HeadMeta.php (working copy)
@@ -39,7 +39,7 @@
* Types of attributes
* @var array
*/
- protected $_typeKeys = array('name', 'http-equiv', 'charset');
+ protected $_typeKeys = array('name', 'http-equiv', 'charset', 'property');
protected $_requiredKeys = array('content');
protected $_modifierKeys = array('lang', 'scheme');
@@ -98,6 +98,8 @@
return 'name';
case 'HttpEquiv':
return 'http-equiv';
+ case 'Property':
+ return 'property';
default:
require_once 'Zend/View/Exception.php';
$e = new Zend_View_Exception(sprintf('Invalid type "%s" passed to _normalizeType', $type));
@@ -118,6 +120,10 @@
* - offsetGetHttpEquiv($index, $keyValue, $content, $modifers = array())
* - prependHttpEquiv($keyValue, $content, $modifiers = array())
* - setHttpEquiv($keyValue, $content, $modifiers = array())
+ * - appendProperty($keyValue, $content, $modifiers = array())
+ * - offsetGetProperty($index, $keyValue, $content, $modifiers = array())
+ * - prependProperty($keyValue, $content, $modifiers = array())
+ * - setProperty($keyValue, $content, $modifiers = array())
*
* @param string $method
* @param array $args
@@ -125,7 +131,7 @@
*/
public function __call($method, $args)
{
- if (preg_match('/^(?Pset|(pre|ap)pend|offsetSet)(?PName|HttpEquiv)$/', $method, $matches)) {
+ if (preg_match('/^(?Pset|(pre|ap)pend|offsetSet)(?PName|HttpEquiv|Property)$/', $method, $matches)) {
$action = $matches['action'];
$type = $this->_normalizeType($matches['type']);
$argc = count($args);
@@ -202,6 +208,12 @@
return false;
}
+ // is only supported with doctype RDFa
+ if (!$this->view->doctype()->isRdfa()
+ && $item->type === 'property') {
+ return false;
+ }
+
return true;
}
Index: documentation/manual/en/module_specs/Zend_View-Helpers-Doctype.xml
===================================================================
--- documentation/manual/en/module_specs/Zend_View-Helpers-Doctype.xml (revision 23566)
+++ documentation/manual/en/module_specs/Zend_View-Helpers-Doctype.xml (working copy)
@@ -101,8 +101,8 @@
Choosing a Doctype to Use with the Open Graph Protocol
- If you would like to implement the
- Open Graph Protocol, it is best to specify the XHTML1_RDFA doctype.
+ To implement the
+ Open Graph Protocol, you may specify the XHTML1_RDFA doctype.
This doctype allows a developer to use the
Resource Description Framework within an XHTML document.
@@ -113,48 +113,40 @@
]]>
- 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:
+ The RDFa doctype allows XHTML to validate when the 'property'
+ meta tag attribute is used per the Open Graph Protocol spec. Example
+ within a view script:
doctype() ?>
-
-
+doctype('XHTML1_RDFA'); ?>
+
+
+
]]>
- In the above example, we specifed two namespaces in the html tag. One for the Open Graph and another for
- Facebook Open Graph.
+ In the previous example, 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. See
+ the Open Graph Protocol documentation
+ for supported properties. The HeadMeta helper
+ may be used to programmatically set these Open Graph Protocol meta tags.
-
-
- Here is how to specify a meta tag with a property:
-
-
-
-]]>
- 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.
+ Here is how you check if the doctype is set to XHTML1_RDFA:
-
- Here is who you check if the doctype includes RFDa in the document.
-
-
doctype() ?>
-
-doctype()->isRdfa()): ?>
-
-
-
-
-
-
-
-
+doctype()->isRdfa()): ?>
+ xmlns:og="http://opengraphprotocol.org/schema/"
+ xmlns:fb="http://www.facebook.com/2008/fbml"
+
+>
]]>
Index: documentation/manual/en/module_specs/Zend_View-Helpers-HeadMeta.xml
===================================================================
--- documentation/manual/en/module_specs/Zend_View-Helpers-HeadMeta.xml (revision 23566)
+++ documentation/manual/en/module_specs/Zend_View-Helpers-HeadMeta.xml (working copy)
@@ -74,6 +74,37 @@
+ The following methods are also supported with XHTML1_RDFA doctype
+ set with the Doctype helper:
+
+
+
+
+
+ appendProperty($property, $content, $modifiers)
+
+
+
+
+
+ offsetSetProperty($index, $property, $content, $modifiers)
+
+
+
+
+
+ prependProperty($property, $content, $modifiers)
+
+
+
+
+
+ setProperty($property, $content, $modifiers)
+
+
+
+
+
The $keyValue item is used to define a value for the 'name'
or 'http-equiv' key; $content is the value for the
'content' key, and $modifiers is an optional associative
@@ -86,7 +117,8 @@
$keyValue, $keyType = 'name', $modifiers = array(), $placement =
'APPEND'). $keyValue is the content for the key
specified in $keyType, which should be either 'name' or
- 'http-equiv'. $placement can be either 'SET' (overwrites
+ 'http-equiv'. $keyType may also be specified as 'property' if the
+ doctype has been set to XHTML1_RDFA. $placement can be 'SET' (overwrites
all previously stored values), 'APPEND' (added to end of stack), or
'PREPEND' (added to top of stack).
@@ -179,6 +211,32 @@
headMeta() ?>
]]>
+
+
+ HeadMeta Usage with XHTML1_RDFA doctype
+
+
+ Enabling the RDFa doctype with the Doctype helper
+ enables the use of the 'property' attribute (in addition to the standard 'name' and 'http-equiv') with HeadMeta.
+ This is commonly used with the Facebook Open Graph Protocol.
+
+
+
+ For instance, you may specify an open graph page title and type as follows:
+
+
+ doctype(Zend_View_Helper_Doctype::XHTML_RDFA);
+$this->headMeta()->setProperty('og:title', 'my article title');
+$this->headMeta()->setProperty('og:type', 'article');
+echo $this->headMeta();
+
+// output is:
+//
+//
+]]>
+
+