source: sipes/modules_contrib/content_taxonomy/content_taxonomy_options.module @ c43ea01

stableversion-3.0
Last change on this file since c43ea01 was 177a560, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se agrego el directorio de modulos contribuidos de drupal

  • Propiedad mode establecida a 100755
File size: 3.1 KB
Línea 
1<?php
2
3// $Id: content_taxonomy_options.module,v 1.1.4.7.2.4 2008/12/27 11:25:27 mh86 Exp $
4
5/**
6 * @file
7 * Defines a widget type for content_taxonomy for options
8 **/
9
10/**
11 * Implementation of hook_theme().
12 */
13function content_taxonomy_options_theme() {
14  return array(
15    'content_taxonomy_options_widgets_none' => array(
16      'arguments' => array('field' => NULL),
17    ),
18  );
19}
20
21/**
22 * Implementation of hook_widget_info().
23 */
24function content_taxonomy_options_widget_info() {
25  return array(
26    'content_taxonomy_options' => array(
27      'label' => t('Checkboxes/Radios'),
28      'field types' => array('content_taxonomy'),
29      'multiple values' => CONTENT_HANDLE_MODULE,
30      'callbacks' => array(
31        'default value' => CONTENT_CALLBACK_DEFAULT,
32      ),
33    ),
34    'content_taxonomy_select' => array(
35      'label' => t('Select List'),
36      'field types' => array('content_taxonomy'),
37      'multiple values' => CONTENT_HANDLE_MODULE,
38      'callbacks' => array(
39        'default value' => CONTENT_CALLBACK_DEFAULT,
40      ),
41    ),
42  );
43  return $items;
44}
45
46/**
47 * Implementation of hook_widget_settings
48 */
49function content_taxonomy_options_widget_settings($op, $widget) {
50  switch ($op) {
51    case 'form':
52      $form['settings'] = array(
53        '#type' => 'fieldset',
54        '#title' => t('Settings for Options'),
55        '#collapsible' => TRUE,
56        '#weight' => 10,
57      );
58      $form['settings']['show_depth'] = array(
59        '#type' => 'checkbox',
60        '#title' => t('Indent child terms with \' - \' signs'),
61        '#default_value' => is_numeric($widget['show_depth']) ? $widget['show_depth'] : 1,
62        '#description' => t('If this option is checked, a hierarchy gets visualized by indenting child terms, otherwise it\'s a flat list'),
63      );
64      $form['settings']['group_parent'] = array(
65        '#title' => t('Parent term for OptGroups in select fields'),
66        '#type' => 'select',
67        '#default_value' => isset($widget['group_parent']) ? $widget['group_parent'] : 0,
68        '#options' => _content_taxonomy_get_all_terms(),
69        '#description' => t('This settings applies only for select fields. Select a parent term containg the grouping terms. Grouping terms should be parents of the selected terms (from the Global Settings).'),
70      );
71      return $form;
72     
73    case 'save':
74      return array('group_parent', 'show_depth');
75  }
76}
77
78/**
79 * Implementation of hook_widget().
80 */
81function content_taxonomy_options_widget(&$form, &$form_state, $field, $items, $delta = NULL) {
82  $element = array(
83    '#type' => ($field['widget']['type'] == 'content_taxonomy_select') ? 'optionwidgets_select' : 'optionwidgets_buttons',
84    '#default_value' => !empty($items) ? $items : array(),
85  );
86  return $element;
87}
88
89/**
90 *  Theme the label for the empty value for options (for optional radios and single selects).
91 */
92function theme_content_taxonomy_options_widgets_none($field) {
93  switch ($field['widget']['type']) {
94    case 'content_taxonomy_options':
95      return t('N/A');
96    case 'content_taxonomy_select':
97      return t('- None -');
98    default :
99      return '';
100  }
101}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.