[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

/sites/all/modules/ctools/plugins/arguments/ -> vid.inc (source)

   1  <?php
   2  // $Id: vid.inc,v 1.4.2.3 2010/01/29 20:18:25 merlinofchaos Exp $
   3  
   4  /**
   5   * @file
   6   *
   7   * Plugin to provide an argument handler for a vocabulary id
   8   */
   9  
  10  /**
  11   * Plugins are described by creating a $plugin array which will be used
  12   * by the system that includes this file.
  13   */
  14  $plugin = array(
  15    'title' => t("Vocabulary: ID"),
  16    // keyword to use for %substitution
  17    'keyword' => 'vocabulary',
  18    'description' => t('Creates a vocabulary context from a vocabulary ID argument.'),
  19    'context' => 'ctools_vid_context',
  20    'placeholder form' => array(
  21      '#type' => 'textfield',
  22      '#description' => t('Enter the vocabulary ID for this argument'),
  23    ),
  24  );
  25  
  26  /**
  27   * Discover if this argument gives us the vocabulary we crave.
  28   */
  29  function ctools_vid_context($arg = NULL, $conf = NULL, $empty = FALSE) {
  30    // If unset it wants a generic, unfilled context.
  31    if ($empty) {
  32      return ctools_context_create_empty('vocabulary');
  33    }
  34  
  35    if (!is_numeric($arg)) {
  36      return NULL;
  37    }
  38  
  39    $vocabulary = taxonomy_vocabulary_load($arg);
  40    if (!$vocabulary) {
  41      return NULL;
  42    }
  43  
  44    return ctools_context_create('vocabulary', $vocabulary);
  45  }
  46  


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7