Skip to content

Commit

Permalink
Zend\Uri: Updated Sitemap view helper to use new URI API
Browse files Browse the repository at this point in the history
  • Loading branch information
weierophinney committed Jul 21, 2011
1 parent 4a25efa commit 3c971e8
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions library/Zend/View/Helper/Navigation/Sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,18 @@
*/
namespace Zend\View\Helper\Navigation;

use Zend\Navigation\AbstractPage,
use DOMDocument,
RecursiveIteratorIterator,
Zend\Navigation\AbstractPage,
Zend\Navigation\Container,
Zend\Uri,
Zend\View;

/**
* Helper for printing sitemaps
*
* @link http://www.sitemaps.org/protocol.php
*
* @uses DOMDocument
* @uses RecursiveIteratorIterator
* @uses \Zend\Uri\Url
* @uses \Zend\Uri\Exception
* @uses \Zend\Validator\Sitemap\Changefreq
* @uses \Zend\Validator\Sitemap\Lastmod
* @uses \Zend\Validator\Sitemap\Loc
* @uses \Zend\Validator\Sitemap\Priority
* @uses \Zend\View\Exception
* @uses \Zend\View\Helper\Navigation\AbstractHelper
* @category Zend
* @package Zend_View
* @subpackage Helper
Expand Down Expand Up @@ -224,21 +217,21 @@ public function getUseSchemaValidation()
*
* @param string $serverUrl server URL to set (only
* scheme and host)
* @throws \Zend\Uri\Exception if invalid server URL
* @return \Zend\View\Helper\Navigation\Sitemap fluent interface, returns
* @throws Uri\Exception if invalid server URL
* @return Sitemap fluent interface, returns
* self
*/
public function setServerUrl($serverUrl)
{
$uri = new \Zend\Uri\Url($serverUrl);
$uri = Uri\UriFactory::factory($serverUrl);
$uri->setFragment('');
$uri->setPath('');
$uri->setQuery('');

if ($uri->isValid()) {
$this->_serverUrl = $uri->generate();
$this->_serverUrl = $uri->toString();
} else {
$e = new \Zend\Uri\Exception(sprintf(
$e = new Uri\Exception\InvalidUriException(sprintf(
'Invalid server URL: "%s"',
$serverUrl));
$e->setView($this->view);
Expand Down Expand Up @@ -347,16 +340,16 @@ public function getDomSitemap(Container $container = null)
}

// create document
$dom = new \DOMDocument('1.0', 'UTF-8');
$dom = new DOMDocument('1.0', 'UTF-8');
$dom->formatOutput = $this->getFormatOutput();

// ...and urlset (root) element
$urlSet = $dom->createElementNS(self::SITEMAP_NS, 'urlset');
$dom->appendChild($urlSet);

// create iterator
$iterator = new \RecursiveIteratorIterator($container,
\RecursiveIteratorIterator::SELF_FIRST);
$iterator = new RecursiveIteratorIterator($container,
RecursiveIteratorIterator::SELF_FIRST);

$maxDepth = $this->getMaxDepth();
if (is_int($maxDepth)) {
Expand Down

0 comments on commit 3c971e8

Please sign in to comment.