function tft_folder_content in Taxonomy File Tree 7
Same name and namespace in other branches
- 7.2 tft.module \tft_folder_content()
Loads the given folder content.
4 calls to tft_folder_content()
- tft_folder_list in ./
tft.module - tft_folder_tree in ./
tft.module - Construct the folder tree.
- tft_get_content in ./
tft.module - Get the folder content and return it in an array form for the theme_table call
- tft_tree in ./
tft.module
File
- ./
tft.module, line 837 - Module hooks.
Code
function tft_folder_content($tid, $only_terms = FALSE, $gid = NULL) {
$content = array();
// Get all child folders (terms)
$result = db_query("SELECT td.tid FROM {taxonomy_term_data} td\n LEFT JOIN {taxonomy_term_hierarchy} th ON th.tid = td.tid\n WHERE th.parent = :ptid AND td.vid = :vid", array(
':ptid' => $tid,
':vid' => variable_get('tft_vocabulary_vid', 0),
));
while ($term = $result
->fetchObject()) {
if ($res = db_query("SELECT weight FROM {tft_folder_content_weight} WHERE id = :tid AND type = 'term'", array(
':tid' => $term->tid,
))) {
$weight = $res
->fetchField();
}
$content[] = array(
'id' => $term->tid,
'type' => 'term',
'weight' => tft_is_archive_folder($term->tid) ? 1000 : $weight,
);
}
if ($only_terms) {
usort($content, '_tft_array_weight_sort');
return $content;
}
// Get the files
$result = db_query("SELECT DISTINCT(tn.nid) FROM {node_revision} v\n LEFT JOIN {node} n ON n.vid = v.vid\n LEFT JOIN {taxonomy_index} tn ON tn.nid = n.nid\n WHERE tn.tid = :tid AND n.status = 1", array(
':tid' => $tid,
));
while ($file = $result
->fetchObject()) {
if ($res = db_query("SELECT weight FROM {tft_folder_content_weight} WHERE id = :nid AND type = 'node'", array(
':nid' => $file->nid,
))) {
$weight = $res
->fetchField();
}
$content[] = array(
'id' => $file->nid,
'type' => 'node',
'weight' => !empty($weight) ? $weight : 0,
);
}
usort($content, '_tft_array_weight_sort');
return $content;
}