1 |
85ad3d82
|
Assos Assos
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
*
|
6 |
|
|
* Plugin to provide an argument handler for a vocabulary id
|
7 |
|
|
*/
|
8 |
|
|
|
9 |
|
|
/**
|
10 |
|
|
* Plugins are described by creating a $plugin array which will be used
|
11 |
|
|
* by the system that includes this file.
|
12 |
|
|
*/
|
13 |
|
|
$plugin = array(
|
14 |
|
|
'title' => t("Vocabulary: ID"),
|
15 |
|
|
// keyword to use for %substitution
|
16 |
|
|
'keyword' => 'vocabulary',
|
17 |
|
|
'description' => t('Creates a vocabulary context from a vocabulary ID argument.'),
|
18 |
|
|
'context' => 'ctools_vid_context',
|
19 |
|
|
'placeholder form' => array(
|
20 |
|
|
'#type' => 'textfield',
|
21 |
|
|
'#description' => t('Enter the vocabulary ID for this argument'),
|
22 |
|
|
),
|
23 |
|
|
'no ui' => TRUE,
|
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('entity:taxonomy_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 |
|
|
}
|