$mask) { $files = file_scan_directory($directory, $mask); $custom_links = db_select('xmlsitemap', 'x') ->fields('x', array('loc', 'id')) ->condition('x.type', 'custom') ->condition('x.subtype', $directory) ->execute() ->fetchAllAssoc('loc', PDO::FETCH_ASSOC); watchdog('xmlsitemap', 'Files:
' . var_export($files, TRUE), WATCHDOG_NOTICE); watchdog('xmlsitemap', 'Custom:' . var_export($custom_links, TRUE), WATCHDOG_NOTICE); foreach (array_diff_key($files, $custom_links) as $missing => $info) { $link = array( 'type' => 'custom', 'subtype' => $directory, 'loc' => $missing, 'id' => db_query("SELECT MAX(id) FROM {xmlsitemap} WHERE type = 'custom'")->fetchField() + 1, 'priority' => XMLSITEMAP_PRIORITY_DEFAULT, 'lastmod' => 0, 'changefreq' => 0, 'changecount' => 0, 'language' => LANGUAGE_NONE, ); xmlsitemap_link_save($link); watchdog('xmlsitemap', 'Added a custom link for %loc.', array('%loc' => $link['loc']), WATCHDOG_NOTICE); $results[$directory]['add'][] = $link['loc']; } foreach (array_diff_key($custom_links, $files) as $extra => $info) { xmlsitemap_link_delete('custom', $custom_links[$extra]); $results[$directory]['delete'][] = $extra; watchdog('xmlsitemap', 'Deleted the custom link for %loc.', array('%loc' => $extra), WATCHDOG_NOTICE); } } return $results; }