/[drupal]/contributions/modules/views/plugins/views_plugin_argument_default.inc
ViewVC logotype

Diff of /contributions/modules/views/plugins/views_plugin_argument_default.inc

Parent Directory Parent Directory | Revision Log Revision Log | View Revision Graph Revision Graph | View Patch Patch

revision 1.1.2.1 by merlinofchaos, Mon Jun 1 23:34:59 2009 UTC revision 1.1.2.2 by merlinofchaos, Thu Nov 26 00:35:16 2009 UTC
# Line 1  Line 1 
1  <?php  <?php
2  // $Id: views_plugin_argument_default.inc,v 1.1 2008/09/03 19:21:30 merlinofchaos Exp $  // $Id: views_plugin_argument_default.inc,v 1.1.2.1 2009/06/01 23:34:59 merlinofchaos Exp $
3  /**  /**
4   * @file   * @file
5   * Contains the fixed argument default plugin.   * Contains the fixed argument default plugin.
# Line 19  Line 19 
19   * The fixed argument default handler; also used as the base.   * The fixed argument default handler; also used as the base.
20   */   */
21  class views_plugin_argument_default extends views_plugin {  class views_plugin_argument_default extends views_plugin {
22    var $option_name = 'default_argument_fixed';    /**
23       * Return the default argument.
24       *
25       * This needs to be overridden by every default argument handler to properly do what is needed.
26       */
27      function get_argument() { }
28    
29    /**    /**
30     * Initialize this plugin with the view and the argument     * Initialize this plugin with the view and the argument
31     * it is linked to.     * it is linked to.
32     */     */
33    function init(&$view, &$argument, $id = NULL) {    function init(&$view, &$argument, $options) {
34      $this->view = &$view;      $this->view = &$view;
35      $this->argument = &$argument;      $this->argument = &$argument;
36      $this->id = $id;  
37        $this->convert_options($options);
38        $this->unpack_options($this->options, $options);
39    }    }
40    
41    /**    /**
42       * Retrieve the options when this is a new access
43       * control plugin
44       */
45      function option_definition() { return array(); }
46    
47      /**
48       * Provide the default form for setting options.
49       */
50      function options_form(&$form, &$form_state) { }
51    
52      /**
53       * Provide the default form form for validating options
54       */
55      function options_validate(&$form, &$form_state) { }
56    
57      /**
58       * Provide the default form form for submitting options
59       */
60      function options_submit(&$form, &$form_state) { }
61    
62      /**
63     * Determine if the administrator has the privileges to use this     * Determine if the administrator has the privileges to use this
64     * plugin     * plugin
65     */     */
66    function access() { return TRUE; }    function access() { return TRUE; }
67    
   function argument_form(&$form, &$form_state) {  
     $form[$this->option_name] = array(  
       '#type' => 'textfield',  
       '#title' => t('Default argument'),  
       '#default_value' => $this->get_argument(),  
       '#process' => array('views_process_dependency'),  
       '#dependency' => array(  
         'radio:options[default_action]' => array('default'),  
         'radio:options[default_argument_type]' => array($this->id)  
       ),  
       '#dependency_count' => 2,  
     );  
   
     // Only do this if using one simple standard form gadget  
     $this->check_access($form);  
   }  
   
68    /**    /**
69     * If we don't have access to the form but are showing it anyway, ensure that     * If we don't have access to the form but are showing it anyway, ensure that
70     * the form is safe and cannot be changed from user input.     * the form is safe and cannot be changed from user input.
71       *
72       * This is only called by child objects if specified in the options_form(),
73       * so it will not always be used.
74     */     */
75    function check_access(&$form) {    function check_access(&$form, $option_name) {
76      if (!$this->access()) {      if (!$this->access()) {
77        $form[$this->option_name]['#disabled'] = TRUE;        $form[$option_name]['#disabled'] = TRUE;
78        $form[$this->option_name]['#value'] = $form[$this->option_name]['#default_value'];        $form[$option_name]['#value'] = $form[$this->option_name]['#default_value'];
79        $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>';        $form[$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>';
80      }      }
81    }    }
82    
83    /**    /**
84     * Return the default argument.     * Convert options from the older style.
85       *
86       * In Views 3, the method of storing default argument options has changed
87       * and each plugin now gets its own silo. This method can be used to
88       * move arguments from the old style to the new style. See
89       * views_plugin_argument_default_fixed for a good example of this method.
90     */     */
91    function get_argument() {    function convert_options(&$options) { }
     return isset($this->argument->options[$this->option_name]) ? $this->argument->options[$this->option_name] : '';  
   }  
92  }  }
93    
94  /**  /**

Legend:
Removed from v.1.1.2.1  
changed lines
  Added in v.1.1.2.2

  ViewVC Help
Powered by ViewVC 1.1.3