Commit 1d00d42a authored by Dave Reid's avatar Dave Reid
Browse files

by Dave Reid: Changed the 'taxonomy' link type to 'taxonomy_term'.

parent 290d7d4c
......@@ -171,15 +171,16 @@ function xmlsitemap_schema() {
'type' => array(
'description' => 'Primary key with id; the type of item (e.g. node, user, etc.).',
'type' => 'varchar',
'length' => 12,
'length' => 32,
'not null' => TRUE,
'default' => '',
),
'subtype' => array(
'description' => 'A sub-type identifier for the link (node type, menu name, term VID, etc.).',
'type' => 'varchar',
'length' => 32,
'default' => NULL,
'length' => 128,
'not null' => TRUE,
'default' => '',
),
'loc' => array(
'description' => 'The URL to the item relative to the Drupal path.',
......@@ -455,6 +456,18 @@ function xmlsitemap_update_17() {
return $ret;
}
function xmlsitemap_update_18() {
$field = array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
);
db_change_field('xmlsitemap', 'type', 'type', $field);
$field['length'] = 128;
db_change_field('xmlsitemap', 'subtype', 'subtype', $field);
}
/**
* These strings exist only for the extractor to pick them up and make them
* available for translation. Putting them here keeps them from being parsed
......
......@@ -20,12 +20,29 @@ function xmlsitemap_taxonomy_uninstall() {
// @todo Remove these update functions before alpha.
function xmlsitemap_taxonomy_update_1() {
$ret = array();
$vids = array_keys(taxonomy_get_vocabularies());
foreach ($vids as $vid) {
if (variable_get('xmlsitemap_taxonomy_priority_' . $vid, 'default') === 'default') {
variable_set('xmlsitemap_taxonomy_priority_' . $vid, 0.5);
}
}
return $ret;
}
/**
* Change 'taxonomy' type to 'taxonomy_term'.
*/
function xmlsitemap_taxonomy_update_2() {
$field = array(
'type' => 'varchar',
'length' => 32,
'not null' => TRUE,
'default' => '',
);
db_change_field('xmlsitemap', 'type', 'type', $field);
db_update('xmlsitemap')
->fields(array('type' => 'taxonomy_term'))
->condition('type', 'taxonomy')
->execute();
}
// @todo Convert {xmlsitemap}.subtype from vid to vocabulary_machine_name.
......@@ -15,7 +15,7 @@ function xmlsitemap_taxonomy_cron() {
*/
function xmlsitemap_taxonomy_xmlsitemap_index_links($limit) {
if ($vids = xmlsitemap_taxonomy_get_vids()) {
$tids = db_query_range("SELECT t.tid FROM {term_data} t LEFT JOIN {xmlsitemap} x ON x.type = 'taxonomy' AND t.tid = x.id WHERE x.id IS NULL AND t.vid IN :vids ORDER BY t.tid DESC", 0, $limit, array(':vids' => $vids));
$tids = db_query_range("SELECT t.tid FROM {term_data} t LEFT JOIN {xmlsitemap} x ON x.type = 'taxonomy_term' AND t.tid = x.id WHERE x.id IS NULL AND t.vid IN :vids ORDER BY t.tid DESC", 0, $limit, array(':vids' => $vids));
foreach ($tids as $tid) {
$term = xmlsitemap_taxonomy_taxonomy_term_load($tid);
$link = xmlsitemap_taxonomy_create_link($term);
......@@ -78,7 +78,7 @@ function xmlsitemap_taxonomy_xmlsitemap_link_info() {
*/
function xmlsitemap_taxonomy_taxonomy_term_load($tid) {
$term = taxonomy_get_term($tid);
if ($data = xmlsitemap_load_link(array('type' => 'taxonomy', 'id' => $tid))) {
if ($data = xmlsitemap_load_link(array('type' => 'taxonomy_term', 'id' => $tid))) {
$term->xmlsitemap = $data;
}
return $term;
......@@ -91,7 +91,7 @@ function xmlsitemap_taxonomy_taxonomy_term_load($tid) {
*/
function xmlsitemap_taxonomy_form_xmlsitemap_settings_form_alter(&$form, $form_state) {
$type = array(
'type' => 'taxonomy',
'type' => 'taxonomy_term',
'title' => t('Taxonomy'),
'item_title' => t('Vocabulary'),
'access' => user_access('administer taxonomy'),
......@@ -108,7 +108,7 @@ function xmlsitemap_taxonomy_form_xmlsitemap_settings_form_alter(&$form, $form_s
}
xmlsitemap_add_form_type_summary($form, $type, $vocabularies);
$form['taxonomy']['#weight'] = 40;
$form['taxonomy_term']['#weight'] = 40;
}
/**
......@@ -157,10 +157,10 @@ function xmlsitemap_taxonomy_taxonomy_form_vocabulary_submit($form, $form_state)
$new_priority = $form_state['values']['xmlsitemap_taxonomy_priority'];
if ($new_status != variable_get('xmlsitemap_taxonomy_status_' . $vid, 0)) {
xmlsitemap_update_links(array('status' => $new_status), array('type' => 'taxonomy', 'subtype' => $vid, 'status_override' => 0));
xmlsitemap_update_links(array('status' => $new_status), array('type' => 'taxonomy_term', 'subtype' => $vid, 'status_override' => 0));
}
if ($new_priority != variable_get('xmlsitemap_taxonomy_priority_' . $vid, 0.5)) {
xmlsitemap_update_links(array('priority' => $new_priority), array('type' => 'taxonomy', 'subtype' => $vid, 'priority_override' => 0));
xmlsitemap_update_links(array('priority' => $new_priority), array('type' => 'taxonomy_term', 'subtype' => $vid, 'priority_override' => 0));
}
variable_set('xmlsitemap_taxonomy_status_' . $vid, $new_status);
......@@ -190,7 +190,7 @@ function xmlsitemap_taxonomy_form_taxonomy_form_term_alter(&$form, $form_state)
$form['xmlsitemap']['#access'] |= user_access('administer taxonomy');
if (user_access('administer taxonomy')) {
$form['xmlsitemap']['#description'] .= ' ' . t('The default priority for this vocabulary can be changed <a href="@link-type">here</a>.', array('@link-type' => url('admin/content/taxonomy/edit/vocabulary/' . $term->vid, array('query' => drupal_get_destination()))));
$form['xmlsitemap']['#description'] = t('The default priority for this vocabulary can be changed <a href="@link-type">here</a>.', array('@link-type' => url('admin/content/taxonomy/edit/vocabulary/' . $term->vid, array('query' => drupal_get_destination()))));
}
// The submit and delete buttons need to be weighted down.
......@@ -209,7 +209,7 @@ function xmlsitemap_taxonomy_taxonomy($op, $type, $array = NULL) {
$vid = $array['vid'];
// Insert and update actions handled by xmlsitemap_taxonomy_taxonomy_form_vocabulary_submit().
if ($op == 'delete') {
xmlsitemap_delete_link(array('type' => 'taxonomy', 'subtype' => $vid));
xmlsitemap_delete_link(array('type' => 'taxonomy_term', 'subtype' => $vid));
variable_del('xmlsitemap_taxonomy_status_' . $vid);
variable_del('xmlsitemap_taxonomy_priority_' . $vid);
}
......@@ -221,7 +221,7 @@ function xmlsitemap_taxonomy_taxonomy($op, $type, $array = NULL) {
xmlsitemap_save_link($link);
}
elseif ($op == 'delete') {
xmlsitemap_delete_link(array('type' => 'taxonomy', 'id' => $tid));
xmlsitemap_delete_link(array('type' => 'taxonomy_term', 'id' => $tid));
}
}
}
......@@ -241,7 +241,7 @@ function xmlsitemap_taxonomy_create_link(stdClass $term) {
$term->xmlsitemap += array(
'id' => $term->tid,
'type' => 'taxonomy',
'type' => 'taxonomy_term',
'subtype' => $term->vid,
'loc' => taxonomy_term_path($term),
'status' => variable_get('xmlsitemap_taxonomy_status_' . $term->vid, 0),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment