diff --git a/xmlsitemap.module b/xmlsitemap.module index 93e935f..20e270e 100644 --- a/xmlsitemap.module +++ b/xmlsitemap.module @@ -589,7 +589,12 @@ function xmlsitemap_link_save(array $link) { $link['changecount'] = 0; } - $existing = db_query_range("SELECT loc, access, status, lastmod, priority, changefreq, changecount, language FROM {xmlsitemap} WHERE type = :type AND id = :id", 0, 1, array(':type' => $link['type'], ':id' => $link['id']))->fetchAssoc(); + if (module_exists('entity_translation') && !empty($link['language']) ) { + $existing = db_query_range("SELECT loc, access, status, lastmod, priority, changefreq, changecount, language FROM {xmlsitemap} WHERE type = :type AND id = :id AND language = :language", 0, 1, array(':type' => $link['type'], ':id' => $link['id'], ':language' => $link['language']))->fetchAssoc(); + } + else { + $existing = db_query_range("SELECT loc, access, status, lastmod, priority, changefreq, changecount, language FROM {xmlsitemap} WHERE type = :type AND id = :id", 0, 1, array(':type' => $link['type'], ':id' => $link['id']))->fetchAssoc(); + } // Check if this is a changed link and set the regenerate flag if necessary. if (!variable_get('xmlsitemap_regenerate_needed', FALSE)) { diff --git a/xmlsitemap_node/xmlsitemap_node.install b/xmlsitemap_node/xmlsitemap_node.install index c7eaa5b..110c411 100644 --- a/xmlsitemap_node/xmlsitemap_node.install +++ b/xmlsitemap_node/xmlsitemap_node.install @@ -42,3 +42,11 @@ function xmlsitemap_node_update_6200() { */ function xmlsitemap_node_update_6201() { } + +/** + * Empty update. + */ +function xmlsitemap_node_update_6202() { + db_query('ALTER TABLE {xmlsitemap} DROP PRIMARY KEY'); + db_add_primary_key('xmlsitemap', array('id', 'type', 'language')); +} diff --git a/xmlsitemap_node/xmlsitemap_node.module b/xmlsitemap_node/xmlsitemap_node.module index 6a0e6d9..987ed4b 100644 --- a/xmlsitemap_node/xmlsitemap_node.module +++ b/xmlsitemap_node/xmlsitemap_node.module @@ -40,7 +40,16 @@ function xmlsitemap_node_xmlsitemap_process_node_links(array $nids) { $nodes = node_load_multiple($nids); foreach ($nodes as $node) { $link = xmlsitemap_node_create_link($node); - xmlsitemap_link_save($link); + if (module_exists('entity_translation') && is_array($link['language']) && !empty($link['language'])) { + foreach ($link['language'] as $lang) { + $lang_link = $link; + $lang_link['language'] = $lang; + xmlsitemap_link_save($lang_link); + } + } + else { + xmlsitemap_link_save($link); + } } } @@ -56,7 +65,16 @@ function xmlsitemap_node_node_insert(stdClass $node) { */ function xmlsitemap_node_node_update(stdClass $node) { $link = xmlsitemap_node_create_link($node); - xmlsitemap_link_save($link); + if (module_exists('entity_translation') && is_array($link['language']) && !empty($link['language'])){ + foreach ($link['language'] as $lang) { + $lang_link = $link; + $lang_link['language'] = $lang; + xmlsitemap_link_save($lang_link); + } + } + else { + xmlsitemap_link_save($link); + } } /** @@ -204,7 +222,12 @@ function xmlsitemap_node_create_link(stdClass $node) { $node->xmlsitemap['loc'] = $uri['path']; $node->xmlsitemap['lastmod'] = count($timestamps) ? max($timestamps) : 0; $node->xmlsitemap['access'] = $node->nid ? xmlsitemap_node_view_access($node, drupal_anonymous_user()) : 1; - $node->xmlsitemap['language'] = isset($node->language) ? $node->language : LANGUAGE_NONE; + if (module_exists('entity_translation') && isset($node->translations)) { + $node->xmlsitemap['language'] = array_keys($node->translations->data); + } + else { + $node->xmlsitemap['language'] = isset($node->language) ? $node->language : LANGUAGE_NONE; + } return $node->xmlsitemap; } diff --git a/xmlsitemap_taxonomy/xmlsitemap_taxonomy.module b/xmlsitemap_taxonomy/xmlsitemap_taxonomy.module index af8dbd0..fef44fd 100644 --- a/xmlsitemap_taxonomy/xmlsitemap_taxonomy.module +++ b/xmlsitemap_taxonomy/xmlsitemap_taxonomy.module @@ -50,7 +50,16 @@ function xmlsitemap_taxonomy_xmlsitemap_process_taxonomy_term_links(array $tids) $terms = taxonomy_term_load_multiple($tids); foreach ($terms as $term) { $link = xmlsitemap_taxonomy_create_link($term); - xmlsitemap_link_save($link); + if (module_exists('entity_translation') && is_array($link['language']) && !empty($link['language'])){ + foreach ($link['language'] as $lang){ + $lang_link = $link; + $lang_link['language'] = $lang; + xmlsitemap_link_save($lang_link); + } + } + else { + xmlsitemap_link_save($link); + } } } @@ -115,7 +124,16 @@ function xmlsitemap_taxonomy_term_insert(stdClass $term) { */ function xmlsitemap_taxonomy_term_update(stdClass $term) { $link = xmlsitemap_taxonomy_create_link($term); - xmlsitemap_link_save($link); + if (module_exists('entity_translation') && is_array($link['language']) && !empty($link['language'])){ + foreach ($link['language'] as $lang){ + $lang_link = $link; + $lang_link['language'] = $lang; + xmlsitemap_link_save($lang_link); + } + } + else { + xmlsitemap_link_save($link); + } } /** @@ -175,7 +193,14 @@ function xmlsitemap_taxonomy_create_link(stdClass &$term) { // @todo How can/should we check taxonomy term access? $term->xmlsitemap['loc'] = $uri['path']; $term->xmlsitemap['access'] = 1; - $term->xmlsitemap['language'] = isset($term->language) ? $term->language : LANGUAGE_NONE; + if (module_exists('entity_translation') && isset($term->translations)) { + $languages = array_keys($term->translations->data); + $term->xmlsitemap['language'] = !empty($languages) ? $languages : (isset($term->language) ? $term->language : LANGUAGE_NONE); + } + else{ + $term->xmlsitemap['language'] = isset($term->language) ? $term->language : LANGUAGE_NONE; + } + return $term->xmlsitemap; }