function taxonomy_manager_tree_process_elements in Taxonomy Manager 6
Same name and namespace in other branches
- 5 taxonomy_manager.module \taxonomy_manager_tree_process_elements()
- 6.2 taxonomy_manager.module \taxonomy_manager_tree_process_elements()
- 7 taxonomy_manager.module \taxonomy_manager_tree_process_elements()
Processes the tree form element
Parameters
$element:
Return value
the tree element
1 string reference to 'taxonomy_manager_tree_process_elements'
- taxonomy_manager_elements in ./
taxonomy_manager.module - Implementation of hook_elements
File
- ./
taxonomy_manager.module, line 315 - Taxonomy Manager
Code
function taxonomy_manager_tree_process_elements($element) {
global $taxonomy_manager_existing_ids;
//TEMP: seems like this functions gets called twice in preview and cause problem because of adding the settings to js twice
$taxonomy_manager_existing_ids = is_array($taxonomy_manager_existing_ids) ? $taxonomy_manager_existing_ids : array();
$module_path = drupal_get_path('module', 'taxonomy_manager') . '/';
$id = form_clean_id(implode('-', $element['#parents']));
$vid = $element['#vid'];
if (!$element['#siblings_page'] && !in_array($id, $taxonomy_manager_existing_ids)) {
$taxonomy_manager_existing_ids[$id] = $id;
drupal_add_css($module_path . 'css/taxonomy_manager.css');
drupal_add_js($module_path . 'js/tree.js');
drupal_add_js(array(
'siblingsForm' => array(
'url' => url('admin/content/taxonomy_manager/siblingsform'),
'modulePath' => $module_path,
),
), 'setting');
drupal_add_js(array(
'childForm' => array(
'url' => url('admin/content/taxonomy_manager/childform'),
'modulePath' => $module_path,
),
), 'setting');
drupal_add_js(array(
'taxonomy_manager' => array(
'modulePath' => url($module_path) == $module_path ? $module_path : base_path() . $module_path,
),
), 'setting');
drupal_add_js(array(
'taxonomytree' => array(
'id' => $id,
'vid' => $vid,
),
), 'setting');
}
if (!is_array($element['#operations'])) {
$opertions_callback = implode('_', $element['#parents']) . '_operations';
if (function_exists($opertions_callback)) {
$element['#operations_callback'] = $opertions_callback;
}
}
if (!isset($element['#link'])) {
$link_callback = implode('_', $element['#parents']) . '_link';
if (function_exists($link_callback)) {
$element['#link_callback'] = $link_callback;
}
}
$tree = _taxonomy_manager_tree_get_item($element['#vid'], $element['#parent'], $element['#pager'], $element['#siblings_page'], $element['#search_string']);
if ($element['#pager'] && !($element['#parent'] || $element['#siblings_page'])) {
$element['pager'] = array(
'#value' => theme('pager', NULL, variable_get('taxonomy_manager_pager_tree_page_size', 50)),
);
}
$element['#default_value'] = is_array($element['#default_value']) ? $element['#default_value'] : array();
$element['#multiple'] = isset($element['#multiple']) ? $element['#multiple'] : TRUE;
$element['#add_term_info'] = isset($element['#add_term_info']) ? $element['#add_term_info'] : TRUE;
$element['#tree'] = TRUE;
$element['#id'] = $id;
$element['#element_validate'] = array(
'taxonomy_manager_tree_validate',
);
$element['#required'] = isset($element['#tree_is_required']) ? $element['#tree_is_required'] : FALSE;
$terms_to_expand = array();
if (count($element['#default_value']) && !$element['#expand_all']) {
$terms_to_expand = taxonomy_manager_tree_get_terms_to_expand($tree, $element['#default_value'], $element['#multiple']);
}
taxonomy_manager_tree_build_form($index = 0, $tree, $element['#elements'], $element, $element['#parents'], !$element['#pager'], $element['#siblings_page'], $element['#default_value'], $element['#multiple'], $terms_to_expand);
return $element;
}