Skip to content
This repository was archived by the owner on Jan 31, 2020. It is now read-only.

Commit d157fcb

Browse files
committed
Merge remote-tracking branch 'AldemarBernal/feature/opengraph'
6 parents d2649e3 + f0162d1 + 6f01416 + a2b3753 + 1786961 + 905ecbc commit d157fcb

File tree

4 files changed

+74
-7
lines changed

4 files changed

+74
-7
lines changed

src/Helper/Doctype.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,10 +39,10 @@ class Doctype extends AbstractHelper
3939
* DocType constants
4040
*/
4141
const XHTML11 = 'XHTML11';
42-
const XHTML1_RDFA1 = 'XHTML_RDFA1';
4342
const XHTML1_STRICT = 'XHTML1_STRICT';
4443
const XHTML1_TRANSITIONAL = 'XHTML1_TRANSITIONAL';
4544
const XHTML1_FRAMESET = 'XHTML1_FRAMESET';
45+
const XHTML1_RDFA = 'XHTML1_RDFA';
4646
const XHTML_BASIC1 = 'XHTML_BASIC1';
4747
const XHTML5 = 'XHTML5';
4848
const HTML4_STRICT = 'HTML4_STRICT';
@@ -82,10 +82,10 @@ public function __construct()
8282
$this->_registry = new ArrayObject(array(
8383
'doctypes' => array(
8484
self::XHTML11 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">',
85-
self::XHTML1_RDFA1 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
8685
self::XHTML1_STRICT => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">',
8786
self::XHTML1_TRANSITIONAL => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">',
8887
self::XHTML1_FRAMESET => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Frameset//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-frameset.dtd">',
88+
self::XHTML1_RDFA => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML+RDFa 1.0//EN" "http://www.w3.org/MarkUp/DTD/xhtml-rdfa-1.dtd">',
8989
self::XHTML_BASIC1 => '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">',
9090
self::XHTML5 => '<!DOCTYPE html>',
9191
self::HTML4_STRICT => '<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">',
@@ -114,10 +114,10 @@ public function __invoke($doctype = null)
114114
if (null !== $doctype) {
115115
switch ($doctype) {
116116
case self::XHTML11:
117-
case self::XHTML1_RDFA1:
118117
case self::XHTML1_STRICT:
119118
case self::XHTML1_TRANSITIONAL:
120119
case self::XHTML1_FRAMESET:
120+
case self::XHTML1_RDFA:
121121
case self::XHTML_BASIC1:
122122
case self::XHTML5:
123123
case self::HTML4_STRICT:

src/Helper/HeadMeta.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ class HeadMeta extends Placeholder\Container\Standalone
3939
* Types of attributes
4040
* @var array
4141
*/
42-
protected $_typeKeys = array('name', 'http-equiv', 'charset');
42+
protected $_typeKeys = array('name', 'http-equiv', 'charset', 'property');
4343
protected $_requiredKeys = array('content');
4444
protected $_modifierKeys = array('lang', 'scheme');
4545

@@ -105,6 +105,8 @@ protected function _normalizeType($type)
105105
return 'name';
106106
case 'HttpEquiv':
107107
return 'http-equiv';
108+
case 'Property':
109+
return 'property';
108110
default:
109111
throw new Exception\DomainException(sprintf(
110112
'Invalid type "%s" passed to _normalizeType',
@@ -125,6 +127,10 @@ protected function _normalizeType($type)
125127
* - offsetGetHttpEquiv($index, $keyValue, $content, $modifers = array())
126128
* - prependHttpEquiv($keyValue, $content, $modifiers = array())
127129
* - setHttpEquiv($keyValue, $content, $modifiers = array())
130+
* - appendProperty($keyValue, $content, $modifiers = array())
131+
* - offsetGetProperty($index, $keyValue, $content, $modifiers = array())
132+
* - prependProperty($keyValue, $content, $modifiers = array())
133+
* - setProperty($keyValue, $content, $modifiers = array())
128134
*
129135
* @param string $method
130136
* @param array $args
@@ -133,7 +139,7 @@ protected function _normalizeType($type)
133139
*/
134140
public function __call($method, $args)
135141
{
136-
if (preg_match('/^(?P<action>set|(pre|ap)pend|offsetSet)(?P<type>Name|HttpEquiv)$/', $method, $matches)) {
142+
if (preg_match('/^(?P<action>set|(pre|ap)pend|offsetSet)(?P<type>Name|HttpEquiv|Property)$/', $method, $matches)) {
137143
$action = $matches['action'];
138144
$type = $this->_normalizeType($matches['type']);
139145
$argc = count($args);
@@ -209,6 +215,12 @@ protected function _isValid($item)
209215
return false;
210216
}
211217

218+
// <meta property= ... /> is only supported with doctype RDFa
219+
if (!$this->view->plugin('doctype')->isRdfa()
220+
&& $item->type === 'property') {
221+
return false;
222+
}
223+
212224
return true;
213225
}
214226

test/Helper/DoctypeTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ public function testIsXhtmlReturnsTrueForXhtmlDoctypes()
100100
Helper\Doctype::XHTML1_STRICT,
101101
Helper\Doctype::XHTML1_TRANSITIONAL,
102102
Helper\Doctype::XHTML1_FRAMESET,
103-
Helper\Doctype::XHTML1_RDFA1,
103+
Helper\Doctype::XHTML1_RDFA,
104104
Helper\Doctype::XHTML5
105105
);
106106

@@ -217,7 +217,7 @@ public function testIsRdfaReturnsTrueForRdfaDoctype()
217217
$this->assertFalse($this->helper->__invoke($type)->isRdfa());
218218
}
219219

220-
$this->assertTrue($this->helper->__invoke(Helper\Doctype::XHTML1_RDFA1)->isRdfa());
220+
$this->assertTrue($this->helper->__invoke(Helper\Doctype::XHTML1_RDFA)->isRdfa());
221221
}
222222
}
223223

test/Helper/HeadMetaTest.php

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,61 @@ public function testCharset()
438438
$view->plugin('headMeta')->toString());
439439
}
440440

441+
/**
442+
* @group ZF-9743
443+
*/
444+
public function testPropertyIsSupportedWithRdfaDoctype()
445+
{
446+
$this->view->doctype('XHTML1_RDFA');
447+
$this->helper->__invoke('foo', 'og:title', 'property');
448+
$this->assertEquals('<meta property="og:title" content="foo" />',
449+
$this->helper->toString()
450+
);
451+
}
452+
453+
/**
454+
* @group ZF-9743
455+
*/
456+
public function testPropertyIsNotSupportedByDefaultDoctype()
457+
{
458+
try {
459+
$this->helper->__invoke('foo', 'og:title', 'property');
460+
$this->fail('meta property attribute should not be supported on default doctype');
461+
} catch (ViewException $e) {
462+
$this->assertContains('Invalid value passed', $e->getMessage());
463+
}
464+
}
465+
466+
/**
467+
* @group ZF-9743
468+
* @depends testPropertyIsSupportedWithRdfaDoctype
469+
*/
470+
public function testOverloadingAppendPropertyAppendsMetaTagToStack()
471+
{
472+
$this->view->doctype('XHTML1_RDFA');
473+
$this->_testOverloadAppend('property');
474+
}
475+
476+
/**
477+
* @group ZF-9743
478+
* @depends testPropertyIsSupportedWithRdfaDoctype
479+
*/
480+
public function testOverloadingPrependPropertyPrependsMetaTagToStack()
481+
{
482+
$this->view->doctype('XHTML1_RDFA');
483+
$this->_testOverloadPrepend('property');
484+
}
485+
486+
/**
487+
* @group ZF-9743
488+
* @depends testPropertyIsSupportedWithRdfaDoctype
489+
*/
490+
public function testOverloadingSetPropertyOverwritesMetaTagStack()
491+
{
492+
$this->view->doctype('XHTML1_RDFA');
493+
$this->_testOverloadSet('property');
494+
}
495+
441496
/**
442497
* @group ZF-11835
443498
*/

0 commit comments

Comments
 (0)