/[drupal]/contributions/modules/views/plugins/views_plugin_row_fields.inc
ViewVC logotype

Contents of /contributions/modules/views/plugins/views_plugin_row_fields.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph


Revision 1.2 - (show annotations) (download) (as text)
Wed Jul 1 22:52:41 2009 UTC (4 months, 3 weeks ago) by merlinofchaos
Branch: MAIN
CVS Tags: DRUPAL-6--2-7, HEAD
Branch point for: DRUPAL-6--2, DRUPAL-7--3
Changes since 1.1: +9 -1 lines
File MIME type: text/x-php
#480162: Fields row style now contains option to hide empty fields.
1 <?php
2 // $Id: views_plugin_row_fields.inc,v 1.1 2008/09/03 19:21:30 merlinofchaos Exp $
3 /**
4 * @file
5 * Contains the base row style plugin.
6 */
7
8 /**
9 * The basic 'fields' row plugin
10 *
11 * This displays fields one after another, giving options for inline
12 * or not.
13 *
14 * @ingroup views_row_plugins
15 */
16 class views_plugin_row_fields extends views_plugin_row {
17 function option_definition() {
18 $options = parent::option_definition();
19
20 $options['inline'] = array('default' => array());
21 $options['separator'] = array('default' => '');
22 $options['hide_empty'] = array('default' => FALSE);
23 return $options;
24 }
25
26 /**
27 * Provide a form for setting options.
28 */
29 function options_form(&$form, &$form_state) {
30 $options = array();
31 foreach ($this->display->handler->get_handlers('field') as $field => $handler) {
32 $options[$field] = $handler->ui_name();
33 }
34
35 if (empty($this->options['inline'])) {
36 $this->options['inline'] = array();
37 }
38
39 $form['inline'] = array(
40 '#type' => 'checkboxes',
41 '#title' => t('Inline fields'),
42 '#options' => $options,
43 '#default_value' => $this->options['inline'],
44 '#description' => t('Inline fields will be displayed next to each other rather than one after another.'),
45 );
46
47 $form['separator'] = array(
48 '#title' => t('Separator'),
49 '#type' => 'textfield',
50 '#size' => 10,
51 '#default_value' => isset($this->options['separator']) ? $this->options['separator'] : '',
52 '#description' => t('The separator may be placed between inline fields to keep them from squishing up next to each other. You can use HTML in this field.'),
53 );
54
55 $form['hide_empty'] = array(
56 '#type' => 'checkbox',
57 '#title' => t('Hide empty fields'),
58 '#default_value' => $this->options['hide_empty'],
59 '#description' => t('Do not display fields, labels or markup for fields that are empty.'),
60 );
61 }
62
63 /**
64 * Perform any necessary changes to the form values prior to storage.
65 * There is no need for this function to actually store the data.
66 */
67 function options_submit($form, &$form_state) {
68 $form_state['values']['row_options']['inline'] = array_filter($form_state['values']['row_options']['inline']);
69 }
70 }
71

  ViewVC Help
Powered by ViewVC 1.1.2