Projet

Général

Profil

Paste
Télécharger (1,07 ko) Statistiques
| Branche: | Révision:

root / drupal7 / sites / all / modules / ctools / plugins / arguments / vid.inc @ c304a780

1
<?php
2

    
3
/**
4
 * @file
5
 * Plugin to provide an argument handler for a vocabulary id.
6
 */
7

    
8
/**
9
 * Plugins are described by creating a $plugin array which will be used
10
 * by the system that includes this file.
11
 */
12
$plugin = array(
13
  'title' => t("Vocabulary: ID"),
14
  // Keyword to use for %substitution.
15
  'keyword' => 'vocabulary',
16
  'description' => t('Creates a vocabulary context from a vocabulary ID argument.'),
17
  'context' => 'ctools_vid_context',
18
  'placeholder form' => array(
19
    '#type' => 'textfield',
20
    '#description' => t('Enter the vocabulary ID for this argument'),
21
  ),
22
  'no ui' => TRUE,
23
);
24

    
25
/**
26
 * Discover if this argument gives us the vocabulary we crave.
27
 */
28
function ctools_vid_context($arg = NULL, $conf = NULL, $empty = FALSE) {
29
  // If unset it wants a generic, unfilled context.
30
  if ($empty) {
31
    return ctools_context_create_empty('entity:taxonomy_vocabulary');
32
  }
33

    
34
  if (!is_numeric($arg)) {
35
    return NULL;
36
  }
37

    
38
  $vocabulary = taxonomy_vocabulary_load($arg);
39
  if (!$vocabulary) {
40
    return NULL;
41
  }
42

    
43
  return ctools_context_create('vocabulary', $vocabulary);
44
}