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

Commit

Permalink
Merge branch 'feature/7263'
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Mar 25, 2015
209 parents 1cb119f + cb2b29e + 817293e + a95715f + 59a52e7 + 1f543f2 + 8ea6767 + 8793888 + 163d706 + a197876 + dc04d82 + e296dd4 + 8cd607e + 758e5c3 + 59f3ba8 + 63d873e + a320b87 + 911d7bc + 5b99e49 + 916ccaf + 363002c + de6a155 + 81d4652 + 8677f66 + bea2340 + 53107b1 + e575de9 + c8a932b + d08629f + a04474f + 3fef53d + 1f4b9ed + d263f1c + c790aed + 412585a + b5e6b02 + 9ac81f3 + 9f28eab + 2e7e2e2 + 7c64770 + b82fa59 + 4190868 + 3a6b7ad + 8e745f6 + bab7086 + c5a5d19 + b468bc1 + d79794c + 508b344 + d16deed + f38e96a + c4a3687 + 54465f7 + 4ad15e4 + 9aa47da + 619d24d + ddfa8f2 + 8e7172b + e5fc69f + 284a721 + 6d3db4c + b99e8c3 + a52dcef + 1d21066 + cccc24c + 81bd699 + dfb38ed + b796f3d + d49dbc2 + 547433c + 0c9ce04 + a76e26a + 2914396 + 7ca3746 + f1b292d + 406112f + 5a9edd3 + f65c9f6 + c54156c + 5e55e82 + 352e42b + fa459f5 + 3eff137 + 3648ab6 + 4096125 + 0037391 + 9bdfcd9 + 6cd1498 + ecac99d + 199ed75 + b8507f7 + ef400bd + decb6ae + 860b39d + 243eca6 + d56af72 + 1aaf7f9 + 26b27a9 + 40cd50e + 986898b + d2780b7 + 49abb1d + cb5a738 + 21d3bef + 4748875 + 3331086 + bfed36c + b56e9b8 + 765b017 + b2cddce + 1c63803 + dd490e0 + c0425c2 + 128ed7f + 4d88940 + 94b3f1e + 9a0d8cf + 12135ad + 1169a58 + 6cdb5dc + 15950e5 + 7e68fb2 + 4bda4a9 + 537893f + 4cf10f8 + dd5b294 + 3ac5190 + 63d8503 + de5ff9e + f8868a0 + e3f8a27 + 634cf99 + c2cd236 + 189672f + d50054c + 8fb183a + 81a21d6 + ba78039 + 2cc9607 + bbd31f7 + aff5dfd + 3daad46 + a2bd1ba + cddc550 + eadb29a + 339c074 + 543ff20 + 732e048 + 8ec7eaf + 25fde7d + 5215c37 + a31404d + 1328e20 + 33a507b + 012928d + 379d601 + b7d4bbd + c1c633c + 6a72de0 + 7968e2e + 51d3d2a + 7e58137 + abedf39 + 896ef54 + cf89f92 + 0df0d18 + 3d7cc47 + 8abd6e8 + e20a954 + 2f039d3 + 88c06cc + 3e03422 + 096a05e + 6c7650a + a4c7b54 + ef5460e + 898d44f + c554ea2 + ffcf7bc + 2adc6bf + 4179b4d + 5907ce0 + fc664b1 + 2ee9d9a + 7fb5cbc + acda3d1 + 6db0d22 + 2bbd38f + 3144a5b + 7efb048 + 3d18a84 + 93a97aa + f98796f + 853fff2 + 149db66 + 2416664 + ed3d22e + 08c425e + 9675758 + 2a8daeb + 7e876e2 + ef2ccfa + 978f64c + 262c40f + 18ac29e + ec7ea9f + 1d789f3 + 95dfa24 + 64dbac3 commit 93898fd
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 22 deletions.
11 changes: 7 additions & 4 deletions src/Reader/Entry/AbstractEntry.php
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ public function getEncoding()
*/
public function saveXml()
{
$dom = new DOMDocument('1.0', $this->getEncoding());
$entry = $dom->importNode($this->getElement(), true);
$dom = new DOMDocument('1.0', $this->getEncoding());
$deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true;
$entry = $dom->importNode($this->getElement(), $deep);
$dom->appendChild($entry);
return $dom->saveXml();
}
Expand Down Expand Up @@ -202,8 +203,10 @@ public function __call($method, $args)
return call_user_func_array(array($extension, $method), $args);
}
}
throw new Exception\RuntimeException('Method: ' . $method
. ' does not exist and could not be located on a registered Extension');
throw new Exception\RuntimeException(sprintf(
'Method: %s does not exist and could not be located on a registered Extension',
$method
));
}

