| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: vocabulary.inc,v 1.3.2.3 2010/07/05 22:48:34 merlinofchaos Exp $ 3 4 /** 5 * @file 6 * 7 * Plugin to provide a vocabulary context 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("Taxonomy vocabulary"), 16 'description' => t('A single taxonomy vocabulary object.'), 17 'context' => 'ctools_context_create_vocabulary', 18 'settings form' => 'ctools_context_vocabulary_settings_form', 19 'settings form validate' => 'ctools_context_vocabulary_settings_form_validate', 20 'keyword' => 'vocabulary', 21 'context name' => 'vocabulary', 22 ); 23 24 /** 25 * It's important to remember that $conf is optional here, because contexts 26 * are not always created from the UI. 27 */ 28 function ctools_context_create_vocabulary($empty, $data = NULL, $conf = FALSE) { 29 $context = new ctools_context('vocabulary'); 30 $context->plugin = 'vocabulary'; 31 32 if ($empty) { 33 return $context; 34 } 35 36 if ($conf && isset($data['vid'])) { 37 $data = taxonomy_vocabulary_load($data['vid']); 38 } 39 40 if (!empty($data)) { 41 $context->data = $data; 42 $context->title = $data->name; 43 $context->argument = $data->vid; 44 return $context; 45 } 46 } 47 48 function ctools_context_vocabulary_settings_form($conf) { 49 $options = array(); 50 51 foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) { 52 $options[$vid] = $vocabulary->name; 53 } 54 55 $form['vid'] = array( 56 '#title' => t('Vocabulary'), 57 '#type' => 'select', 58 '#options' => $options, 59 '#default_value' => isset($conf['vid']) ? $conf['vid'] : array(), 60 '#prefix' => '<div class="clear-block">', 61 '#suffix' => '</div>', 62 '#description' => t('Select the vocabulary for this form.'), 63 ); 64 65 return $form; 66 } 67
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Thu Mar 24 11:18:33 2011 | Cross-referenced by PHPXref 0.7 |