You are here

function context_condition_node_taxonomy::condition_form in Context 7.3

Same name and namespace in other branches
  1. 6.3 plugins/context_condition_node_taxonomy.inc \context_condition_node_taxonomy::condition_form()
  2. 6 plugins/context_condition_node_taxonomy.inc \context_condition_node_taxonomy::condition_form()

Condition form.

Overrides context_condition::condition_form

File

plugins/context_condition_node_taxonomy.inc, line 21

Class

context_condition_node_taxonomy
Expose node taxonomy terms as a context condition.

Code

function condition_form($context) {
  $form = parent::condition_form($context);
  $form['#type'] = 'select';
  $form['#size'] = 12;
  $form['#multiple'] = TRUE;
  $vocabularies = taxonomy_get_vocabularies();
  $options = array();
  foreach ($vocabularies as $vid => $vocabulary) {
    $tree = taxonomy_get_tree($vid);
    if ($tree && count($tree) > 0) {
      $options[$vocabulary->name] = array();
      foreach ($tree as $term) {
        $options[$vocabulary->name][$term->tid] = str_repeat('-', $term->depth) . $term->name;
      }
    }
  }
  $form['#options'] = $options;
  return $form;
}