You are here

function _taxonomy_manager_tree_get_item in Taxonomy Manager 5

Same name and namespace in other branches
  1. 6.2 taxonomy_manager.module \_taxonomy_manager_tree_get_item()
  2. 6 taxonomy_manager.module \_taxonomy_manager_tree_get_item()
  3. 7 taxonomy_manager.module \_taxonomy_manager_tree_get_item()

loads tree with terms (depending on various settings)

Parameters

$vid:

$parent:

$pager:

$siblings_page:

Return value

array with term elements

1 call to _taxonomy_manager_tree_get_item()
taxonomy_manager_tree_process_elements in ./taxonomy_manager.module
Processes the tree form element

File

./taxonomy_manager.module, line 1679
Taxonomy Manager

Code

function _taxonomy_manager_tree_get_item($vid, $parent = 0, $pager = FALSE, $siblings_page = 0, $search_string = NULL) {
  $tree = array();
  if ($pager) {
    if ($parent || $siblings_page) {
      $start = ($siblings_page - 1) * variable_get('taxonomy_manager_pager_tree_page_size', 50);
      $result = db_query_range("SELECT t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE vid = %d AND h.parent = %d ORDER BY weight, name", $vid, $parent, $start, variable_get('taxonomy_manager_pager_tree_page_size', 50));
    }
    else {
      if ($search_string) {
        $result = pager_query("SELECT t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE vid = %d AND h.parent = 0 AND name LIKE ('%%%s%%') ORDER BY weight, name", variable_get('taxonomy_manager_pager_tree_page_size', 50), 0, NULL, array(
          $vid,
          $search_string,
        ));
      }
      else {
        $result = pager_query("SELECT t.* FROM {term_data} t INNER JOIN {term_hierarchy} h ON t.tid = h.tid WHERE vid = %d AND h.parent = 0 ORDER BY weight, name", variable_get('taxonomy_manager_pager_tree_page_size', 50), 0, NULL, array(
          $vid,
        ));
      }
    }
    while ($term = db_fetch_object($result)) {
      $tree[] = $term;
    }
  }
  else {
    $tree = taxonomy_get_tree($vid, $parent);
  }
  return $tree;
}