You are here

function taxonomy_manager_tree_process_elements in Taxonomy Manager 5

Same name and namespace in other branches
  1. 6.2 taxonomy_manager.module \taxonomy_manager_tree_process_elements()
  2. 6 taxonomy_manager.module \taxonomy_manager_tree_process_elements()
  3. 7 taxonomy_manager.module \taxonomy_manager_tree_process_elements()

Processes the tree form element

Parameters

$element:

Return value

the tree element

File

./taxonomy_manager.module, line 1623
Taxonomy Manager

Code

function taxonomy_manager_tree_process_elements($element) {
  $module_path = drupal_get_path('module', 'taxonomy_manager') . '/';
  $id = form_clean_id(implode('-', $element['#parents']));
  $vid = $element['#vid'];
  if (!$element['#parent'] && !$element['#siblings_page']) {
    drupal_add_css($module_path . 'css/taxonomy_manager.css');
    drupal_add_js($module_path . 'js/tree.js');
    drupal_add_js($module_path . 'js/childForm.js');
    drupal_add_js($module_path . 'js/siblingsForm.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'] = $opertions_callback();
    }
  }
  if (!isset($element['#link'])) {
    $link_callback = implode('_', $element['#parents']) . '_link';
    if (function_exists($link_callback)) {
      $element['#link'] = $link_callback($vid);
    }
  }
  $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['#tree'] = TRUE;
  $element['#id'] = $id;
  $element['#validate'] = array(
    'taxonomy_manager_tree_validate' => array(),
  );
  $element['selected_terms'] = array(
    '#type' => 'value',
    '#value' => array(),
  );
  taxonomy_manager_tree_build_form($index = 0, $tree, $element['#elements'], $element, $element['#parents'], !$element['#pager'], $element['#siblings_page']);
  return $element;
}