11<?php
22/**
3- * @file easy_xmlsitemap. module
3+ * @file main module file
44 */
5+
56/**
6- * Implements hook_help().
7- *
7+ * Implements hook_config_info().
88 */
9- function easy_xmlsitemap_help($path, $arg) {
10- if ($path == 'admin/help#easy_xmlsitemap') {
11- return t('Easy XML Sitemap module provides sitemap file in XML format with multilingual attributes.');
12- }
9+ function easy_xmlsitemap_config_info() {
10+ $prefixes['easy_xmlsitemap.settings'] = array(
11+ 'label' => t('Easy XML Sitemap'),
12+ 'group' => t('Configuration'),
13+ );
14+
15+ return $prefixes;
1316}
1417
1518/**
@@ -57,18 +60,6 @@ function easy_xmlsitemap_menu() {
5760 return $items;
5861}
5962
60- /**
61- * Implements hook_config_info().
62- */
63- function easy_xmlsitemap_config_info() {
64- $prefixes['easy_xmlsitemap.settings'] = array(
65- 'label' => t('Easy XML Sitemap'),
66- 'group' => t('Configuration'),
67- );
68-
69- return $prefixes;
70- }
71-
7263/**
7364 * Wrapper for core language_list(), just remove excluded languages
7465 */
@@ -100,8 +91,6 @@ function easy_xmlsitemap_build() {
10091 $host = $_SERVER['HTTP_HOST'];
10192 $config_base_url = rtrim($config->get('base_url'), '/');
10293 $base_url = !empty($config_base_url) ? $config_base_url : $proto . $host;
103- $excluded_raw_urls = $config->get('excluded_urls');
104- $excluded_urls = easy_xmlsitemap_textarea_to_array($excluded_raw_urls);
10594
10695 $result = db_select('node', 'n')
10796 ->fields('n', array('nid', 'type', 'langcode', 'uid', 'status', 'tnid'))
@@ -127,7 +116,7 @@ function easy_xmlsitemap_build() {
127116 $url = url('node/' . $node->nid, array('absolute' => FALSE, 'language' => (object) array('langcode' => $node->langcode)));
128117
129118 // skip excluded URLs
130- if (easy_xmlsitemap_url_excluded($url, $excluded_urls )) {
119+ if (easy_xmlsitemap_url_excluded($url)) {
131120 continue;
132121 }
133122
@@ -156,11 +145,14 @@ function easy_xmlsitemap_build() {
156145/**
157146 * Check if given URL should be excluded from sitemap
158147 * @param string $url (e.g. "/about.html" or "/node/123")
159- * @param array $excluded_urls
160148 * @return boolean
161149 */
162- function easy_xmlsitemap_url_excluded($url, $excluded_urls) {
163- $excluded = FALSE;
150+ function easy_xmlsitemap_url_excluded($url) {
151+ $config = config('easy_xmlsitemap.settings');
152+ $excluded_raw_urls = $config->get('excluded_urls');
153+ $excluded_urls = easy_xmlsitemap_textarea_to_array($excluded_raw_urls);
154+ $excluded = FALSE;
155+
164156 if (!empty($excluded_urls)) {
165157 if (in_array(substr($url, 1), $excluded_urls)) {
166158 $excluded = TRUE;
@@ -220,7 +212,7 @@ function easy_xmlsitemap_build_front_url($base_url) {
220212}
221213
222214/**
223- * Find ans print nodes URLs
215+ * Find and print nodes URLs
224216 * @global object $language
225217 * @param string $base_url
226218 * @param array $urls_blok
@@ -279,8 +271,13 @@ function easy_xmlsitemap_build_taxonomy_items($base_url) {
279271 $array_of_nodes = taxonomy_select_nodes($term->tid);
280272
281273 if (!empty($array_of_nodes)) {
282- $url = $base_url . url('taxonomy/term/' . $term->tid, array('absolute' => FALSE, 'language' => (object) array('langcode' => $langcode)));
283- $output .= easy_xmlsitemap_wrap_url($url, $langcode);
274+ $url = url('taxonomy/term/' . $term->tid, array('absolute' => FALSE, 'language' => (object) array('langcode' => $langcode)));
275+ // skip excluded URLs
276+ if (easy_xmlsitemap_url_excluded($url)) {
277+ continue;
278+ }
279+
280+ $output .= easy_xmlsitemap_wrap_url($base_url . $url, $langcode);
284281 }
285282 }
286283 return $output;
@@ -314,8 +311,13 @@ function easy_xmlsitemap_build_views_items($base_url) {
314311 $page_path = $view->display[$id]->display_options['path'];
315312 // Skip admin views
316313 if (strpos($page_path, 'admin/') === FALSE) {
317- $url = $base_url . url('/' . $page_path, array('absolute' => FALSE, 'language' => (object) array('langcode' => $langcode)));
318- $output .= easy_xmlsitemap_wrap_url($url, $langcode);
314+ $url = url('/' . $page_path, array('absolute' => FALSE, 'language' => (object) array('langcode' => $langcode)));
315+ // skip excluded URLs
316+ if (easy_xmlsitemap_url_excluded($url)) {
317+ continue;
318+ }
319+
320+ $output .= easy_xmlsitemap_wrap_url($base_url . $url, $langcode);
319321 }
320322 }
321323 }
0 commit comments