tid = $term->tid; $row->vid = $term->vid; $row->changed = REQUEST_TIME; drupal_write_record('xmlsitemap_taxonomy', $row); $sitemap_changed = TRUE; } if ($sitemap_changed) { xmlsitemap_flag_sitemap(); } } } /** * Implementation of hook_form_FORM_ID_alter(). */ function xmlsitemap_taxonomy_form_taxonomy_form_term_alter(&$form, &$from_state) { if (!isset($form['identification'])) { // This same form is used for the term delete confirm form, so skip // adding our fieldset if that is the case. return; } $priority = db_result(db_query("SELECT priority_override FROM {xmlsitemap_taxonomy} WHERE tid = %d", $form['#term']['tid']) ); if ($priority === FALSE) { $priority = -2.0; } $options = xmlsitemap_priority_options('both'); $default = variable_get('xmlsitemap_taxonomy_vocabulary_priority_'. $form['vid']['#value'], '0.5'); if (!isset($form['xmlsitemap'])) { $form['xmlsitemap'] = array( '#type' => 'fieldset', '#title' => t('XML sitemap'), '#collapsible' => TRUE, '#collapsed' => TRUE, ); } $form['xmlsitemap']['xmlsitemap_taxonomy_priority'] = array( '#type' => 'select', '#title' => t('Priority'), '#description' => t('The default priority is %priority.', array('%priority' => $options[$default])), '#default_value' => $priority, '#options' => $options, ); // The submit and delete buttons need to be weighted down. $form['submit'] += array('#weight' => 100); if (isset($form['delete'])) { $form['delete'] += array('#weight' => 110); } } /** * Implementation of hook_form_FORM_ID_alter(). */ function xmlsitemap_taxonomy_form_taxonomy_form_vocabulary_alter(&$form, &$from_state) { $form['xmlsitemap'] = array( '#type' => 'fieldset', '#title' => t('XML sitemap'), '#collapsible' => TRUE, ); $form['xmlsitemap']['xmlsitemap_taxonomy_vocabulary_priority'] = array( '#type' => 'select', '#title' => t('Priority'), '#description' => t('This will be the default priority of terms in this vocabulary.'), '#default_value' => variable_get('xmlsitemap_taxonomy_vocabulary_priority_'. $form['vid']['#value'], 0.5), '#options' => xmlsitemap_priority_options('exclude'), ); $form['submit']['#weight'] = isset($form['submit']['#weight']) ? $form['submit']['#weight'] + 1 : 1; $form['delete']['#weight'] = isset($form['delete']['#weight']) ? $form['delete']['#weight'] + 2 : 2; } /** * Implementation of hook_nodeapi(). */ function xmlsitemap_taxonomy_nodeapi(&$node, $op, $a3 = NULL, $a4 = NULL) { switch ($op) { case 'update': $terms = taxonomy_node_get_terms($node); foreach ($terms as $term) { $result = db_fetch_object(db_query("SELECT tid, changed, previously_changed, priority_override FROM {xmlsitemap_taxonomy} WHERE tid = %d", $term->tid)); if ($result === FALSE) { $row = new stdClass(); $row->tid = $term->tid; $row->vid = $term->vid; $row->changed = $node->changed; $row->previously_changed = $node->created; } else { $row = $result; if ($row->changed < $node->changed) { $row->previously_changed = $row->changed; $row->changed = $node->changed; } } drupal_write_record('xmlsitemap_taxonomy', $row, $result === FALSE ? NULL : 'tid'); xmlsitemap_flag_sitemap(); } break; } } /** * Implementation of hook_taxonomy(). */ function xmlsitemap_taxonomy_taxonomy($op, $type, $array = NULL) { if ($type == 'vocabulary') { switch ($op) { case 'delete': db_query("DELETE FROM {xmlsitemap_taxonomy} WHERE vid = %d", $array['vid']); variable_del('xmlsitemap_taxonomy_vocabulary_priority_'. $array['vid']); xmlsitemap_flag_sitemap(); break; case 'insert': case 'update': if (isset($array['vid']) && isset($array['xmlsitemap_taxonomy_vocabulary_priority'])) { if (variable_get('xmlsitemap_taxonomy_vocabulary_priority_'. $array['vid'], 0.5) != $array['xmlsitemap_taxonomy_vocabulary_priority']) { variable_set('xmlsitemap_taxonomy_vocabulary_priority_'. $array['vid'], $array['xmlsitemap_taxonomy_vocabulary_priority']); xmlsitemap_flag_sitemap(); } } break; } } else { switch ($op) { case 'delete': db_query("DELETE FROM {xmlsitemap_taxonomy} WHERE tid = %d", $array['tid']); db_query("DELETE FROM {xmlsitemap} WHERE type = 'taxonomy' AND id = %d", $array['tid']); break; case 'insert': if (isset($array['tid']) && isset($array['vid'])) { $row = new stdClass(); $row->tid = $array['tid']; $row->vid = $array['vid']; $row->changed = REQUEST_TIME; $row->priority_override = isset($array['xmlsitemap_taxonomy_priority']) ? $array['xmlsitemap_taxonomy_priority'] : -2.0; drupal_write_record('xmlsitemap_taxonomy', $row); } break; case 'update': $result = db_fetch_object(db_query("SELECT tid, vid, changed, previously_changed, priority_override FROM {xmlsitemap_taxonomy} WHERE tid = %d", $array['tid']) ); if ($result === FALSE) { $row = new stdClass(); $row->tid = $array['tid']; $row->vid = $array['vid']; $row->changed = REQUEST_TIME; $row->priority_override = isset($array['xmlsitemap_taxonomy_priority']) ? $array['xmlsitemap_taxonomy_priority'] : -2.0; } else { $row = $result; if (isset($array['xmlsitemap_taxonomy_priority'])) { $row->priority_override = $array['xmlsitemap_taxonomy_priority']; } } drupal_write_record('xmlsitemap_taxonomy', $row, $result === FALSE ? NULL : 'tid'); break; } xmlsitemap_flag_sitemap(); } } /** * Implementation of hook_xmlsitemap_description(). */ function xmlsitemap_taxonomy_xmlsitemap_description() { return '