[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

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

   1  <?php
   2  // $Id: plugins.inc,v 1.156.2.2 2009/11/30 23:55:33 merlinofchaos Exp $
   3  /**
   4   * @file plugins.inc
   5   * Built in plugins for Views output handling.
   6   *
   7   */
   8  
   9  /**
  10   * Implementation of hook_views_plugins
  11   */
  12  function views_views_plugins() {
  13    $path = drupal_get_path('module', 'views') . '/js';
  14  
  15    $plugins = array(
  16      'module' => 'views', // This just tells our themes are elsewhere.
  17      'display' => array(
  18        'parent' => array(
  19          // this isn't really a display but is necessary so the file can
  20          // be included.
  21          'no ui' => TRUE,
  22          'handler' => 'views_plugin_display',
  23          'parent' => '',
  24        ),
  25        'default' => array(
  26          'title' => t('Defaults'),
  27          'help' => t('Default settings for this view.'),
  28          'handler' => 'views_plugin_display_default',
  29          'theme' => 'views_view',
  30          'no ui' => TRUE,
  31          'no remove' => TRUE,
  32          'js' => array('misc/collapse.js', 'misc/textarea.js', 'misc/tabledrag.js', 'misc/autocomplete.js', "$path/dependent.js"),
  33          'use ajax' => TRUE,
  34          'use pager' => TRUE,
  35          'use more' => TRUE,
  36          'accept attachments' => TRUE,
  37          'help topic' => 'display-default',
  38        ),
  39        'page' => array(
  40          'title' => t('Page'),
  41          'help' => t('Display the view as a page, with a URL and menu links.'),
  42          'handler' => 'views_plugin_display_page',
  43          'theme' => 'views_view',
  44          'uses hook menu' => TRUE,
  45          'use ajax' => TRUE,
  46          'use pager' => TRUE,
  47          'accept attachments' => TRUE,
  48          'admin' => t('Page'),
  49          'help topic' => 'display-page',
  50        ),
  51        'block' => array(
  52          'title' => t('Block'),
  53          'help' => t('Display the view as a block.'),
  54          'handler' => 'views_plugin_display_block',
  55          'theme' => 'views_view',
  56          'uses hook block' => TRUE,
  57          'use ajax' => TRUE,
  58          'use pager' => TRUE,
  59          'use more' => TRUE,
  60          'accept attachments' => TRUE,
  61          'admin' => t('Block'),
  62          'help topic' => 'display-block',
  63        ),
  64        'attachment' => array(
  65          'title' => t('Attachment'),
  66          'help' => t('Attachments added to other displays to achieve multiple views in the same view.'),
  67          'handler' => 'views_plugin_display_attachment',
  68          'theme' => 'views_view',
  69          'use ajax' => TRUE,
  70          'help topic' => 'display-attachment',
  71        ),
  72        'feed' => array(
  73          'title' => t('Feed'),
  74          'help' => t('Display the view as a feed, such as an RSS feed.'),
  75          'handler' => 'views_plugin_display_feed',
  76          'parent' => 'page', // so it knows to load the page plugin .inc file
  77          'uses hook menu' => TRUE,
  78          'use ajax' => FALSE,
  79          'use pager' => FALSE,
  80          'accept attachments' => FALSE,
  81          'admin' => t('Feed'),
  82          'help topic' => 'display-feed',
  83        ),
  84      ),
  85      'style' => array(
  86        'parent' => array(
  87          // this isn't really a display but is necessary so the file can
  88          // be included.
  89          'no ui' => TRUE,
  90          'handler' => 'views_plugin_style',
  91          'parent' => '',
  92        ),
  93        'default' => array(
  94          'title' => t('Unformatted'),
  95          'help' => t('Displays rows one after another.'),
  96          'handler' => 'views_plugin_style_default',
  97          'theme' => 'views_view_unformatted',
  98          'uses row plugin' => TRUE,
  99          'uses grouping' => TRUE,
 100          'uses options' => TRUE,
 101          'type' => 'normal',
 102          'help topic' => 'style-unformatted',
 103        ),
 104        'list' => array(
 105          'title' => t('HTML List'),
 106          'help' => t('Displays rows as an HTML list.'),
 107          'handler' => 'views_plugin_style_list',
 108          'theme' => 'views_view_list',
 109          'uses row plugin' => TRUE,
 110          'uses options' => TRUE,
 111          'type' => 'normal',
 112          'help topic' => 'style-list',
 113        ),
 114        'grid' => array(
 115          'title' => t('Grid'),
 116          'help' => t('Displays rows in a grid.'),
 117          'handler' => 'views_plugin_style_grid',
 118          'theme' => 'views_view_grid',
 119          'uses row plugin' => TRUE,
 120          'uses options' => TRUE,
 121          'type' => 'normal',
 122          'help topic' => 'style-grid',
 123        ),
 124        'table' => array(
 125          'title' => t('Table'),
 126          'help' => t('Displays rows in a table.'),
 127          'handler' => 'views_plugin_style_table',
 128          'theme' => 'views_view_table',
 129          'uses row plugin' => FALSE,
 130          'uses fields' => TRUE,
 131          'uses options' => TRUE,
 132          'type' => 'normal',
 133          'help topic' => 'style-table',
 134        ),
 135        'default_summary' => array(
 136          'title' => t('List'),
 137          'help' => t('Displays the default summary as a list.'),
 138          'handler' => 'views_plugin_style_summary',
 139          'theme' => 'views_view_summary',
 140          'type' => 'summary', // only shows up as a summary style
 141          'uses options' => TRUE,
 142          'help topic' => 'style-summary',
 143        ),
 144        'unformatted_summary' => array(
 145          'title' => t('Unformatted'),
 146          'help' => t('Displays the summary unformatted, with option for one after another or inline.'),
 147          'handler' => 'views_plugin_style_summary_unformatted',
 148          'parent' => 'default_summary',
 149          'theme' => 'views_view_summary_unformatted',
 150          'type' => 'summary', // only shows up as a summary style
 151          'uses options' => TRUE,
 152          'help topic' => 'style-summary-unformatted',
 153        ),
 154        'rss' => array(
 155          'title' => t('RSS Feed'),
 156          'help' => t('Generates an RSS feed from a view.'),
 157          'handler' => 'views_plugin_style_rss',
 158          'theme' => 'views_view_rss',
 159          'uses row plugin' => TRUE,
 160          'uses options' => TRUE,
 161          'type' => 'feed',
 162          'help topic' => 'style-rss',
 163        ),
 164      ),
 165      'row' => array(
 166        'parent' => array(
 167          // this isn't really a display but is necessary so the file can
 168          // be included.
 169          'no ui' => TRUE,
 170          'handler' => 'views_plugin_row',
 171          'parent' => '',
 172        ),
 173        'fields' => array(
 174          'title' => t('Fields'),
 175          'help' => t('Displays the fields with an optional template.'),
 176          'handler' => 'views_plugin_row_fields',
 177          'theme' => 'views_view_fields',
 178          'uses fields' => TRUE,
 179          'uses options' => TRUE,
 180          'type' => 'normal',
 181          'help topic' => 'style-row-fields',
 182        ),
 183      ),
 184      'argument default' => array(
 185        // This type of plugin does not conform to the standard and
 186        // uses 'fixed' as the parent rather than having a separate parent.
 187        'fixed' => array(
 188          'title' => t('Fixed entry'),
 189          'handler' => 'views_plugin_argument_default',
 190        ),
 191        'php' => array(
 192          'title' => t('PHP Code'),
 193          'handler' => 'views_plugin_argument_default_php',
 194          'parent' => 'fixed',
 195        ),
 196      ),
 197      'argument validator' => array(
 198        'parent' => array(
 199          'no ui' => TRUE,
 200          'handler' => 'views_plugin_argument_validate',
 201          'parent' => '',
 202        ),
 203        'php' => array(
 204          'title' => t('PHP Code'),
 205          'handler' => 'views_plugin_argument_validate_php',
 206        ),
 207        'numeric' => array(
 208          'title' => t('Numeric'),
 209          'handler' => 'views_plugin_argument_validate_numeric',
 210        ),
 211      ),
 212      'access' => array(
 213        'parent' => array(
 214          'no ui' => TRUE,
 215          'handler' => 'views_plugin_access',
 216          'parent' => '',
 217        ),
 218        'none' => array(
 219          'title' => t('None'),
 220          'help' => t('Will be available to all users.'),
 221          'handler' => 'views_plugin_access_none',
 222          'help topic' => 'access-none',
 223        ),
 224        'role' => array(
 225          'title' => t('Role'),
 226          'help' => t('Access will be granted to users with any of the specified roles.'),
 227          'handler' => 'views_plugin_access_role',
 228          'uses options' => TRUE,
 229          'help topic' => 'access-role',
 230        ),
 231        'perm' => array(
 232          'title' => t('Permission'),
 233          'help' => t('Access will be granted to users with the specified permission string.'),
 234          'handler' => 'views_plugin_access_perm',
 235          'uses options' => TRUE,
 236          'help topic' => 'access-perm',
 237        ),
 238      ),
 239      'cache' => array(
 240        'parent' => array(
 241          'no ui' => TRUE,
 242          'handler' => 'views_plugin_cache',
 243          'parent' => '',
 244        ),
 245        'none' => array(
 246          'title' => t('None'),
 247          'help' => t('No caching of Views data.'),
 248          'handler' => 'views_plugin_cache_none',
 249          'help topic' => 'cache-none',
 250        ),
 251        'time' => array(
 252          'title' => t('Time-based'),
 253          'help' => t('Simple time-based caching of data.'),
 254          'handler' => 'views_plugin_cache_time',
 255          'uses options' => TRUE,
 256          'help topic' => 'cache-time',
 257        ),
 258      ),
 259    );
 260  
 261    if (module_invoke('ctools', 'api_version', '1.3')) {
 262      $plugins['style']['jump_menu_summary'] = array(
 263        'title' => t('Jump menu'),
 264        'help' => t('Puts all of the results into a select box and allows the user to go to a different page based upon the results.'),
 265        'handler' => 'views_plugin_style_summary_jump_menu',
 266        'theme' => 'views_view_summary_jump_menu',
 267        'type' => 'summary', // only shows up as a summary style
 268        'uses options' => TRUE,
 269        'help topic' => 'style-summary-jump-menu',
 270      );
 271      $plugins['style']['jump_menu'] = array(
 272        'title' => t('Jump menu'),
 273        'help' => t('Puts all of the results into a select box and allows the user to go to a different page based upon the results.'),
 274        'handler' => 'views_plugin_style_jump_menu',
 275        'theme' => 'views_view_jump_menu',
 276        'uses row plugin' => TRUE,
 277        'uses fields' => TRUE,
 278        'uses options' => TRUE,
 279        'type' => 'normal',
 280        'help topic' => 'style-jump-menu',
 281      );
 282    }
 283  
 284    return $plugins;
 285  }
 286  
 287  /**
 288   * Builds and return a list of all plugins available in the system.
 289   *
 290   * @return Nested array of plugins, grouped by type.
 291   */
 292  function views_discover_plugins() {
 293    $cache = array('display' => array(), 'style' => array(), 'row' => array(), 'argument default' => array(), 'argument validator' => array(), 'access' => array(), 'cache' => array());
 294    // Get plugins from all mdoules.
 295    foreach (module_implements('views_plugins') as $module) {
 296      $function = $module . '_views_plugins';
 297      $result = $function();
 298      if (!is_array($result)) {
 299        continue;
 300      }
 301  
 302      $module_dir = isset($result['module']) ? $result['module'] : $module;
 303      // Setup automatic path/file finding for theme registration
 304      if ($module_dir == 'views') {
 305        $theme_path = drupal_get_path('module', $module_dir) . '/theme';
 306        $theme_file = 'theme.inc';
 307        $path = drupal_get_path('module', $module_dir) . '/plugins';
 308      }
 309      else {
 310        $theme_path = $path = drupal_get_path('module', $module_dir);
 311        $theme_file = "$module.views.inc";
 312      }
 313  
 314      foreach ($result as $type => $info) {
 315        if ($type == 'module') {
 316          continue;
 317        }
 318        foreach ($info as $plugin => $def) {
 319          $def['module'] = $module_dir;
 320          if (!isset($def['theme path'])) {
 321            $def['theme path'] = $theme_path;
 322          }
 323          if (!isset($def['theme file'])) {
 324            $def['theme file'] = $theme_file;
 325          }
 326          if (!isset($def['path'])) {
 327            $def['path'] = $path;
 328          }
 329          if (!isset($def['file'])) {
 330            $def['file'] = $def['handler'] . '.inc';
 331          }
 332          if (!isset($def['parent'])) {
 333            $def['parent'] = 'parent';
 334          }
 335          // merge the new data in
 336          $cache[$type][$plugin] = $def;
 337        }
 338      }
 339    }
 340  
 341    // Let other modules modify the plugins.
 342    drupal_alter('views_plugins', $cache);
 343    return $cache;
 344  }
 345  
 346  /**
 347   * Abstract base class to provide interface common to all plugins.
 348   */
 349  class views_plugin extends views_object {
 350    /**
 351     * Init will be called after construct, when the plugin is attached to a
 352     * view and a display.
 353     */
 354    function init(&$view, &$display) {
 355      $this->view = &$view;
 356      $this->display = &$display;
 357    }
 358  
 359    /**
 360     * Provide a form to edit options for this plugin.
 361     */
 362    function options_form(&$form, &$form_state) { }
 363  
 364    /**
 365     * Validate the options form.
 366     */
 367    function options_validate(&$form, &$form_state) { }
 368  
 369    /**
 370     * Handle any special handling on the validate form.
 371     */
 372    function options_submit(&$form, &$form_state) { }
 373  
 374    /**
 375     * Add anything to the query that we might need to.
 376     */
 377    function query() { }
 378  
 379    /**
 380     * Provide a full list of possible theme templates used by this style.
 381     */
 382    function theme_functions() {
 383      return views_theme_functions($this->definition['theme'], $this->view, $this->display);
 384    }
 385  
 386    /**
 387     * Provide a list of additional theme functions for the theme information page
 388     */
 389    function additional_theme_functions() {
 390      $funcs = array();
 391      if (!empty($this->definition['additional themes'])) {
 392        foreach ($this->definition['additional themes'] as $theme => $type) {
 393          $funcs[] = views_theme_functions($theme, $this->view, $this->display);
 394        }
 395      }
 396      return $funcs;
 397    }
 398  
 399    /**
 400     * Validate that the plugin is correct and can be saved.
 401     *
 402     * @return
 403     *   An array of error strings to tell the user what is wrong with this
 404     *   plugin.
 405     */
 406    function validate() { return array(); }
 407  }
 408  


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