[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/views/plugins/ -> views_plugin_argument_default_php.inc (source)

   1  <?php
   2  // $Id: views_plugin_argument_default_php.inc,v 1.1 2008/09/03 19:21:30 merlinofchaos Exp $
   3  /**
   4   * @file
   5   * Contains the php code argument default plugin.
   6   */
   7  
   8  /**
   9   * Default argument plugin to provide a PHP code block.
  10   */
  11  class views_plugin_argument_default_php extends views_plugin_argument_default {
  12    var $option_name = 'default_argument_php';
  13  
  14    function argument_form(&$form, &$form_state) {
  15      $form[$this->option_name] = array(
  16        '#type' => 'textarea',
  17        '#title' => t('PHP argument code'),
  18        '#default_value' => $this->get_argument(TRUE), // the true forces it raw.
  19        '#process' => array('views_process_dependency'),
  20        '#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.'),
  21        '#dependency' => array(
  22          'radio:options[default_action]' => array('default'),
  23          'radio:options[default_argument_type]' => array($this->id)
  24        ),
  25        '#dependency_count' => 2,
  26      );
  27  
  28      $this->check_access($form);
  29    }
  30  
  31    /**
  32     * Only let users with PHP block visibility permissions set/modify this
  33     * default plugin.
  34     */
  35    function access() {
  36      return user_access('use PHP for block visibility');
  37    }
  38  
  39    function get_argument($raw = FALSE) {
  40      if ($raw) {
  41        return parent::get_argument();
  42      }
  43  
  44      // set up variables to make it easier to reference during the argument.
  45      $view = &$this->view;
  46      $argument = &$this->argument;
  47      ob_start();
  48      $result = eval($this->argument->options[$this->option_name]);
  49      ob_end_clean();
  50      return $result;
  51    }
  52  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7