Skip to content

Commit

Permalink
add a new attribute "ExcludeSiteaccess", Code optimization
Browse files Browse the repository at this point in the history
  • Loading branch information
xinyuexrow committed Aug 15, 2016
1 parent d47b940 commit a691dcb
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 6 deletions.
38 changes: 34 additions & 4 deletions classes/xrowsitemaptools.php
Original file line number Diff line number Diff line change
Expand Up @@ -261,10 +261,15 @@ public static function addNode( xrowSitemap $sitemap, eZContentObjectTreeNode $n
$urlAlias = $url;

//Ticket #10114 - correction URLs
if (strpos($GLOBALS['eZCurrentAccess']['name'], 'hi_') !== false) {
$cur_access = explode('_', $GLOBALS['eZCurrentAccess']['name']);
$language_code = $cur_access[1];
$url = $language_code . '/' . $url;
if ( $ini->hasVariable( 'SitemapSettings', 'HostUriMatchMapItems' ) )
{
$host_uri = self::getUri($ini->variable( 'SitemapSettings', 'HostUriMatchMapItems' ));
} elseif ( $site_ini->hasVariable( 'SiteAccessSettings', 'HostUriMatchMapItems' ))
{
$host_uri = self::getUri($site_ini->variable( 'SiteAccessSettings', 'HostUriMatchMapItems' ));
}
if ( $host_uri !== '') {
$url = $host_uri . '/' . $url;
}

// $urlAlias is kept 'as is' to be able to generate these links
Expand Down Expand Up @@ -1679,6 +1684,31 @@ public static function checkAccess( eZContentObject $contentobject, eZUser $user
}
}
}

/*!
get URI for the current object
return the URI
*/
public static function getUri( $urimatchMapitems )
{
foreach ( $urimatchMapitems as $hostUriMap )
{
$hostUri = explode( ';', $hostUriMap );
if ( count( $hostUri ) < 3 )
{
$accessname = $hostUri[1];
$uri = '';
} else {
$accessname = $hostUri[2];
$uri = $hostUri[1];
}
if ( $accessname == $GLOBALS['eZCurrentAccess']['name'] )
{
break;
}
}
return $uri;
}
}

?>
12 changes: 12 additions & 0 deletions cronjobs/sitemap.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,18 @@
);
}

if ( $xrowsitemapINI->hasVariable( 'Settings', 'ExcludeSiteaccess' ) )
{
$exclude_array = $xrowsitemapINI->variable( 'Settings', 'ExcludeSiteaccess' );
foreach ($siteAccessArray as $key=>$siteaccess_item)
{
if (in_array($siteaccess_item, $exclude_array))
{
unset($siteAccessArray[$key]);
}
}
}

if ( $xrowsitemapINI->hasVariable( 'SitemapSettings', 'HostUriMatchMapItems' ) )
{
$hostArrays = $xrowsitemapINI->variable( 'SitemapSettings', 'HostUriMatchMapItems' );
Expand Down
5 changes: 3 additions & 2 deletions settings/xrowsitemap.ini.append.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@
# AvailableSiteAccessList[]
# AvailableSiteAccessList[]=ger
# AvailableSiteAccessList[]=eng
# Each entry consists of the hostname;uri;accessname[;start|end|part|strict]
#HostUriMatchMapItems[]
#HostUriMatchMapItems[]=www.xxxxxxxx.de;x_de
#HostUriMatchMapItems[]=www.xxxxxxxx.de;xx_de
#HostUriMatchMapItems[]=www.xxxxxxxx.de;de;x_de
#HostUriMatchMapItems[]=www.xxxxxxxx.de;;xx_de
MainNodeOnly=false
# include or exclude objects of classes listed in ClassFilterArray
Expand Down

0 comments on commit a691dcb

Please sign in to comment.