| [ Index ] |
PHP Cross Reference of Drupal 6 (gatewave) |
[Summary view] [Print] [Text view]
1 <?php 2 // $Id: link_views_handler_argument_target.inc,v 1.1.4.3 2010/06/14 15:59:35 jcfiala Exp $ 3 4 /** 5 * @file 6 * Argument handler to filter results by target. 7 */ 8 9 /** 10 * Argument handler to filter results by target. 11 */ 12 class link_views_handler_argument_target extends views_handler_argument { 13 14 /** 15 * Provide a default options form for the argument. 16 */ 17 function options_form(&$form, &$form_state) { 18 $defaults = $this->default_actions(); 19 20 $form['title'] = array( 21 '#prefix' => '<div class="clear-block">', 22 '#suffix' => '</div>', 23 '#type' => 'textfield', 24 '#title' => t('Title'), 25 '#default_value' => $this->options['title'], 26 '#description' => t('The title to use when this argument is present; it will override the title of the view and titles from previous arguments. You can use percent substitution here to replace with argument titles. Use "%1" for the first argument, "%2" for the second, etc.'), 27 ); 28 29 $form['clear_start'] = array( 30 '#value' => '<div class="clear-block">', 31 ); 32 33 $form['defaults_start'] = array( 34 '#value' => '<div class="views-left-50">', 35 ); 36 37 $form['default_action'] = array( 38 '#type' => 'radios', 39 '#title' => t('Action to take if argument is not present'), 40 '#default_value' => $this->options['default_action'], 41 ); 42 43 $form['defaults_stop'] = array( 44 '#value' => '</div>', 45 ); 46 47 $form['wildcard'] = array( 48 '#prefix' => '<div class="views-right-50">', 49 // prefix and no suffix means these two items will be grouped together. 50 '#type' => 'textfield', 51 '#title' => t('Wildcard'), 52 '#size' => 20, 53 '#default_value' => $this->options['wildcard'], 54 '#description' => t('If this value is received as an argument, the argument will be ignored; i.e, "all values"'), 55 ); 56 57 $form['wildcard_substitution'] = array( 58 '#suffix' => '</div>', 59 '#type' => 'textfield', 60 '#title' => t('Wildcard title'), 61 '#size' => 20, 62 '#default_value' => $this->options['wildcard_substitution'], 63 '#description' => t('The title to use for the wildcard in substitutions elsewhere.'), 64 ); 65 66 $form['clear_stop'] = array( 67 '#value' => '</div>', 68 ); 69 70 $options = array(); 71 $validate_options = array(); 72 foreach ($defaults as $id => $info) { 73 $options[$id] = $info['title']; 74 if (empty($info['default only'])) { 75 $validate_options[$id] = $info['title']; 76 } 77 if (!empty($info['form method'])) { 78 $this->{$info['form method']}($form, $form_state); 79 } 80 } 81 82 $form['default_action']['#options'] = $options; 83 84 $form['validate_type'] = array( 85 '#type' => 'select', 86 '#title' => t('Validator'), 87 '#default_value' => $this->options['validate_type'], 88 ); 89 90 $validate_types = array('none' => t('<Basic validation>')); 91 $plugins = views_fetch_plugin_data('argument validator'); 92 foreach ($plugins as $id => $info) { 93 $valid = TRUE; 94 if (!empty($info['type'])) { 95 $valid = FALSE; 96 if (empty($this->definition['validate type'])) { 97 continue; 98 } 99 foreach ((array) $info['type'] as $type) { 100 if ($type == $this->definition['validate type']) { 101 $valid = TRUE; 102 break; 103 } 104 } 105 } 106 107 // If we decide this validator is ok, add it to the list. 108 if ($valid) { 109 $plugin = views_get_plugin('argument validator', $id); 110 if ($plugin) { 111 $plugin->init($this->view, $this, $id); 112 if ($plugin->access()) { 113 $plugin->validate_form($form, $form_state, $id); 114 $validate_types[$id] = $info['title']; 115 } 116 } 117 } 118 } 119 120 asort($validate_types); 121 $form['validate_type']['#options'] = $validate_types; 122 // Show this gadget if *anything* but 'none' is selected 123 124 $form['validate_fail'] = array( 125 '#type' => 'select', 126 '#title' => t('Action to take if argument does not validate'), 127 '#default_value' => $this->options['validate_fail'], 128 '#options' => $validate_options, 129 ); 130 } 131 132 /** 133 * Set up the query for this argument. 134 * 135 * The argument sent may be found at $this->argument. 136 */ 137 function query() { 138 $this->ensure_my_table(); 139 // Because attributes are stored serialized, our only option is to also 140 // serialize the data we're searching for and use LIKE to find similar data. 141 $this->query->add_where(0, $this->table_alias .'.'. $this->real_field ." LIKE '%%%s%'", serialize(array('target' => $this->argument))); 142 } 143 }
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 |