[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

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

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


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