[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

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

   1  <?php
   2  /**
   3   * @file
   4   * Contains the base argument validator plugin.
   5   */
   6  
   7  /**
   8   * @defgroup views_argument_validate_plugins Views' argument validate plugins
   9   * @{
  10   *
  11   * Allow specialized methods of validating arguments.
  12   *
  13   * @see hook_views_plugins
  14   */
  15  
  16  /**
  17   * Base argument validator plugin to provide basic functionality.
  18   *
  19   * @ingroup views_argument_validate_plugins
  20   */
  21  class views_plugin_argument_validate extends views_plugin {
  22    var $option_name = 'validate_argument';
  23  
  24    /**
  25     * Initialize this plugin with the view and the argument
  26     * it is linked to.
  27     */
  28    function init(&$view, &$argument, $id = NULL) {
  29      $this->view = &$view;
  30      $this->argument = &$argument;
  31      $this->id = $id;
  32    }
  33  
  34    /**
  35     * Determine if the administrator has the privileges to use this
  36     * plugin
  37     */
  38    function access() { return TRUE; }
  39  
  40    function argument_form(&$form, &$form_state) {
  41    }
  42  
  43    /**
  44     * If we don't have access to the form but are showing it anyway, ensure that
  45     * the form is safe and cannot be changed from user input.
  46     */
  47    function check_access(&$form) {
  48      if (!$this->access()) {
  49        $form[$this->option_name]['#disabled'] = TRUE;
  50        $form[$this->option_name]['#value'] = $form[$this->option_name]['#default_value'];
  51        $form[$this->option_name]['#description'] .= ' <strong>' . t('Note: you do not have permission to modify this. If you change the validator, this setting will be lost and you will NOT be able to get it back.') . '</strong>';
  52      }
  53    }
  54  
  55    /**
  56     * Return the validate argument.
  57     */
  58    function get_argument() {
  59      return isset($this->argument->options[$this->option_name]) ? $this->argument->options[$this->option_name] : '';
  60    }
  61  
  62    function validate_form(&$form, &$form_state) { }
  63  
  64    function validate_argument($arg) { return TRUE; }
  65  }
  66  
  67  /**
  68   * @}
  69   */
  70  


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7