| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @file 4 * Contains the numeric argument handler. 5 */ 6 7 /** 8 * Basic argument handler for arguments that are numeric. Incorporates 9 * break_phrase. 10 * 11 * @ingroup views_argument_handlers 12 */ 13 class views_handler_argument_numeric extends views_handler_argument { 14 function option_definition() { 15 $options = parent::option_definition(); 16 17 $options['break_phrase'] = array('default' => FALSE); 18 $options['not'] = array('default' => FALSE); 19 20 return $options; 21 } 22 23 function options_form(&$form, &$form_state) { 24 parent::options_form($form, $form_state); 25 26 // allow + for or, , for and 27 $form['break_phrase'] = array( 28 '#type' => 'checkbox', 29 '#title' => t('Allow multiple terms per argument.'), 30 '#description' => t('If selected, users can enter multiple arguments in the form of 1+2+3 or 1,2,3.'), 31 '#default_value' => !empty($this->options['break_phrase']), 32 ); 33 34 $form['not'] = array( 35 '#type' => 'checkbox', 36 '#title' => t('Exclude the argument'), 37 '#description' => t('If selected, the numbers entered in the argument will be excluded rather than limiting the view.'), 38 '#default_value' => !empty($this->options['not']), 39 ); 40 } 41 42 function title() { 43 if (!$this->argument) { 44 return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : t('Uncategorized'); 45 } 46 47 if (!empty($this->options['break_phrase'])) { 48 views_break_phrase($this->argument, $this); 49 } 50 else { 51 $this->value = array($this->argument); 52 $this->operator = 'or'; 53 } 54 55 if (empty($this->value)) { 56 return !empty($this->definition['empty field name']) ? $this->definition['empty field name'] : t('Uncategorized'); 57 } 58 59 if ($this->value === array(-1)) { 60 return !empty($this->definition['invalid input']) ? $this->definition['invalid input'] : t('Invalid input'); 61 } 62 63 return implode($this->operator == 'or' ? ' + ' : ', ', $this->title_query()); 64 } 65 66 /** 67 * Override for specific title lookups. 68 */ 69 function title_query() { 70 return $this->value; 71 } 72 73 function query() { 74 $this->ensure_my_table(); 75 76 if (!empty($this->options['break_phrase'])) { 77 views_break_phrase($this->argument, $this); 78 } 79 else { 80 $this->value = array($this->argument); 81 } 82 83 $null_check = empty($this->options['not']) ? '' : " OR $this->table_alias.$this->real_field IS NULL"; 84 85 if (count($this->value) > 1) { 86 $operator = empty($this->options['not']) ? 'IN' : 'NOT IN'; 87 $placeholders = implode(', ', array_fill(0, sizeof($this->value), '%d')); 88 $this->query->add_where(0, "$this->table_alias.$this->real_field $operator ($placeholders) $null_check", $this->value); 89 } 90 else { 91 $operator = empty($this->options['not']) ? '=' : '!='; 92 $this->query->add_where(0, "$this->table_alias.$this->real_field $operator %d $null_check", $this->argument); 93 } 94 } 95 }
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 |