function tft_folder_content in Taxonomy File Tree 7.2
Same name and namespace in other branches
- 7 tft.module \tft_folder_content()
Loads the given folder content.
Can optionally load only child folders. By default, will load folders and files.
Parameters
int $tid:
bool $only_terms = FALSE:
Return value
array
Related topics
3 calls to tft_folder_content()
- 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 - Construct the folder tree recursively.
File
- ./
tft.module, line 611 - Hook implementations and module logic for TFT.
Code
function tft_folder_content($tid, $only_terms = FALSE) {
$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 ORDER BY td.name", array(
':ptid' => $tid,
':vid' => variable_get('tft_vocabulary_vid', 0),
));
while ($term = $result
->fetchObject()) {
if (variable_get('tft_use_weight', 0) && ($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' => !empty($weight) ? $weight : 0,
);
}
if ($only_terms) {
if (variable_get('tft_use_weight', 0)) {
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 ORDER BY v.title", array(
':tid' => $tid,
));
while ($file = $result
->fetchObject()) {
if (variable_get('tft_use_weight', 0) && ($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,
);
}
if (variable_get('tft_use_weight', 0)) {
usort($content, '_tft_array_weight_sort');
}
return $content;
}