default_xml_menu.php
2.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
<?php
/**
* @package JMAP::SITEMAP::components::com_jmap
* @subpackage views
* @subpackage sitemap
* @subpackage tmpl
* @author Joomla! Extensions Store
* @copyright (C) 2015 - Joomla! Extensions Store
* @license GNU/GPLv2 http://www.gnu.org/licenses/gpl-2.0.html
*/
defined ( '_JEXEC' ) or die ( 'Restricted access' );
$priority = $this->sourceparams->get ( 'priority', '0.5' );
$changefreq = $this->sourceparams->get ( 'changefreq', 'daily' );
$includeExternalLinks = $this->sourceparams->get ( 'include_external_links', 1 );
$trailingSlash = '/';
$removeHomeSlash = $this->cparams->get('remove_home_slash', 0);
// Get menus object
$menusArray = $this->application->getMenu()->getMenu();
if (count ( $this->source->data )) {
foreach ( $this->source->data as $elm ) {
// Skip menu external links
if($elm->type == 'url' && !$includeExternalLinks) {
continue;
}
// Always skip external urls in XML sitemaps
if($elm->type == 'url' && strpos($elm->link, $this->liveSite) === false) {
continue;
}
// Avoid place link for separator and alias
if(in_array($elm->type, array('separator', 'alias', 'heading'))) {
continue;
}
$link = $elm->link;
if (isset ( $elm->id )) {
switch (@$elm->type) {
case 'separator' :
case 'alias' :
case 'heading' :
break;
case 'url' :
if (preg_match ( "#^/?index\.php\?#", $link )) {
if (strpos ( $link, 'Itemid=' ) === FALSE) {
if (strpos ( $link, '?' ) === FALSE) {
$link .= '?Itemid=' . $elm->id;
} else {
$link .= '&Itemid=' . $elm->id;
}
}
}
break;
default :
if (strpos ( $link, 'Itemid=' ) === FALSE) {
$link .= '&Itemid=' . $elm->id;
}
break;
}
}
if (strcasecmp ( substr ( $link, 0, 9 ), 'index.php' ) === 0) {
$link = JRoute::_ ( $link );
}
// SEF patch for better match uri con $link override
if ($elm->type == 'component' && array_key_exists($elm->id, $menusArray)) {
$link = 'index.php?Itemid=' . $elm->id;
$link = JRoute::_ ( $link );
}
if ($elm->home && $removeHomeSlash) { // HOME
$link = rtrim($link, '/');
$trailingSlash = '';
}
// Skip outputting
if(array_key_exists($link, $this->outputtedLinksBuffer)) {
continue;
}
// Else store to prevent duplication
$this->outputtedLinksBuffer[$link] = true;
$link = htmlspecialchars($link, null, 'UTF-8', false);
?>
<url>
<loc><?php echo preg_match('/^http/i', $link) ? $link : $this->liveSite . (strpos($link, '/') === 0 ? $link : $trailingSlash . $link) ; ?></loc>
<changefreq><?php echo $changefreq;?></changefreq>
<priority><?php echo $elm->priority ? $elm->priority : $priority;?></priority>
</url>
<?php
}
}