diff --git a/composer.json b/composer.json index 1eccc69..7e06bdb 100644 --- a/composer.json +++ b/composer.json @@ -2,7 +2,7 @@ "name": "homm/hommsitemap", "description": "Craft 3 plugin that provides an easy way to provide and manage a XML sitemap for search engines like Google and Bing", "type": "craft-plugin", - "version": "1.0.9", + "version": "1.1.1", "keywords": [ "craft", "cms", @@ -16,9 +16,9 @@ "license": "MIT", "authors": [ { - "name": "Dolphiq", - "email": "info@dolphiq.nl", - "homepage": "https://dolphiq.nl/" + "name": "Homm", + "email": "mail@homm.ch", + "homepage": "https://homm.ch/" } ], "require": { @@ -39,16 +39,14 @@ "extra": { "name": "XML Sitemap Homm", "handle": "sitemap", - "schemaVersion": "1.0.2", - "developer": "Dolphiq", - "developerUrl": "https://dolphiq.nl/", + "schemaVersion": "1.1.1", + "developer": "Homm", + "developerUrl": "https://homm.ch/", "hasCpSettings": true, "hasCpSection": false, "components": { "sitemapService": "homm\\hommsitemap\\services\\SitemapService" }, - "documentationUrl": "https://github.com/Dolphiq/craft3-plugin-sitemap/blob/master/README.md", - "changelogUrl": "https://github.com/Dolphiq/craft3-plugin-sitemap/blob/master/CHANGELOG.md", "class": "homm\\hommsitemap\\Sitemap" } diff --git a/src/Sitemap.php b/src/Sitemap.php index 6d42eec..c697e98 100644 --- a/src/Sitemap.php +++ b/src/Sitemap.php @@ -4,7 +4,7 @@ * * Craft 3 plugin that provides an easy way to enable and manage a xml sitemap for search engines like Google * - * @link https://github.com/Dolphiq/craft3-plugin-sitemap + * @link https://github.com/HOMMinteractive/hommsitemap * @copyright Copyright (c) 2017 Johan Zandstra */ @@ -59,7 +59,7 @@ class Sitemap extends Plugin public $hasCpSettings = true; // table schema version - public $schemaVersion = '1.0.2'; + public $schemaVersion = '1.1.1'; /** * Return the settings response (if some one clicks on the settings/plugin icon) diff --git a/src/assetbundles/indexcpsection/IndexCPSectionAsset.php b/src/assetbundles/indexcpsection/IndexCPSectionAsset.php index 89fb026..ec04f0a 100644 --- a/src/assetbundles/indexcpsection/IndexCPSectionAsset.php +++ b/src/assetbundles/indexcpsection/IndexCPSectionAsset.php @@ -4,7 +4,7 @@ * * Craft 3 plugin that provides an easy way to enable and manage a xml sitemap for search engines like Google * - * @link https://github.com/Dolphiq/craft3-plugin-sitemap + * @link https://github.com/HOMMinteractive/hommsitemap * @copyright Copyright (c) 2017 Johan Zandstra */ diff --git a/src/assetbundles/sitemap/SitemapAsset.php b/src/assetbundles/sitemap/SitemapAsset.php index 6f11609..e48e6c6 100644 --- a/src/assetbundles/sitemap/SitemapAsset.php +++ b/src/assetbundles/sitemap/SitemapAsset.php @@ -4,7 +4,7 @@ * * Craft 3 plugin that provides an easy way to enable and manage a xml sitemap for search engines like Google * - * @link https://github.com/Dolphiq/craft3-plugin-sitemap + * @link https://github.com/HOMMinteractive/hommsitemap * @copyright Copyright (c) 2017 Johan Zandstra */ diff --git a/src/config.php b/src/config.php index 2734b84..c737417 100644 --- a/src/config.php +++ b/src/config.php @@ -4,7 +4,7 @@ * * Craft 3 plugin that provides an easy way to enable and manage a xml sitemap for search engines like Google * - * @link https://github.com/Dolphiq/craft3-plugin-sitemap + * @link https://github.com/HOMMinteractive/hommsitemap * @copyright Copyright (c) 2017 Johan Zandstra */ diff --git a/src/controllers/SettingsController.php b/src/controllers/SettingsController.php index 71bc0b5..684e15a 100644 --- a/src/controllers/SettingsController.php +++ b/src/controllers/SettingsController.php @@ -4,7 +4,7 @@ * * Craft 3 plugin that provides an easy way to enable and manage a xml sitemap for search engines like Google * - * @link https://github.com/Dolphiq/craft3-plugin-sitemap + * @link https://github.com/HOMMinteractive/hommsitemap * @copyright Copyright (c) 2017 Johan Zandstra */ diff --git a/src/controllers/SitemapController.php b/src/controllers/SitemapController.php index fadb28f..e0b1694 100644 --- a/src/controllers/SitemapController.php +++ b/src/controllers/SitemapController.php @@ -4,7 +4,7 @@ * * Craft 3 plugin that provides an easy way to enable and manage a xml sitemap for search engines like Google * - * @link https://github.com/Dolphiq/craft3-plugin-sitemap + * @link https://github.com/HOMMinteractive/hommsitemap * @copyright Copyright (c) 2017 Johan Zandstra */ @@ -47,8 +47,7 @@ class SitemapController extends Controller private $_sourceRouteParams = []; protected $allowAnonymous = ['index']; // Public Methods -// ========================================================================= - + // ========================================================================= /** * @inheritdoc @@ -71,7 +70,6 @@ private function getUrl($uri, $siteId) */ public function actionIndex() { - try { // try to register the searchengine visit $CrawlerDetect = new CrawlerDetect; @@ -84,7 +82,6 @@ public function actionIndex() $visit->save(); } } catch (\Exception $err) { - } Craft::$app->response->format = \yii\web\Response::FORMAT_RAW; $headers = Craft::$app->response->headers; @@ -102,38 +99,40 @@ public function actionIndex() $dom->appendChild($urlset); foreach ($this->_createEntrySectionQuery()->all() as $item) { - $entries = \craft\elements\Entry::find() ->id($item['elementId']) ->one(); - if ($entries) { $entry = $entries->getAttributes(['seoIndexierung']); + $weiterleitung = $entries->getAttributes(['navigationAlsWeiterleitung']); + if ($entry['seoIndexierung']) { - $loc = $this->getUrl($item['uri'], $item['siteId']); - if ($loc === null) continue; - - $url = $dom->createElement('url'); - $urlset->appendChild($url); - - $url->appendChild($dom->createElement('loc', $loc)); - $url->appendChild($dom->createElement('priority', $item['priority'])); - $url->appendChild($dom->createElement('changefreq', $item['changefreq'])); - $dateUpdated = strtotime($item['dateUpdated']); - $url->appendChild($dom->createElement('lastmod', date('Y-m-d\TH:i:sP', $dateUpdated))); - if ($item['alternateLinkCount'] > 1) { - $alternateLinks = $this->_createAlternateSectionQuery($item['elementId'])->all(); - if (count($alternateLinks) > 0) { - foreach ($alternateLinks as $alternateItem) { - $alternateLoc = $this->getUrl($alternateItem['uri'], $alternateItem['siteId']); - if ($alternateLoc === null) continue; - - $alternateLink = $dom->createElementNS('http://www.w3.org/1999/xhtml', 'xhtml:link'); - $alternateLink->setAttribute('rel', 'alternate'); - $alternateLink->setAttribute('hreflang', strtolower($alternateItem['siteLanguate'])); - $alternateLink->setAttribute('href', $alternateLoc); - $url->appendChild($alternateLink); + if ($weiterleitung['navigationAlsWeiterleitung'] == '') { + $loc = $this->getUrl($item['uri'], $item['siteId']); + if ($loc === null) continue; + + $url = $dom->createElement('url'); + $urlset->appendChild($url); + + $url->appendChild($dom->createElement('loc', $loc)); + $url->appendChild($dom->createElement('priority', $item['priority'])); + $url->appendChild($dom->createElement('changefreq', $item['changefreq'])); + $dateUpdated = strtotime($item['dateUpdated']); + $url->appendChild($dom->createElement('lastmod', date('Y-m-d\TH:i:sP', $dateUpdated))); + if ($item['alternateLinkCount'] > 1) { + $alternateLinks = $this->_createAlternateSectionQuery($item['elementId'])->all(); + if (count($alternateLinks) > 0) { + foreach ($alternateLinks as $alternateItem) { + $alternateLoc = $this->getUrl($alternateItem['uri'], $alternateItem['siteId']); + if ($alternateLoc === null) continue; + + $alternateLink = $dom->createElementNS('http://www.w3.org/1999/xhtml', 'xhtml:link'); + $alternateLink->setAttribute('rel', 'alternate'); + $alternateLink->setAttribute('hreflang', strtolower($alternateItem['siteLanguate'])); + $alternateLink->setAttribute('href', $alternateLoc); + $url->appendChild($alternateLink); + } } } } @@ -152,15 +151,12 @@ public function actionIndex() $url->appendChild($dom->createElement('changefreq', $item['changefreq'])); $dateUpdated = strtotime($item['dateUpdated']); $url->appendChild($dom->createElement('lastmod', date('Y-m-d\TH:i:sP', $dateUpdated))); - - } return $dom->saveXML(); } private function _createEntrySectionQuery(): Query { - $subQuery = (new Query()) ->select('COUNT(DISTINCT other_elements_sites.id)') ->from('{{%elements_sites}} other_elements_sites') @@ -176,7 +172,6 @@ private function _createEntrySectionQuery(): Query 'elements.id elementId', 'alternateLinkCount' => $subQuery, - ]) ->from(['{{%sections}} sections']) ->innerJoin('{{%homm_sitemap_entries}} sitemap_entries', '[[sections.id]] = [[sitemap_entries.linkId]] AND [[sitemap_entries.type]] = "section"') diff --git a/src/migrations/Install.php b/src/migrations/Install.php index 6fecf44..5a5d550 100644 --- a/src/migrations/Install.php +++ b/src/migrations/Install.php @@ -4,7 +4,7 @@ * * Craft 3 plugin that provides an easy way to enable and manage a xml sitemap for search engines like Google * - * @link https://github.com/Dolphiq/craft3-plugin-sitemap + * @link https://github.com/HOMMinteractive/hommsitemap * @copyright Copyright (c) 2017 Johan Zandstra */ diff --git a/src/models/Settings.php b/src/models/Settings.php index 3ed406d..e6e6ab4 100644 --- a/src/models/Settings.php +++ b/src/models/Settings.php @@ -4,7 +4,7 @@ * * Craft 3 plugin that provides an easy way to enable and manage a xml sitemap for search engines like Google * - * @link https://github.com/Dolphiq/craft3-plugin-sitemap + * @link https://github.com/HOMMinteractive/hommsitemap * @copyright Copyright (c) 2017 Johan Zandstra */ diff --git a/src/records/SitemapCrawlerVisit.php b/src/records/SitemapCrawlerVisit.php index 54588d7..0471e9b 100644 --- a/src/records/SitemapCrawlerVisit.php +++ b/src/records/SitemapCrawlerVisit.php @@ -4,7 +4,7 @@ * * Craft 3 plugin that provides an easy way to enable and manage a xml sitemap for search engines like Google * - * @link https://github.com/Dolphiq/craft3-plugin-sitemap + * @link https://github.com/HOMMinteractive/hommsitemap * @copyright Copyright (c) 2017 Johan Zandstra */ diff --git a/src/records/SitemapEntry.php b/src/records/SitemapEntry.php index cb727cd..bb0d2c7 100644 --- a/src/records/SitemapEntry.php +++ b/src/records/SitemapEntry.php @@ -4,7 +4,7 @@ * * Craft 3 plugin that provides an easy way to enable and manage a xml sitemap for search engines like Google * - * @link https://github.com/Dolphiq/craft3-plugin-sitemap + * @link https://github.com/HOMMinteractive/hommsitemap * @copyright Copyright (c) 2017 Johan Zandstra */ diff --git a/src/services/SitemapService.php b/src/services/SitemapService.php index 6334b04..3c72d20 100644 --- a/src/services/SitemapService.php +++ b/src/services/SitemapService.php @@ -4,7 +4,7 @@ * * Craft 3 plugin that provides an easy way to enable and manage a xml sitemap for search engines like Google * - * @link https://github.com/Dolphiq/craft3-plugin-sitemap + * @link https://github.com/HOMMinteractive/hommsitemap * @copyright Copyright (c) 2017 Johan Zandstra */ diff --git a/src/templates/settings.twig b/src/templates/settings.twig index 98faa9d..7b41649 100644 --- a/src/templates/settings.twig +++ b/src/templates/settings.twig @@ -6,7 +6,7 @@ * * @author Johan Zandstra * @copyright Copyright (c) 2017 Johan Zandstra - * @link https://github.com/Dolphiq/craft3-plugin-sitemap + * @link https://github.com/HOMMinteractive/hommsitemap * @package Sitemap * @since 1.0.0 */ diff --git a/src/translations/en/sitemap.php b/src/translations/en/sitemap.php index 4594826..fd60d17 100644 --- a/src/translations/en/sitemap.php +++ b/src/translations/en/sitemap.php @@ -4,7 +4,7 @@ * * Craft 3 plugin that provides an easy way to enable and manage a xml sitemap for search engines like Google * - * @link https://github.com/Dolphiq/craft3-plugin-sitemap + * @link https://github.com/HOMMinteractive/hommsitemap * @copyright Copyright (c) 2017 Johan Zandstra */