source: sipes/modules_contrib/views/plugins/views_plugin_argument_default_php.inc @ a8b1f3f

stableversion-3.0
Last change on this file since a8b1f3f was 59029b2, checked in by José Gregorio Puentes <jpuentes@…>, 8 años ago

se actualizo la version del modulo views

  • Propiedad mode establecida a 100644
File size: 1.8 KB
Línea 
1<?php
2/**
3 * @file
4 * Contains the php code argument default plugin.
5 */
6
7/**
8 * Default argument plugin to provide a PHP code block.
9 */
10class views_plugin_argument_default_php extends views_plugin_argument_default {
11  function option_definition() {
12    $options = parent::option_definition();
13    $options['code'] = array('default' => '');
14
15    return $options;
16  }
17
18  function options_form(&$form, &$form_state) {
19    $form['code'] = array(
20      '#type' => 'textarea',
21      '#title' => t('PHP argument code'),
22      '#default_value' => $this->options['code'],
23      '#process' => array('views_process_dependency'),
24      '#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. 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"".'),
25    );
26
27    // Only do this if using one simple standard form gadget
28    $this->check_access($form, 'code');
29  }
30
31  function convert_options(&$options) {
32    if (!isset($options['code']) && isset($this->argument->options['default_argument_php'])) {
33      $options['code'] = $this->argument->options['default_argument_php'];
34    }
35  }
36
37  /**
38   * Only let users with PHP block visibility permissions set/modify this
39   * default plugin.
40   */
41  function access() {
42    return user_access('use PHP for block visibility');
43  }
44
45  function get_argument() {
46    // set up variables to make it easier to reference during the argument.
47    $view = &$this->view;
48    $argument = &$this->argument;
49    ob_start();
50    $result = eval($this->options['code']);
51    ob_end_clean();
52    return $result;
53  }
54}
Nota: Vea TracBrowser para ayuda de uso del navegador del repositorio.