5 * Contains the php code argument default plugin.
9 * Default argument plugin to provide a PHP code block.
11 * @ingroup views_argument_default_plugins
13 class views_plugin_argument_default_php extends views_plugin_argument_default {
14 function option_definition() {
15 $options = parent::option_definition();
16 $options['code'] = array('default' => '');
21 function options_form(&$form, &$form_state) {
22 parent::options_form($form, $form_state);
23 $form['code'] = array(
24 '#type' => 'textarea',
25 '#title' => t('PHP contextual filter code'),
26 '#default_value' => $this->options['code'],
27 '#description' => t('Enter PHP code that returns a value to use for this filter. Do not use <?php ?>. 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"".'),
30 // Only do this if using one simple standard form gadget
31 $this->check_access($form, 'code');
34 function convert_options(&$options) {
35 if (!isset($options['code']) && isset($this->argument->options['default_argument_php'])) {
36 $options['code'] = $this->argument->options['default_argument_php'];
41 * Only let users with PHP block visibility permissions set/modify this
45 return user_access('use PHP for settings');
48 function get_argument() {
49 // set up variables to make it easier to reference during the argument.
51 $argument = &$this->argument;
53 $result = eval($this->options['code']);