• Main Page
  • Related Pages
  • Modules
  • Classes
  • Files
  • File List
  • File Members

plugins/views_plugin_argument_default_php.inc

Go to the documentation of this file.
00001 <?php
00010 class views_plugin_argument_default_php extends views_plugin_argument_default {
00011   function option_definition() {
00012     $options = parent::option_definition();
00013     $options['code'] = array('default' => '');
00014 
00015     return $options;
00016   }
00017 
00018   function options_form(&$form, &$form_state) {
00019     parent::options_form($form, $form_state);
00020     $form['code'] = array(
00021       '#type' => 'textarea',
00022       '#title' => t('PHP contextual filter code'),
00023       '#default_value' => $this->options['code'],
00024       '#description' => t('Enter PHP code that returns a value to use for this filter. Do not use &lt;?php ?&gt;. You must return only a single value for just this filter. Some variables are available: the view object will be "$view". The argument handler will be "$argument", for example you may change the title used for substitutions for this argument by setting "argument->validated_title"".'),
00025     );
00026 
00027     // Only do this if using one simple standard form gadget
00028     $this->check_access($form, 'code');
00029   }
00030 
00031   function convert_options(&$options) {
00032     if (!isset($options['code']) && isset($this->argument->options['default_argument_php'])) {
00033       $options['code'] = $this->argument->options['default_argument_php'];
00034     }
00035   }
00036 
00041   function access() {
00042     return user_access('use PHP for settings');
00043   }
00044 
00045   function get_argument() {
00046     // set up variables to make it easier to reference during the argument.
00047     $view = &$this->view;
00048     $argument = &$this->argument;
00049     ob_start();
00050     $result = eval($this->options['code']);
00051     ob_end_clean();
00052     return $result;
00053   }
00054 }

Generated on Sun Feb 26 2012 12:52:51 for Views by  doxygen 1.7.1