| [ Index ] |
PHP Cross Reference of Drupal 6 (yi-drupal) |
[Summary view] [Print] [Text view]
1 <?php 2 /** 3 * @file 4 * Contains the php code argument validator plugin. 5 */ 6 7 /** 8 * Provide PHP code to validate whether or not an argument is ok. 9 * 10 * @ingroup views_argument_validate_plugins 11 */ 12 class views_plugin_argument_validate_php extends views_plugin_argument_validate { 13 var $option_name = 'validate_argument_php'; 14 15 function validate_form(&$form, &$form_state) { 16 $form[$this->option_name] = array( 17 '#type' => 'textarea', 18 '#title' => t('PHP validate code'), 19 '#default_value' => $this->get_argument(), 20 '#description' => t('Enter PHP code that returns TRUE or FALSE. No return is the same as FALSE, so be SURE to return something if you do not want to declare the argument invalid. Do not use <?php ?>. The argument to validate will be "$argument" and the view will be "$view". You may change the argument by setting "$handler->argument".'), 21 '#process' => array('views_process_dependency'), 22 '#dependency' => array('edit-options-validate-type' => array($this->id)), 23 ); 24 25 $this->check_access($form); 26 } 27 28 /** 29 * Only let users with PHP block visibility permissions set/modify this 30 * validate plugin. 31 */ 32 function access() { 33 return user_access('use PHP for block visibility'); 34 } 35 36 function validate_argument($argument) { 37 // set up variables to make it easier to reference during the argument. 38 $view = &$this->view; 39 $handler = &$this->argument; 40 41 ob_start(); 42 $result = eval($this->argument->options[$this->option_name]); 43 ob_end_clean(); 44 return $result; 45 } 46 } 47
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 |