You are here

function taxonomy_patterns_get_arguments in Patterns 7

File

patterns_components/components/taxonomy.inc, line 75
Patterns component for taxonomy vocabularies and terms.

Code

function taxonomy_patterns_get_arguments($action, $tag, $form_id, &$loop = FALSE) {
  static $i = -1;
  $i++;
  if ($tag == 'vocabulary' || $tag == 'vocabulary_extract_all') {
    $vocabulary = taxonomy_get_vocabularies();
    if ($tag == 'vocabulary' && $action == PATTERNS_MODIFY && $form_id == 'taxonomy_form_vocabulary') {
      return array(
        array_pop($vocabulary),
      );
    }
    elseif ($tag == 'vocabulary_extract_all') {
      $loop = TRUE;
      $return = array();
      foreach ($vocabulary as $voc) {
        array_push($return, array(
          $voc,
        ));
      }
      return $return;
    }
  }
  elseif ($tag == 'term' || $tag == 'term_extract_all') {
    $terms = entity_load('taxonomy_term');
    if ($tag == 'vocabulary' && $action == PATTERNS_MODIFY && $form_id == 'taxonomy_form_vocabulary') {
      return array(
        array_pop($terms),
      );
    }
    elseif ($tag == 'term_extract_all') {
      $loop = TRUE;
      $return = array();
      foreach ($terms as $term) {
        array_push($return, array(
          $term,
        ));
      }
      return $return;
    }
  }
}