Skip to content

Commit

Permalink
v.1.0.5
Browse files Browse the repository at this point in the history
  • Loading branch information
findlabnet committed Nov 14, 2016
1 parent d08935b commit dae29d7
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 9 deletions.
1 change: 0 additions & 1 deletion config/easy_xmlsitemap.settings.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"base_url": "",
"sitemap_dir": "easy_xmlsitemap",
"rebuild_frequency": "daily",
"last_build_date": 0,
"excluded_urls": "",
"excluded_langs": []
}
2 changes: 1 addition & 1 deletion easy_xmlsitemap.admin.inc
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
*/
function easy_xmlsitemap_settings_form() {
$config = config('easy_xmlsitemap.settings');
$last_build_date = $config->get('last_build_date');
$last_build_date = state_get('easy_xmlsitemap_last_build_date', 0);

$info = $last_build_date != 0
? t('Sitemap last build time: ') . format_date($last_build_date, 'short')
Expand Down
2 changes: 1 addition & 1 deletion easy_xmlsitemap.info
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ package = SEO
backdrop = 1.x
type = module
configure = admin/config/search/easy_xmlsitemap
version = 1.0.4
version = 1.0.5

9 changes: 9 additions & 0 deletions easy_xmlsitemap.install
Original file line number Diff line number Diff line change
Expand Up @@ -36,3 +36,12 @@ function easy_xmlsitemap_update_1000() {
$config->set('excluded_langs', array());
$config->save();
}

/**
* Remove obsolete variable from config.
*/
function easy_xmlsitemap_update_1001() {
$config = config('easy_xmlsitemap.settings');
$config->clear('last_build_date');
$config->save();
}
11 changes: 5 additions & 6 deletions easy_xmlsitemap.module
Original file line number Diff line number Diff line change
Expand Up @@ -106,11 +106,11 @@ function easy_xmlsitemap_build() {
$output = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n"
. "<urlset xmlns=\"http://www.sitemaps.org/schemas/sitemap/0.9\" xmlns:xhtml=\"http://www.w3.org/1999/xhtml\">";

$frontpage_nid = easy_xmlsitemap_get_frontpage_nid();

foreach ($result as $node) {
if (node_access('view', $node, $account)) {
// skip node if set as frontpage
$frontpage_nid = easy_xmlsitemap_get_frontpage_nid();

if (!empty($frontpage_nid) && $node->nid == $frontpage_nid) {
continue;
}
Expand Down Expand Up @@ -358,8 +358,7 @@ function easy_xmlsitemap_file_save($content) {
$success = file_exists($file_path);

if ($success) {
$config->set('last_build_date', time());
$config->save();
state_set('easy_xmlsitemap_last_build_date', time());
watchdog('easy_xmlsitemap', 'Sitemap file saved.');
backdrop_set_message(t('File "sitemap.xml" has been saved successfully.'));
}
Expand All @@ -374,7 +373,7 @@ function easy_xmlsitemap_output() {
$config = config('easy_xmlsitemap.settings');
$file_dir = 'public://' . $config->get('sitemap_dir');
$file_path = $file_dir . '/' . 'sitemap.xml';
$last_build_date = $config->get('last_build_date');
$last_build_date = state_get('easy_xmlsitemap_last_build_date', 0);

if (!file_exists($file_path) || !is_readable($file_path)) {
return backdrop_not_found();
Expand Down Expand Up @@ -414,7 +413,7 @@ function easy_xmlsitemap_textarea_to_array($raw_string = '') {
*/
function easy_xmlsitemap_cron() {
$config = config('easy_xmlsitemap.settings');
$last_build_date = $config->get('last_build_date');
$last_build_date = state_get('easy_xmlsitemap_last_build_date', 0);
$rebuild_frequency = $config->get('rebuild_frequency');

if ($rebuild_frequency == 'manually') {
Expand Down

0 comments on commit dae29d7

Please sign in to comment.