2
2
3
3
namespace Charcoal \Sitemap \Action ;
4
4
5
- use SimpleXMLElement ;
6
-
5
+ use Charcoal \ App \ Action \ AbstractAction ;
6
+ use Charcoal \ Translator \ TranslatorAwareTrait ;
7
7
use Pimple \Container ;
8
8
use Psr \Http \Message \RequestInterface ;
9
9
use Psr \Http \Message \ResponseInterface ;
10
-
11
- use Charcoal \App \Action \AbstractAction ;
12
- use Charcoal \Translator \TranslatorAwareTrait ;
10
+ use SimpleXMLElement ;
13
11
14
12
/**
15
13
* Class SitemapAction
@@ -34,7 +32,7 @@ public function setDependencies(Container $container)
34
32
parent ::setDependencies ($ container );
35
33
36
34
$ this ->sitemapBuilder = $ container ['charcoal/sitemap/builder ' ];
37
- $ this ->baseUrl = $ container ['base-url ' ];
35
+ $ this ->baseUrl = $ container ['base-url ' ];
38
36
}
39
37
40
38
/**
@@ -50,7 +48,7 @@ public function run(RequestInterface $request, ResponseInterface $response)
50
48
{
51
49
$ this ->setMode (self ::MODE_XML );
52
50
53
- $ sitemap = $ this ->sitemapBuilder ->build ('xml ' );
51
+ $ sitemap = $ this ->sitemapBuilder ->build ('xml ' );
54
52
$ this ->xml = $ this ->toXml ($ sitemap );
55
53
56
54
$ this ->setSuccess (true );
@@ -61,9 +59,10 @@ public function run(RequestInterface $request, ResponseInterface $response)
61
59
protected function toXml ($ map )
62
60
{
63
61
$ 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
+
67
66
68
67
$ xml = new SimpleXmlElement ($ str );
69
68
@@ -102,7 +101,7 @@ protected function toXml($map)
102
101
parse_url ($ altUrl , PHP_URL_HOST ) !== null ) {
103
102
continue ;
104
103
}
105
- $ xhtml = $ url ->addChild ('xhtml:link ' , null ,'xhtml ' );
104
+ $ xhtml = $ url ->addChild ('xhtml:link ' , null , 'xhtml ' );
106
105
$ xhtml ->addAttribute ('rel ' , 'alternate ' );
107
106
$ xhtml ->addAttribute ('hreflang ' , $ alt ['lang ' ]);
108
107
$ xhtml ->addAttribute ('href ' , $ altUrl );
0 commit comments