Skip to content

Commit b6973fb

Browse files
committed
xhtml definition in XML.
1 parent e857e26 commit b6973fb

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

src/Charcoal/Sitemap/Action/SitemapAction.php

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,12 @@
22

33
namespace Charcoal\Sitemap\Action;
44

5-
use SimpleXMLElement;
6-
5+
use Charcoal\App\Action\AbstractAction;
6+
use Charcoal\Translator\TranslatorAwareTrait;
77
use Pimple\Container;
88
use Psr\Http\Message\RequestInterface;
99
use Psr\Http\Message\ResponseInterface;
10-
11-
use Charcoal\App\Action\AbstractAction;
12-
use Charcoal\Translator\TranslatorAwareTrait;
10+
use SimpleXMLElement;
1311

1412
/**
1513
* Class SitemapAction
@@ -34,7 +32,7 @@ public function setDependencies(Container $container)
3432
parent::setDependencies($container);
3533

3634
$this->sitemapBuilder = $container['charcoal/sitemap/builder'];
37-
$this->baseUrl = $container['base-url'];
35+
$this->baseUrl = $container['base-url'];
3836
}
3937

4038
/**
@@ -50,7 +48,7 @@ public function run(RequestInterface $request, ResponseInterface $response)
5048
{
5149
$this->setMode(self::MODE_XML);
5250

53-
$sitemap = $this->sitemapBuilder->build('xml');
51+
$sitemap = $this->sitemapBuilder->build('xml');
5452
$this->xml = $this->toXml($sitemap);
5553

5654
$this->setSuccess(true);
@@ -61,9 +59,10 @@ public function run(RequestInterface $request, ResponseInterface $response)
6159
protected function toXml($map)
6260
{
6361
$str = '<?xml version="1.0" encoding="UTF-8"?><urlset '
64-
.'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" '
65-
.'xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" '
66-
.'xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"/>';
62+
. 'xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" '
63+
. 'xmlns:xhtml="http://www.w3.org/1999/xhtml" '
64+
. '/>';
65+
6766

6867
$xml = new SimpleXmlElement($str);
6968

@@ -102,7 +101,7 @@ protected function toXml($map)
102101
parse_url($altUrl, PHP_URL_HOST) !== null) {
103102
continue;
104103
}
105-
$xhtml = $url->addChild('xhtml:link', null,'xhtml');
104+
$xhtml = $url->addChild('xhtml:link', null, 'xhtml');
106105
$xhtml->addAttribute('rel', 'alternate');
107106
$xhtml->addAttribute('hreflang', $alt['lang']);
108107
$xhtml->addAttribute('href', $altUrl);

0 commit comments

Comments
 (0)