You are here

function taxonomy_pathauto_bulkupdate in Pathauto 5

Same name and namespace in other branches
  1. 5.2 pathauto_taxonomy.inc \taxonomy_pathauto_bulkupdate()
  2. 6 pathauto_taxonomy.inc \taxonomy_pathauto_bulkupdate()

Generate aliases for all categories without aliases

File

./pathauto_taxonomy.inc, line 108

Code

function taxonomy_pathauto_bulkupdate() {
  $query = "SELECT tid,vid,name,src,dst FROM {term_data} LEFT JOIN {url_alias} ON CONCAT('taxonomy/term/', tid) = src";
  $result = db_query($query);
  $category = db_fetch_object($result);
  if (module_exists('forum')) {
    $forumvid = variable_get('forum_nav_vocabulary', '');
  }
  $count = 0;
  $placeholders = array();
  while ($category) {
    $vid = $category->vid;
    if (!module_exists($forum) || module_exists($forum) && $forumvid != $vid) {
      $vocabulary = taxonomy_get_vocabulary($vid);
      $placeholders[t('[vocab]')] = pathauto_cleanstring($vocabulary->name);
      $placeholders[t('[cat]')] = pathauto_cleanstring($category->name);
      $placeholders[t('[tid]')] = $category->tid;
      $placeholders[t('[catpath]')] = _pathauto_taxonomy_catpath($category);

      // Append any additional extensions
      $extplaceholders = module_invoke_all('pathauto_taxonomy', 'values', $category);
      $placeholders = array_merge($placeholders, $extplaceholders);
      $src = 'taxonomy/term/' . $category->tid;
      if ($alias = pathauto_create_alias('taxonomy', 'bulkupdate', $placeholders, $src, $vid)) {
        $count++;
      }
    }
    $category = db_fetch_object($result);
  }
  drupal_set_message(format_plural($count, "Bulk update of terms completed, one alias generated.", "Bulk update of terms completed, @count aliases generated."));
}