vocabulary.inc
Go to the documentation of this file.00001 <?php
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011 function panels_vocabulary_panels_contexts() {
00012 $args['vocabulary'] = array(
00013 'title' => t("Taxonomy vocabulary"),
00014 'description' => t('A single taxonomy vocabulary object.'),
00015 'context' => 'panels_context_create_vocabulary',
00016 'settings form' => 'panels_context_vocabulary_settings_form',
00017 'settings form validate' => 'panels_context_vocabulary_settings_form_validate',
00018 'keyword' => 'vocabulary',
00019 'context name' => 'vocabulary',
00020 );
00021 return $args;
00022 }
00023
00024
00025
00026
00027
00028 function panels_context_create_vocabulary($empty, $data = NULL, $conf = FALSE) {
00029 $context = new panels_context('vocabulary');
00030 $context->plugin = 'vocabulary';
00031
00032 if ($empty) {
00033 return $context;
00034 }
00035
00036 if ($conf) {
00037 $data = taxonomy_get_vocabulary($data['vid']);
00038 }
00039
00040 if (!empty($data)) {
00041 $context->data = $data;
00042 $context->title = $data->name;
00043 $context->argument = $data->vid;
00044 return $context;
00045 }
00046 }
00047
00048 function panels_context_vocabulary_settings_form($conf, $external = FALSE) {
00049 $options = array();
00050 if ($external) {
00051 $options[0] = t('External source');
00052 }
00053
00054 foreach (taxonomy_get_vocabularies() as $vid => $vocabulary) {
00055 $options[$vid] = $vocabulary->name;
00056 }
00057
00058 $form['vid'] = array(
00059 '#title' => t('Vocabulary'),
00060 '#type' => 'select',
00061 '#options' => $options,
00062 '#default_value' => $conf['vids'],
00063 '#prefix' => '<div class="clear-block">',
00064 '#suffix' => '</div>',
00065 '#description' => t('Select the vocabulary for this form.'),
00066 );
00067 if ($external) {
00068 $form['vid']['#description'] .= ' ' . t('Select external to require this from an external source (such as a containing panel page).');
00069 }
00070
00071 return $form;
00072 }
00073