function _tft_manage_folders_form in Taxonomy File Tree 7
Same name and namespace in other branches
- 7.2 includes/tft.pages.inc \_tft_manage_folders_form()
Form helper. Flattens the terms tree and creates the form elements.
Parameters
array $tree: The current tree level to be rendered
array &$form: A reference to the form array
int $root_depth = 0: The depth of the root term
int $root_tid = NULL: The root tid
bool $use_hierarchy = TRUE: Allow users to change the hierarchy.
bool $use_wight = FALSE: Allow users to reorder elements.
See also
1 call to _tft_manage_folders_form()
- tft_manage_folders_form in ./
tft.admin.inc - Reorganise terms under the given term tid.
File
- ./
tft.admin.inc, line 135
Code
function _tft_manage_folders_form($tree, &$form, $root_depth = 0, $root_tid = NULL, $use_hierarchy = TRUE, $use_weight = FALSE) {
if (!isset($form['#use_hierarchy'])) {
$form['#use_hierarchy'] = $use_hierarchy;
$form['#use_weight'] = $use_weight;
}
foreach ($tree as $data) {
if ($root_tid && isset($data['tid']) && $data['tid'] == tft_get_archive_tid($root_tid)) {
continue;
}
$data['depth'] = isset($data['tid']) ? tft_get_depth($data['tid']) - $root_depth : tft_get_depth($data['parent']) - $root_depth + 1;
$key = 'tft-admin-' . (isset($data['nid']) ? 'node-' . $data['nid'] : 'term-' . $data['tid']);
$form['table'][$key] = array();
$form['table'][$key]['name'] = array(
'#type' => 'textfield',
'#default_value' => $data['name'],
'#maxlength' => 255,
'#required' => TRUE,
);
if (isset($data['type']) && $data['type'] == 'node') {
$form['table'][$key]['name']['#required'] = FALSE;
$form['table'][$key]['name']['#attributes'] = array(
'disabled' => 'disabled',
);
}
if ($use_hierarchy) {
$form['table'][$key]['parent'] = array(
'#type' => 'textfield',
'#default_value' => $data['parent'],
'#size' => 6,
'#attributes' => array(
'class' => array(
'taxonomy_term_hierarchy-parent',
),
),
);
}
$form['table'][$key]['id'] = array(
'#type' => 'hidden',
'#default_value' => isset($data['nid']) ? $data['nid'] : $data['tid'],
'#attributes' => array(
'class' => array(
'taxonomy_term_hierarchy-tid',
),
),
);
$form['table'][$key]['type'] = array(
'#type' => 'hidden',
'#value' => isset($data['type']) ? $data['type'] : 'term',
);
if ($use_hierarchy) {
$form['table'][$key]['depth'] = array(
'#type' => 'value',
'#value' => $data['depth'],
);
}
if ($use_weight) {
$form['table'][$key]['weight'] = array(
'#type' => 'weight',
'#delta' => 50,
'#default_value' => $data['weight'],
'#attributes' => array(
'class' => array(
'taxonomy_term_hierarchy-weight',
),
),
);
}
if (isset($data['children'])) {
_tft_manage_folders_form($data['children'], $form, $root_depth, $root_tid, $use_hierarchy, $use_weight);
}
}
}