default_hreflang_user.php
2.69 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
<?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' );
// Check if the third party user data source extension is supported
$extension = $this->source->chunks->option;
if(!property_exists($this->supportedNativeExtensions, $extension)) {
return;
}
$tablename = $this->source->chunks->table_maintable;
$explodedExtensionName = explode('_', $extension);
$classRoutePrefix = ucfirst(array_pop($explodedExtensionName));
$classRouteHelper = $classRoutePrefix . 'HelperRoute';
$methodRouteHelper = 'get' . $this->supportedNativeExtensions->{$extension} . 'Route';
if (count ( $this->source->data ) != 0 && file_exists(JPATH_BASE . '/components/' . $extension . '/helpers/route.php')) {
require_once (JPATH_BASE . '/components/' . $extension . '/helpers/route.php');
foreach ( $this->source->data as $elm ) {
// Element category empty da right join
if(!$elm->id) {
continue;
}
// Get language associations for this content, if not found skip and go on
$associatedContents = JMapHelpersAssociations::getContentAssociations($extension, $tablename, $extension . '.item', $elm->id);
if(count($associatedContents) <= 1) {
continue;
}
$seolink = JRoute::_ ( $classRouteHelper::$methodRouteHelper ( $elm->id, $elm->catid, $elm->language ) );
// Skip outputting
if(array_key_exists($seolink, $this->outputtedLinksBuffer)) {
continue;
}
// Else store to prevent duplication
$this->outputtedLinksBuffer[$seolink] = true;
?>
<url>
<loc><?php echo $this->liveSite . $seolink; ?></loc>
<?php foreach ($associatedContents as $alternate):?>
<xhtml:link rel="alternate" hreflang="<?php echo $alternate->sef?>" href="<?php echo $this->liveSite . JRoute::_ ( $classRouteHelper::$methodRouteHelper ( $alternate->id, $alternate->catid, $alternate->language ) );?>" />
<?php endforeach;?>
</url>
<?php
foreach ($associatedContents as $repetition) {
// Skip the main default url already added
if((int)$repetition->id == $elm->id) {
continue;
}
?>
<url>
<loc><?php echo $this->liveSite . JRoute::_ ( $classRouteHelper::$methodRouteHelper ( $repetition->id, $repetition->catid, $repetition->language ) ); ?></loc>
<?php foreach ($associatedContents as $subalternate):?>
<xhtml:link rel="alternate" hreflang="<?php echo $subalternate->sef?>" href="<?php echo $this->liveSite . JRoute::_ ( $classRouteHelper::$methodRouteHelper ( $subalternate->id, $subalternate->catid, $subalternate->language ) );?>" />
<?php endforeach;?>
</url>
<?php
}
}
}