| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 3 /** 4 * Field handler to provide a list of items. 5 * 6 * The items are expected to be loaded by a child object during pre_render, 7 * and 'my field' is expected to be the pointer to the items in the list. 8 * 9 * Items to render should be in a list in $this->items 10 * 11 * @ingroup views_field_handlers 12 */ 13 class views_handler_field_prerender_list extends views_handler_field { 14 function option_definition() { 15 $options = parent::option_definition(); 16 17 $options['type'] = array('default' => 'separator'); 18 $options['separator'] = array('default' => ', '); 19 20 return $options; 21 } 22 23 function options_form(&$form, &$form_state) { 24 parent::options_form($form, $form_state); 25 $form['type'] = array( 26 '#type' => 'radios', 27 '#title' => t('Display type'), 28 '#options' => array( 29 'ul' => t('Unordered list'), 30 'ol' => t('Ordered list'), 31 'separator' => t('Simple separator'), 32 ), 33 '#default_value' => $this->options['type'], 34 ); 35 36 $form['separator'] = array( 37 '#type' => 'textfield', 38 '#title' => t('Separator'), 39 '#default_value' => $this->options['separator'], 40 '#process' => array('views_process_dependency'), 41 '#dependency' => array('radio:options[type]' => array('separator')), 42 ); 43 } 44 45 /** 46 * Render the field. 47 * 48 * This function is deprecated, but left in for older systems that have not 49 * yet or won't update their prerender list fields. If a render_item method 50 * exists, this will not get used by advanced_render. 51 */ 52 function render($values) { 53 $field = $values->{$this->field_alias}; 54 if (!empty($this->items[$field])) { 55 if ($this->options['type'] == 'separator') { 56 return implode(check_plain($this->options['separator']), $this->items[$field]); 57 } 58 else { 59 return theme('item_list', $this->items[$field], NULL, $this->options['type']); 60 } 61 } 62 } 63 64 /** 65 * Render all items in this field together. 66 * 67 * When using advanced render, each possible item in the list is rendered 68 * individually. Then the items are all pasted together. 69 */ 70 function render_items($items) { 71 if (!empty($items)) { 72 if ($this->options['type'] == 'separator') { 73 return implode(check_plain($this->options['separator']), $items); 74 } 75 else { 76 return theme('item_list', $items, NULL, $this->options['type']); 77 } 78 } 79 } 80 81 /** 82 * Return an array of items for the field. 83 * 84 * Items should be stored in the result array, if possible, as an array 85 * with 'value' as the actual displayable value of the item, plus 86 * any items that might be found in the 'alter' options array for 87 * creating links, such as 'path', 'fragment', 'query' etc, such a thing 88 * is to be made. Additionally, items that might be turned into tokens 89 * should also be in this array. 90 */ 91 function get_items($values) { 92 $field = $values->{$this->field_alias}; 93 if (!empty($this->items[$field])) { 94 return $this->items[$field]; 95 } 96 97 return array(); 98 } 99 100 /** 101 * Determine if advanced rendering is allowed. 102 * 103 * By default, advanced rendering will NOT be allowed if the class 104 * inheriting from this does not implement a 'render_items' method. 105 */ 106 function allow_advanced_render() { 107 // Note that the advanced render bits also use the presence of 108 // this method to determine if it needs to render items as a list. 109 return method_exists($this, 'render_item'); 110 } 111 }
title
Description
Body
title
Description
Body
title
Description
Body
title
Body
| Generated: Mon Jul 9 18:01:44 2012 | Cross-referenced by PHPXref 0.7 |