You are here

function xmlsitemap_term_taxonomy in XML sitemap 5.2

Same name and namespace in other branches
  1. 5 xmlsitemap_term/xmlsitemap_term.module \xmlsitemap_term_taxonomy()

Implementation of hook_taxonomy().

File

xmlsitemap_term/xmlsitemap_term.module, line 111
Adds taxonomy terms to the sitemap.

Code

function xmlsitemap_term_taxonomy($op, $type, $array = NULL) {
  if ($type == 'vocabulary') {
    switch ($op) {
      case 'delete':
        variable_del('xmlsitemap_term_vocabulary_priority_' . $array['vid']);
        xmlsitemap_flag_sitemap();
        break;
      case 'insert':
      case 'update':
        if (variable_get('xmlsitemap_term_vocabulary_priority_' . $array['vid'], 0.5) != $array['xmlsitemap_term_vocabulary_priority']) {
          variable_set('xmlsitemap_term_vocabulary_priority_' . $array['vid'], $array['xmlsitemap_term_vocabulary_priority']);
          xmlsitemap_flag_sitemap();
        }
        break;
    }
  }
  else {
    switch ($op) {
      case 'insert':
        $priority = isset($array['xmlsitemap_term_priority']) ? $array['xmlsitemap_term_priority'] : 'NULL';
        db_query("INSERT INTO {xmlsitemap_term} (tid, last_changed, priority_override) VALUES (%d, %d, %s)", $array['tid'], REQUEST_TIME, $priority);
        break;
      case 'update':
        if (!isset($array['xmlsitemap_term_priority'])) {
          $priority = db_result(db_query("SELECT priority_override FROM {xmlsitemap_term} WHERE tid = %d", $array['tid']));
          $array['xmlsitemap_term_priority'] = isset($priority) && $priority !== FALSE ? $priority : 'NULL';
        }
        db_query("UPDATE {xmlsitemap_term}\n          SET priority_override = %s\n          WHERE tid = %d", $array['xmlsitemap_term_priority'], $array['tid']);
        break;
      case 'delete':
        db_query("DELETE FROM {xmlsitemap_term} WHERE tid = %d", $array['tid']);
        break;
    }
    xmlsitemap_flag_sitemap();
  }
}