function taxonomy_pathauto_bulkupdate in Pathauto 5.2
Same name and namespace in other branches
- 5 pathauto_taxonomy.inc \taxonomy_pathauto_bulkupdate()
- 6 pathauto_taxonomy.inc \taxonomy_pathauto_bulkupdate()
Generate aliases for all categories without aliases.
File
- ./
pathauto_taxonomy.inc, line 55 - Hook implementations for taxonomy module integration.
Code
function taxonomy_pathauto_bulkupdate() {
// From all node types, only attempt to update those with patterns
$pattern_vids = array();
foreach (taxonomy_get_vocabularies() as $vid => $info) {
$pattern = trim(variable_get('pathauto_taxonomy_' . $vid . '_pattern', ''));
// If it's not set, check the default
// TODO - if there's a default we shouldn't do this crazy where statement because all vocabs get aliases
// TODO - special casing to exclude the forum vid (and the images vid and...?)
if (empty($pattern)) {
$pattern = trim(variable_get('pathauto_taxonomy_pattern', ''));
}
if (!empty($pattern)) {
$pattern_vids[] = $vid;
if (empty($vid_where)) {
$vid_where = " AND (vid = '%s' ";
}
else {
$vid_where .= " OR vid = '%s'";
}
}
}
$vid_where .= ')';
// Exclude the forums and join all the args into one array so they can be passed to db_query
$forum_vid[] = variable_get('forum_nav_vocabulary', '');
$query_args = array_merge($forum_vid, $pattern_vids);
$query = "SELECT tid, vid, name, src, dst FROM {term_data} LEFT JOIN {url_alias} ON CONCAT('taxonomy/term/', CAST(tid AS CHAR)) = src WHERE src IS NULL AND vid <> %d " . $vid_where;
$result = db_query_range($query, $query_args, 0, variable_get('pathauto_max_bulk_update', 50));
$count = 0;
$placeholders = array();
while ($category = db_fetch_object($result)) {
$count += _taxonomy_pathauto_alias($category, 'bulkupdate');
}
drupal_set_message(format_plural($count, 'Bulk generation of terms completed, one alias generated.', 'Bulk generation of terms completed, @count aliases generated.'));
}