You are here

function _taxonomy_manager_tree_get_translated_item in Taxonomy Manager 7

Same name and namespace in other branches
  1. 6.2 taxonomy_manager.module \_taxonomy_manager_tree_get_translated_item()

loads translated 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_translated_item()
_taxonomy_manager_tree_get_item in ./taxonomy_manager.module
loads tree with terms (depending on various settings)

File

./taxonomy_manager.module, line 394
Taxonomy Manager

Code

function _taxonomy_manager_tree_get_translated_item($vid, $parent = 0, $pager = FALSE, $siblings_page = 0, $search_string = NULL, $language_code = NULL) {

  //TODO merge with function above
  $tree = array();
  if ($language_code == "no language") {
    $language_code = "";

    //get terms where no language is specified
  }
  if ($pager) {
    if ($parent || $siblings_page) {
      $start = ($siblings_page - 1) * variable_get('taxonomy_manager_pager_tree_page_size', TAXONOMY_MANAGER_PAGER_TREE_PAGE_SIZE_DEFAULT);
      $result = db_query_range("SELECT t.* FROM {taxonomy_term_data} t INNER JOIN {taxonomy_term_hierarchy} h ON t.tid = h.tid WHERE vid = :vid AND h.parent = :parent AND t.language = :language ORDER BY t.weight, t.name", $start, variable_get('taxonomy_manager_pager_tree_page_size', 50), array(
        ':vid' => $vid,
        ':parent' => $parent,
        ':language' => $language_code,
      ));
    }
    else {
      $query = db_select('taxonomy_term_data', 't')
        ->extend('PagerDefault');
      $query
        ->fields('t');
      $table_alias = $query
        ->join('taxonomy_term_hierarchy', 'h', 't.tid = h.tid AND h.parent = 0');
      $query
        ->condition('t.vid', $vid)
        ->condition('t.language', $language_code)
        ->orderBy('t.weight', 'ASC')
        ->orderBy('t.name', 'ASC')
        ->limit(variable_get('taxonomy_manager_pager_tree_page_size', TAXONOMY_MANAGER_PAGER_TREE_PAGE_SIZE_DEFAULT));
      if ($search_string) {
        $query
          ->condition('name', '%' . db_like($search_string) . '%', 'LIKE');
      }
      $result = $query
        ->execute();
    }
    foreach ($result as $term) {
      $term->depth = 0;
      $tree[] = $term;
    }
  }
  else {
    $tree = i18n_taxonomy_get_tree($vid, $language_code, $parent);
  }
  return $tree;
}