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

Diff of /contributions/modules/views/plugins/views_plugin_argument_default_php.inc

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

revision 1.1 by merlinofchaos, Wed Sep 3 19:21:30 2008 UTC revision 1.1.2.1 by merlinofchaos, Thu Nov 26 00:35:16 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: comment.views_default.inc,v 1.6 2008/06/10 21:30:43 merlinofchaos Exp $  // $Id: views_plugin_argument_default_php.inc,v 1.1 2008/09/03 19:21:30 merlinofchaos Exp $
3  /**  /**
4   * @file   * @file
5   * Contains the php code argument default plugin.   * Contains the php code argument default plugin.
# Line 9  Line 9 
9   * Default argument plugin to provide a PHP code block.   * Default argument plugin to provide a PHP code block.
10   */   */
11  class views_plugin_argument_default_php extends views_plugin_argument_default {  class views_plugin_argument_default_php extends views_plugin_argument_default {
12    var $option_name = 'default_argument_php';    function option_definition() {
13        $options = parent::option_definition();
14        $options['code'] = array('default' => '');
15    
16    function argument_form(&$form, &$form_state) {      return $options;
17      $form[$this->option_name] = array(    }
18    
19      function options_form(&$form, &$form_state) {
20        $form['code'] = array(
21        '#type' => 'textarea',        '#type' => 'textarea',
22        '#title' => t('PHP argument code'),        '#title' => t('PHP argument code'),
23        '#default_value' => $this->get_argument(TRUE), // the true forces it raw.        '#default_value' => $this->options['code'],
24        '#process' => array('views_process_dependency'),        '#process' => array('views_process_dependency'),
25        '#description' => t('Enter PHP code that returns a value to use for this argument. Do not use &lt;?php ?&gt;. You must return only a single value for just this argument.'),        '#description' => t('Enter PHP code that returns a value to use for this argument. Do not use &lt;?php ?&gt;. You must return only a single value for just this argument.'),
       '#dependency' => array(  
         'radio:options[default_action]' => array('default'),  
         'radio:options[default_argument_type]' => array($this->id)  
       ),  
       '#dependency_count' => 2,  
26      );      );
27    
28      $this->check_access($form);      // Only do this if using one simple standard form gadget
29        $this->check_access($form, 'code');
30      }
31    
32      function convert_options(&$options) {
33        if (!isset($options['code']) && isset($this->argument->options['default_argument_php'])) {
34          $options['code'] = $this->argument->options['default_argument_php'];
35        }
36    }    }
37    
38    /**    /**
# Line 36  class views_plugin_argument_default_php Line 43  class views_plugin_argument_default_php
43      return user_access('use PHP for block visibility');      return user_access('use PHP for block visibility');
44    }    }
45    
46    function get_argument($raw = FALSE) {    function get_argument() {
     if ($raw) {  
       return parent::get_argument();  
     }  
   
47      // set up variables to make it easier to reference during the argument.      // set up variables to make it easier to reference during the argument.
48      $view = &$this->view;      $view = &$this->view;
49      $argument = &$this->argument;      $argument = &$this->argument;
50      ob_start();      ob_start();
51      $result = eval($this->argument->options[$this->option_name]);      $result = eval($this->options['code']);
52      ob_end_clean();      ob_end_clean();
53      return $result;      return $result;
54    }    }

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.1.2.1

  ViewVC Help
Powered by ViewVC 1.1.3