[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

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

   1  <?php
   2  // $Id: views_plugin_argument_default.inc,v 1.2 2009/06/01 23:34:55 merlinofchaos Exp $
   3  /**
   4   * @file
   5   * Contains the fixed argument default plugin.
   6   */
   7  
   8  /**
   9   * @defgroup views_argument_default_plugins Views' argument default plugins
  10   * @{
  11   *
  12   * Allow specialized methods of filling in arguments when they aren't
  13   * provided.
  14   *
  15   * @see hook_views_plugins
  16   */
  17  
  18  /**
  19   * The fixed argument default handler; also used as the base.
  20   */
  21  class views_plugin_argument_default extends views_plugin {
  22    var $option_name = 'default_argument_fixed';
  23    /**
  24     * Initialize this plugin with the view and the argument
  25     * it is linked to.
  26     */
  27    function init(&$view, &$argument, $id = NULL) {
  28      $this->view = &$view;
  29      $this->argument = &$argument;
  30      $this->id = $id;
  31    }
  32  
  33    /**
  34     * Determine if the administrator has the privileges to use this
  35     * plugin
  36     */
  37    function access() { return TRUE; }
  38  
  39    function argument_form(&$form, &$form_state) {
  40      $form[$this->option_name] = array(
  41        '#type' => 'textfield',
  42        '#title' => t('Default argument'),
  43        '#default_value' => $this->get_argument(),
  44        '#process' => array('views_process_dependency'),
  45        '#dependency' => array(
  46          'radio:options[default_action]' => array('default'),
  47          'radio:options[default_argument_type]' => array($this->id)
  48        ),
  49        '#dependency_count' => 2,
  50      );
  51  
  52      // Only do this if using one simple standard form gadget
  53      $this->check_access($form);
  54    }
  55  
  56    /**
  57     * If we don't have access to the form but are showing it anyway, ensure that
  58     * the form is safe and cannot be changed from user input.
  59     */
  60    function check_access(&$form) {
  61      if (!$this->access()) {
  62        $form[$this->option_name]['#disabled'] = TRUE;
  63        $form[$this->option_name]['#value'] = $form[$this->option_name]['#default_value'];
  64        $form[$this->option_name]['#description'] .= ' <strong>' . t('Note: you do not have permission to modify this. If you change the default argument type, this setting will be lost and you will NOT be able to get it back.') . '</strong>';
  65      }
  66    }
  67  
  68    /**
  69     * Return the default argument.
  70     */
  71    function get_argument() {
  72      return isset($this->argument->options[$this->option_name]) ? $this->argument->options[$this->option_name] : '';
  73    }
  74  }
  75  
  76  /**
  77   * @}
  78   */
  79  


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