/**
Expand Down
16 changes: 10 additions & 6 deletions src/Reader/Extension/Atom/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -103,20 +103,21 @@ public function getContent()
case 'html':
case 'text/html':
$content = $el->nodeValue;
break;
break;
case 'xhtml':
$this->getXpath()->registerNamespace('xhtml', 'http://www.w3.org/1999/xhtml');
$xhtml = $this->getXpath()->query(
$this->getXpathPrefix() . '/atom:content/xhtml:div'
)->item(0);
$d = new DOMDocument('1.0', $this->getEncoding());
$xhtmls = $d->importNode($xhtml, true);
$deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true;
$xhtmls = $d->importNode($xhtml, $deep);
$d->appendChild($xhtmls);
$content = $this->collectXhtml(
$d->saveXML(),
$d->lookupPrefix('http://www.w3.org/1999/xhtml')
);
break;
break;
}
}

Expand Down Expand Up @@ -296,9 +297,12 @@ public function getBaseUrl()
return $this->data['baseUrl'];
}

$baseUrl = $this->getXpath()->evaluate('string('
. $this->getXpathPrefix() . '/@xml:base[1]'
. ')');
$baseUrl = $this->getXpath()->evaluate(
'string('
. $this->getXpathPrefix()
. '/@xml:base[1]'
. ')'
);

if (!$baseUrl) {
$baseUrl = $this->getXpath()->evaluate('string(//@xml:base[1])');
Expand Down
22 changes: 16 additions & 6 deletions src/Writer/Renderer/Entry/Atom.php
Original file line number Diff line number Diff line change
Expand Up @@ -265,12 +265,14 @@ protected function _setId(DOMDocument $dom, DOMElement $root)

if (!$this->getDataContainer()->getId()) {
$this->getDataContainer()->setId(
$this->getDataContainer()->getLink());
$this->getDataContainer()->getLink()
);
}
if (!Uri::factory($this->getDataContainer()->getId())->isValid()
&& !preg_match(
"#^urn:[a-zA-Z0-9][a-zA-Z0-9\-]{1,31}:([a-zA-Z0-9\(\)\+\,\.\:\=\@\;\$\_\!\*\-]|%[0-9a-fA-F]{2})*#",
$this->getDataContainer()->getId())
$this->getDataContainer()->getId()
)
&& !$this->_validateTagUri($this->getDataContainer()->getId())
) {
throw new Writer\Exception\InvalidArgumentException('Atom 1.0 IDs must be a valid URI/IRI');
Expand All @@ -289,7 +291,11 @@ protected function _setId(DOMDocument $dom, DOMElement $root)
*/
protected function _validateTagUri($id)
{
if (preg_match('/^tag:(?P<name>.*),(?P<date>\d{4}-?\d{0,2}-?\d{0,2}):(?P<specific>.*)(.*:)*$/', $id, $matches)) {
if (preg_match(
'/^tag:(?P<name>.*),(?P<date>\d{4}-?\d{0,2}-?\d{0,2}):(?P<specific>.*)(.*:)*$/',
$id,
$matches
)) {
$dvalid = false;
$date = $matches['date'];
$d6 = strtotime($date);
Expand Down Expand Up @@ -341,7 +347,8 @@ protected function _setContent(DOMDocument $dom, DOMElement $root)
$element = $dom->createElement('content');
$element->setAttribute('type', 'xhtml');
$xhtmlElement = $this->_loadXhtml($content);
$xhtml = $dom->importNode($xhtmlElement, true);
$deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true;
$xhtml = $dom->importNode($xhtmlElement, $deep);
$element->appendChild($xhtml);
$root->appendChild($element);
}
Expand Down Expand Up @@ -369,8 +376,11 @@ protected function _loadXhtml($content)
"/(<[\/]?)([a-zA-Z]+)/"
), '$1xhtml:$2', $xhtml);
$dom = new DOMDocument('1.0', $this->getEncoding());
$dom->loadXML('<xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">'
. $xhtml . '</xhtml:div>');
$dom->loadXML(
'<xhtml:div xmlns:xhtml="http://www.w3.org/1999/xhtml">'
. $xhtml
. '</xhtml:div>'
);
return $dom->documentElement;
}

Expand Down
9 changes: 6 additions & 3 deletions src/Writer/Renderer/Feed/Atom.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public function render()
$this->dom = new DOMDocument('1.0', $this->container->getEncoding());
$this->dom->formatOutput = true;
$root = $this->dom->createElementNS(
Writer\Writer::NAMESPACE_ATOM_10, 'feed'
Writer\Writer::NAMESPACE_ATOM_10,
'feed'
);
$this->setRootElement($root);
$this->dom->appendChild($root);
Expand Down Expand Up @@ -76,7 +77,8 @@ public function render()
} else {
if (!$this->dom->documentElement->hasAttribute('xmlns:at')) {
$this->dom->documentElement->setAttribute(
'xmlns:at', 'http://purl.org/atompub/tombstones/1.0'
'xmlns:at',
'http://purl.org/atompub/tombstones/1.0'
);
}
$renderer = new Renderer\Entry\AtomDeleted($entry);
Expand All @@ -88,7 +90,8 @@ public function render()
$renderer->setRootElement($this->dom->documentElement);
$renderer->render();
$element = $renderer->getElement();
$imported = $this->dom->importNode($element, true);
$deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true;
$imported = $this->dom->importNode($element, $deep);
$root->appendChild($imported);
}
return $this;
Expand Down
10 changes: 7 additions & 3 deletions src/Writer/Renderer/Feed/Rss.php
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,8 @@ public function render()
$renderer->setRootElement($this->dom->documentElement);
$renderer->render();
$element = $renderer->getElement();
$imported = $this->dom->importNode($element, true);
$deep = version_compare(PHP_VERSION, '7', 'ge') ? 1 : true;
$imported = $this->dom->importNode($element, $deep);
$channel->appendChild($imported);
}
return $this;
Expand Down Expand Up @@ -195,8 +196,11 @@ protected function _setDateModified(DOMDocument $dom, DOMElement $root)
protected function _setGenerator(DOMDocument $dom, DOMElement $root)
{
if (!$this->getDataContainer()->getGenerator()) {
$this->getDataContainer()->setGenerator('Zend_Feed_Writer',
Version::VERSION, 'http://framework.zend.com');
$this->getDataContainer()->setGenerator(
'Zend_Feed_Writer',
Version::VERSION,
'http://framework.zend.com'
);
}

$gdata = $this->getDataContainer()->getGenerator();
Expand Down

0 comments on commit 93898fd

Please sign in to comment.