' . "\n"; echo '' . "\n"; foreach ($urls as $url) { $url = fix_issues($url); if (!!$url) { echo "\t" . '' . "\n"; echo "\t\t" . '' . $url . '' . "\n"; echo "\t" . '' . "\n"; } } echo ''; function fix_issues($url) { // news / event archive link if (strpos($url, '{date:year()}') !== false) { $url = str_replace('{date:year()}', date('Y'), $url); } // solution advisor link if (strpos($url, '?bl={$url}') !== false) { $url = str_replace('?bl={$url}', '', $url); } // webshop link if (strpos($url, '&___store') !== false) { $url = str_replace('&___store', '&___store', $url); } // lib links if (strpos($url, '.com/lib') !== false) { $url = str_replace('.com/lib', '.com/_ttt/lib', $url); } // remove partner portal link if (strpos($url, 'api/refer/pp') !== false) { return false; } // if the host doesn't contain the host form the sitemap (main site/sub domain), exclude url (which wouldn't be allowed in a xml sitemap) if (strpos( $url, parse_url(get_domain_name(),PHP_URL_HOST) ) === false) { return false; } return $url; } // ███╗ ██╗ ████╗ ██╗ ██╗██╗ ████╗ ████╗ ██████╗██╗ ████╗ ███╗ ██╗ // ████╗ ██║██╔═██╗██║ ██║██║██╔══╝ ██╔═██╗╚═██╔═╝██║██╔═██╗████╗ ██║ // ██╔██╗██║██████║██║ ██║██║██║███╗██████║ ██║ ██║██║ ██║██╔██╗██║ // ██║╚████║██╔═██║╚██╗██╔╝██║██║ ██║██╔═██║ ██║ ██║██║ ██║██║╚████║ // ██║ ╚███║██║ ██║ ╚███╔╝ ██║╚████╔╝██║ ██║ ██║ ██║╚████╔╝██║ ╚███║ // ╚═╝ ╚══╝╚═╝ ╚═╝ ╚══╝ ╚═╝ ╚═══╝ ╚═╝ ╚═╝ ╚═╝ ╚═╝ ╚═══╝ ╚═╝ ╚══╝ function sitemap_get_nav_urls($navId) { global $cocoon; $nav = new DOMDocument(); $nav->load($cocoon->path_src2 . '/app/config/navigations.xml'); $xpath = new DOMXPath($nav); $menuitems = $xpath->query('/params/navigations/navigation[@id="' . $navId . '"]/menuitem[not(@showInXMLSitemap) or @showInXMLSitemap!="false"]'); return sitemap_get_urls_from_menuitems($menuitems); } function sitemap_get_urls_from_menuitems($menuitems, $recursive = true) { global $cocoon; $urls = array(); if ($menuitems instanceof DOMNodeList) { foreach ($menuitems as $menuitem) { $urls[] = sitemap_get_urls_from_menuitem($menuitem); // remove child nodes if menuitem is not available if ($cocoon->isNodeAvailable($menuitem) === false) { $childNodes = $menuitem->childNodes; for($i = $childNodes->length; $i--;) { $childNode = $childNodes->item($i); $menuitem->removeChild($childNode); } } if ($menuitem->getElementsByTagName('menuitem')->length > 0 && $recursive) { $urls = array_merge($urls, sitemap_get_urls_from_menuitems($menuitem->getElementsByTagName('menuitem'))); } } } elseif ($menuitems instanceof DOMElement) { $urls[] = sitemap_get_urls_from_menuitem($menuitem); // remove child nodes if menuitem is not available if ($cocoon->isNodeAvailable($menuitem) === false) { $childNodes = $menuitem->childNodes; for($i = $childNodes->length; $i--;) { $childNode = $childNodes->item($i); $menuitem->removeChild($childNode); } } if ($menuitem->getElementsByTagName('menuitem')->length > 0 && $recursive) { $urls = array_merge($urls, sitemap_get_urls_from_menuitems($menuitem->getElementsByTagName('menuitem'))); } } return array_unique($urls); } function sitemap_get_urls_from_menuitem(DOMElement $menuitem) { global $cocoon; if ($cocoon->isNodeAvailable($menuitem)) { // menuitem allowed to appear in the XML sitemap? $showInXMLSitemap = ($menuitem->hasAttribute('showInXMLSitemap') && $menuitem->getAttribute('showInXMLSitemap') === 'false') ? false : true; if ($menuitem->hasAttribute('url') && $showInXMLSitemap !== false) { if (starts_with($menuitem->getAttribute('url'), 'http')) { $url = ''; } elseif (starts_with($menuitem->getAttribute('url'), '//')) { $url = 'https:'; } elseif (starts_with($menuitem->getAttribute('url'), '/refer/')) { $url = get_domain_name(); } else { $url = get_domain_name() . '/' . $cocoon->locale . '/webfleet'; } return $url . $cocoon->finalize($menuitem->getAttribute('url')); } } } // ████╗ ████╗ █████╗█████╗█████╗ // ██╔══╝██╔═██╗██╔══╝██╔══╝██╔══╝ // ██║ ██████║█████╗████╗ █████╗ // ██║ ██╔═██║╚══██║██╔═╝ ╚══██║ // ╚████╗██║ ██║█████║█████╗█████║ // ╚═══╝╚═╝ ╚═╝╚════╝╚════╝╚════╝ function sitemap_get_case_urls() { global $cocoon; $all_cases = new DOMDocument(); $all_cases->load( $cocoon->path_content . '/_jbuilt_/assets/cases/' . $cocoon->locale . '.xml' ); $xpath = new DOMXPath($all_cases); $cases = $xpath->query( '/assets/case' ); $case_urls = array(); foreach ($cases as $case) { if( $cocoon->isNodeAvailable($case) ) { $case_urls[] = get_domain_name() .'/'. $cocoon->locale .'/webfleet/resources/case/' . $case->getAttribute('id') .'/'; } } return $case_urls; } // █████╗ ████╗ ██╗ ██╗███╗ ██╗██╗ ████╗ ████╗ █████╗ █████╗ // ██╔═██╗██╔═██╗██║ ██║████╗ ██║██║ ██╔═██╗██╔═██╗██╔═██╗██╔══╝ // ██║ ██║██║ ██║██║ █╗ ██║██╔██╗██║██║ ██║ ██║██████║██║ ██║█████╗ // ██║ ██║██║ ██║██║███╗██║██║╚████║██║ ██║ ██║██╔═██║██║ ██║╚══██║ // █████╔╝╚████╔╝╚███╔███╔╝██║ ╚███║█████╗╚████╔╝██║ ██║█████╔╝█████║ // ╚════╝ ╚═══╝ ╚══╝╚══╝ ╚═╝ ╚══╝╚════╝ ╚═══╝ ╚═╝ ╚═╝╚════╝ ╚════╝ function sitemap_get_download_urls() { global $cocoon; $all_downloads = new DOMDocument(); $all_downloads->load($cocoon->path_content . '/_jbuilt_/assets/downloads/' . $cocoon->locale . '.xml'); $xpath = new DOMXPath($all_downloads); $downloads = $xpath->query('/assets/download/content/landingpages/landingpage'); $downloads_urls = array(); foreach ($downloads as $download) { if ($cocoon->isNodeAvailable($download)) { $downloadUrl = $download->getAttribute('url'); if (!empty($downloadUrl)) { $url = get_domain_name() . '/' . $cocoon->locale . $downloadUrl; $downloads_urls[] = str_replace('&', '%26', $cocoon->finalize($url)); } } } return $downloads_urls; } // ██╗ ██╗██╗█████╗ █████╗ ████╗ █████╗ // ██║ ██║██║██╔═██╗██╔══╝██╔═██╗██╔══╝ // ██║ ██║██║██║ ██║████╗ ██║ ██║█████╗ // ╚██╗██╔╝██║██║ ██║██╔═╝ ██║ ██║╚══██║ // ╚███╔╝ ██║█████╔╝█████╗╚████╔╝█████║ // ╚══╝ ╚═╝╚════╝ ╚════╝ ╚═══╝ ╚════╝ function sitemap_get_video_urls() { global $cocoon; $all_videos = new DOMDocument(); $all_videos->load( $cocoon->path_content . '/_jbuilt_/assets/videos/' . $cocoon->locale . '.xml' ); $xpath = new DOMXPath($all_videos); $videos = $xpath->query('/assets/video/content/landingpages/landingpage'); $videos_urls = array(); foreach ($videos as $video) { if ($cocoon->isNodeAvailable($video)) { $videoUrl = $video->getAttribute('url'); if (!empty($videoUrl)) { $url = get_domain_name() . '/' . $cocoon->locale . $videoUrl; $videos_urls[] = str_replace('&', '%26', $cocoon->finalize($url)); } } } return $videos_urls; } // █████╗██╗ ██╗█████╗███╗ ██╗██████╗█████╗ // ██╔══╝██║ ██║██╔══╝████╗ ██║╚═██╔═╝██╔══╝ // ████╗ ██║ ██║████╗ ██╔██╗██║ ██║ █████╗ // ██╔═╝ ╚██╗██╔╝██╔═╝ ██║╚████║ ██║ ╚══██║ // █████╗ ╚███╔╝ █████╗██║ ╚███║ ██║ █████║ // ╚════╝ ╚══╝ ╚════╝╚═╝ ╚══╝ ╚═╝ ╚════╝ function sitemap_get_event_urls() { global $cocoon; $all_events = new DOMDocument(); $all_events->load( $cocoon->path_content . '/_jbuilt_/assets/events/' . $cocoon->locale . '.xml' ); $xpath = new DOMXPath($all_events); $events = $xpath->query( '/assets/event' ); // return sitemap_get_urls_from_events($events); $event_urls = array(); foreach ($events as $event) { if ($cocoon->isNodeAvailable($event)) { $id = $event->getAttribute('id'); $year = $event->getElementsByTagName('release-date-time')->item(0)->getAttribute('year'); $event_urls[] = get_domain_name() . '/' . $cocoon->locale . '/webfleet/company/updates/events/' . $year . '/' . $id . '/'; } } // events archive for ($i = 2009; $i < date('Y'); $i++) { $event_urls[] = get_domain_name() . '/' . $cocoon->locale .'/webfleet/company/updates/events/' . $i . '/'; } return $event_urls; } // ███╗ ██╗█████╗██╗ ██╗█████╗ // ████╗ ██║██╔══╝██║ ██║██╔══╝ // ██╔██╗██║████╗ ██║ █╗ ██║█████╗ // ██║╚████║██╔═╝ ██║███╗██║╚══██║ // ██║ ╚███║█████╗╚███╔███╔╝█████║ // ╚═╝ ╚══╝╚════╝ ╚══╝╚══╝ ╚════╝ function sitemap_get_news_urls() { global $cocoon; $all_news = new DOMDocument(); $all_news->load( $cocoon->path_content . '/_jbuilt_/assets/releases/' . $cocoon->locale . '.xml' ); $xpath = new DOMXPath($all_news); $news_items = $xpath->query( '/assets/release' ); // return sitemap_get_urls_from_news($news); $news_urls = array(); foreach ($news_items as $news) { $category = $news->getElementsByTagName('meta')->item(0)->getAttribute('categories'); $year = $news->getElementsByTagName('release-date-time')->item(0)->getAttribute('year'); $month = $news->getElementsByTagName('release-date-time')->item(0)->getAttribute('month'); $day = $news->getElementsByTagName('release-date-time')->item(0)->getAttribute('day'); $url = get_domain_name() . '/' . $cocoon->locale . '/webfleet/company/updates/press/' . $year . '/' . $month . '/' . $day . '/'; $following_count = $xpath->query('following::release-date-time[ @year=' . $year . ' and @month=' . $month . ' and @day=' . $day . ' ]', $news)->length; if ($following_count > 0) { $url .= ($following_count + 1) . '/'; } $news_urls[] = $url; } // news archive for ($i = 2005; $i < date('Y'); $i++) { $news_urls[] = get_domain_name() . '/' . $cocoon->locale . '/webfleet/company/updates/press/' . $i . '/'; } return $news_urls; }