Skip to content

Commit c9a4a71

Browse files
committed
v.1.0.13
1 parent d24b026 commit c9a4a71

File tree

2 files changed

+39
-42
lines changed

2 files changed

+39
-42
lines changed

easy_xmlsitemap.info

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,5 @@ package = SEO
44
backdrop = 1.x
55
type = module
66
configure = admin/config/metadata/easy_xmlsitemap
7-
version = 1.0.12
7+
version = 1.0.13
88

easy_xmlsitemap.module

Lines changed: 38 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -97,48 +97,10 @@ function easy_xmlsitemap_build() {
9797
$config_base_url = rtrim($config->get('base_url'), '/');
9898
$base_url = !empty($config_base_url) ? $config_base_url : $proto . $host;
9999

100-
$result = db_select('node', 'n')
101-
->fields('n', array('nid', 'type', 'langcode', 'uid', 'status', 'tnid'))
102-
->condition('status', 1)
103-
->execute();
104-
105-
$account = user_load(0);
106-
$site_langs = easy_xmlsitemap_language_list();
107-
$urls_block = array();
108-
109100
$output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
110101
. "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">";
111-
112-
$frontpage_nid = easy_xmlsitemap_get_frontpage_nid();
113-
foreach ($result as $node) {
114-
if (node_access('view', $node, $account)) {
115-
// skip node if set as frontpage
116-
if (!empty($frontpage_nid) && $node->nid == $frontpage_nid) {
117-
continue;
118-
}
119-
120-
$url = url('node/' . $node->nid, array('absolute' => FALSE, 'language' => (object) array('langcode' => $node->langcode)));
121-
122-
// skip excluded URLs
123-
if (easy_xmlsitemap_seo_meta_check_robots(SEO_META_TYPE_NODE, $node->nid) || easy_xmlsitemap_url_excluded($url)) {
124-
continue;
125-
}
126-
127-
//skip nodes with disabled languages but with "und"
128-
if ($node->langcode != 'und' && !array_key_exists($node->langcode, $site_langs)) {
129-
continue;
130-
}
131-
132-
$urls_block[$node->tnid][] = array(
133-
'nid' => $node->nid,
134-
'tnid' => $node->tnid,
135-
'langcode' => $node->langcode,
136-
);
137-
}
138-
}
139-
140102
$output .= easy_xmlsitemap_build_front_url($base_url);
141-
$output .= easy_xmlsitemap_build_node_items($base_url, $urls_block);
103+
$output .= easy_xmlsitemap_build_node_items($base_url);
142104
$output .= easy_xmlsitemap_build_taxonomy_items($base_url);
143105
$output .= easy_xmlsitemap_build_views_items($base_url);
144106
$output .= "\n" . '</urlset>';
@@ -254,12 +216,47 @@ function easy_xmlsitemap_build_front_url($base_url) {
254216
* Find and print nodes URLs
255217
* @global object $language
256218
* @param string $base_url
257-
* @param array $urls_block
258219
* @return string
259220
*/
260-
function easy_xmlsitemap_build_node_items($base_url, $urls_block) {
221+
function easy_xmlsitemap_build_node_items($base_url) {
261222
$default_langcode = config_get('system.core', 'language_default');
223+
$site_langs = easy_xmlsitemap_language_list();
224+
$urls_block = array();
262225
$output = '';
226+
227+
$frontpage_nid = easy_xmlsitemap_get_frontpage_nid();
228+
229+
$result = db_select('node', 'n')
230+
->addTag('node_access')
231+
->fields('n')
232+
->condition('status', 0, '>')
233+
->execute()
234+
->fetchAll();
235+
236+
foreach ($result as $node) {
237+
// skip node if set as frontpage
238+
if (!empty($frontpage_nid) && $node->nid == $frontpage_nid) {
239+
continue;
240+
}
241+
242+
$url = url('node/' . $node->nid, array('absolute' => FALSE, 'language' => (object) array('langcode' => $node->langcode)));
243+
244+
// skip excluded URLs
245+
if (easy_xmlsitemap_seo_meta_check_robots(SEO_META_TYPE_NODE, $node->nid) || easy_xmlsitemap_url_excluded($url)) {
246+
continue;
247+
}
248+
249+
//skip nodes with disabled languages but with "und"
250+
if ($node->langcode != 'und' && !array_key_exists($node->langcode, $site_langs)) {
251+
continue;
252+
}
253+
254+
$urls_block[$node->tnid][] = array(
255+
'nid' => $node->nid,
256+
'tnid' => $node->tnid,
257+
'langcode' => $node->langcode,
258+
);
259+
}
263260

264261
foreach ($urls_block as $tnid => $urls) {
265262
if ($tnid == '0') {

0 commit comments

Comments
 (0)