Newer
Older
Earl Miles
committed
<?php
* @file plugins.inc
* Built in plugins for Views output handling.
Earl Miles
committed
/**
* Implementation of hook_views_plugins
*/
function views_views_plugins() {
Earl Miles
committed
$path = drupal_get_path('module', 'views') . '/js';
'module' => 'views', // This just tells our themes are elsewhere.
'display' => array(
Earl Miles
committed
'parent' => array(
// this isn't really a display but is necessary so the file can
// be included.
'no ui' => TRUE,
'handler' => 'views_plugin_display',
'parent' => '',
),
'default' => array(
'title' => t('Defaults'),
'help' => t('Default settings for this view.'),
'handler' => 'views_plugin_display_default',
Earl Miles
committed
'theme' => 'views_view',
Earl Miles
committed
'js' => array('misc/collapse.js', 'misc/textarea.js', 'misc/tabledrag.js', 'misc/autocomplete.js', "$path/dependent.js"),
'use ajax' => TRUE,
'accept attachments' => TRUE,
'page' => array(
'title' => t('Page'),
'help' => t('Display the view as a page, with a URL and menu links.'),
'handler' => 'views_plugin_display_page',
Earl Miles
committed
'theme' => 'views_view',
Earl Miles
committed
'uses hook menu' => TRUE,
'use ajax' => TRUE,
'use more' => TRUE,
'accept attachments' => TRUE,
'admin' => t('Page'),
Earl Miles
committed
'title' => t('Block'),
'handler' => 'views_plugin_display_block',
Earl Miles
committed
'theme' => 'views_view',
Earl Miles
committed
'uses hook block' => TRUE,
'use ajax' => TRUE,
'use pager' => TRUE,
'accept attachments' => TRUE,
'admin' => t('Block'),
),
'attachment' => array(
'title' => t('Attachment'),
'help' => t('Attachments added to other displays to achieve multiple views in the same view.'),
'handler' => 'views_plugin_display_attachment',
Earl Miles
committed
'theme' => 'views_view',
'use ajax' => TRUE,
'use more' => TRUE,
'accept attachments' => FALSE,
'feed' => array(
'title' => t('Feed'),
'help' => t('Display the view as a feed, such as an RSS feed.'),
'handler' => 'views_plugin_display_feed',
Earl Miles
committed
'parent' => 'page', // so it knows to load the page plugin .inc file
'uses hook menu' => TRUE,
'use ajax' => FALSE,
'use pager' => FALSE,
'accept attachments' => FALSE,
'admin' => t('Feed'),
'display_extender' => array(
// Default settings for all display_extender plugins.
'default' => array(
'title' => t('Empty display extender'),
'help' => t('Default settings for this view.'),
'handler' => 'views_plugin_display_extender',
'no ui' => TRUE,
),
),
Earl Miles
committed
'parent' => array(
// this isn't really a display but is necessary so the file can
// be included.
'no ui' => TRUE,
'handler' => 'views_plugin_style',
'parent' => '',
),
Earl Miles
committed
'title' => t('Unformatted'),
'help' => t('Displays rows one after another.'),
'handler' => 'views_plugin_style_default',
Earl Miles
committed
'uses row plugin' => TRUE,
'uses row class' => TRUE,
'uses grouping' => TRUE,
Earl Miles
committed
'uses options' => TRUE,
'help topic' => 'style-unformatted',
Earl Miles
committed
'title' => t('HTML List'),
'help' => t('Displays rows as an HTML list.'),
'handler' => 'views_plugin_style_list',
'theme' => 'views_view_list',
Earl Miles
committed
'uses row plugin' => TRUE,
'uses row class' => TRUE,
Earl Miles
committed
'uses options' => TRUE,
'help topic' => 'style-list',
Earl Miles
committed
'grid' => array(
'title' => t('Grid'),
'help' => t('Displays rows in a grid.'),
'handler' => 'views_plugin_style_grid',
'theme' => 'views_view_grid',
'uses row plugin' => TRUE,
'uses row class' => TRUE,
Earl Miles
committed
'uses options' => TRUE,
'type' => 'normal',
'help topic' => 'style-grid',
Earl Miles
committed
),
'table' => array(
'title' => t('Table'),
'help' => t('Displays rows in a table.'),
'handler' => 'views_plugin_style_table',
'theme' => 'views_view_table',
Earl Miles
committed
'uses row plugin' => FALSE,
'uses row class' => TRUE,
Earl Miles
committed
'uses fields' => TRUE,
'uses options' => TRUE,
'help topic' => 'style-table',
Earl Miles
committed
'default_summary' => array(
'title' => t('List'),
'help' => t('Displays the default summary as a list.'),
'handler' => 'views_plugin_style_summary',
Earl Miles
committed
'theme' => 'views_view_summary',
'type' => 'summary', // only shows up as a summary style
'uses options' => TRUE,
'help topic' => 'style-summary',
'unformatted_summary' => array(
'title' => t('Unformatted'),
'help' => t('Displays the summary unformatted, with option for one after another or inline.'),
'handler' => 'views_plugin_style_summary_unformatted',
Earl Miles
committed
'parent' => 'default_summary',
'theme' => 'views_view_summary_unformatted',
'type' => 'summary', // only shows up as a summary style
'uses options' => TRUE,
'help topic' => 'style-summary-unformatted',
'rss' => array(
'title' => t('RSS Feed'),
'help' => t('Generates an RSS feed from a view.'),
'handler' => 'views_plugin_style_rss',
'theme' => 'views_view_rss',
'uses row plugin' => TRUE,
Earl Miles
committed
'uses options' => TRUE,
'help topic' => 'style-rss',
Earl Miles
committed
),
Earl Miles
committed
'parent' => array(
// this isn't really a display but is necessary so the file can
// be included.
'no ui' => TRUE,
'handler' => 'views_plugin_row',
'parent' => '',
),
'fields' => array(
'title' => t('Fields'),
'help' => t('Displays the fields with an optional template.'),
'handler' => 'views_plugin_row_fields',
Earl Miles
committed
'uses fields' => TRUE,
'help topic' => 'style-row-fields',
Earl Miles
committed
'argument default' => array(
'parent' => array(
'no ui' => TRUE,
'handler' => 'views_plugin_argument_default',
'parent' => '',
),
Earl Miles
committed
'fixed' => array(
'title' => t('Fixed entry'),
'handler' => 'views_plugin_argument_default_fixed',
Earl Miles
committed
),
'php' => array(
'title' => t('PHP Code'),
'handler' => 'views_plugin_argument_default_php',
),
'raw' => array(
'title' => t('Raw value from URL'),
'handler' => 'views_plugin_argument_default_raw',
),
Earl Miles
committed
),
'argument validator' => array(
Earl Miles
committed
'parent' => array(
'no ui' => TRUE,
'handler' => 'views_plugin_argument_validate',
Earl Miles
committed
'parent' => '',
),
Earl Miles
committed
'php' => array(
'title' => t('PHP Code'),
'handler' => 'views_plugin_argument_validate_php',
),
'numeric' => array(
'title' => t('Numeric'),
'handler' => 'views_plugin_argument_validate_numeric',
),
),
Earl Miles
committed
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
'access' => array(
'parent' => array(
'no ui' => TRUE,
'handler' => 'views_plugin_access',
'parent' => '',
),
'none' => array(
'title' => t('None'),
'help' => t('Will be available to all users.'),
'handler' => 'views_plugin_access_none',
'help topic' => 'access-none',
),
'role' => array(
'title' => t('Role'),
'help' => t('Access will be granted to users with any of the specified roles.'),
'handler' => 'views_plugin_access_role',
'uses options' => TRUE,
'help topic' => 'access-role',
),
'perm' => array(
'title' => t('Permission'),
'help' => t('Access will be granted to users with the specified permission string.'),
'handler' => 'views_plugin_access_perm',
'uses options' => TRUE,
'help topic' => 'access-perm',
),
),
Earl Miles
committed
'query' => array(
'parent' => array(
'no ui' => TRUE,
'handler' => 'views_plugin_query',
'parent' => '',
),
'views_query' => array(
'title' => t('SQL Query'),
'help' => t('Query will be generated and run using the Drupal database API.'),
'handler' => 'views_plugin_query_default'
),
),
Earl Miles
committed
'cache' => array(
'parent' => array(
'no ui' => TRUE,
'handler' => 'views_plugin_cache',
'parent' => '',
),
'none' => array(
'title' => t('None'),
'help' => t('No caching of Views data.'),
'handler' => 'views_plugin_cache_none',
'help topic' => 'cache-none',
),
'time' => array(
'title' => t('Time-based'),
'help' => t('Simple time-based caching of data.'),
'handler' => 'views_plugin_cache_time',
'uses options' => TRUE,
'help topic' => 'cache-time',
),
),
Earl Miles
committed
'exposed_form' => array(
'parent' => array(
'no ui' => TRUE,
'handler' => 'views_plugin_exposed_form',
'parent' => '',
),
'basic' => array(
'title' => t('Basic'),
'help' => t('Basic exposed form'),
'handler' => 'views_plugin_exposed_form_basic',
'uses options' => TRUE,
'help topic' => 'exposed-form-basic',
),
'input_required' => array(
'title' => t('Input required'),
'help' => t('An exposed form that only renders a view if the form contains user input.'),
'handler' => 'views_plugin_exposed_form_input_required',
'uses options' => TRUE,
'help topic' => 'exposed-form-input-required',
),
),
Earl Miles
committed
'pager' => array(
'parent' => array(
'no ui' => TRUE,
'handler' => 'views_plugin_pager',
'parent' => '',
),
'none' => array(
'title' => t('Display all items'),
'help' => t("Display all items that this view might find"),
'handler' => 'views_plugin_pager_none',
'help topic' => 'pager-none',
'uses options' => TRUE,
Earl Miles
committed
),
'some' => array(
'title' => t('Display a specified number of items'),
'help' => t('Display a limited number items that this view might find.'),
'handler' => 'views_plugin_pager_some',
'help topic' => 'pager-some',
'uses options' => TRUE,
Earl Miles
committed
),
'full' => array(
'title' => t('Paged output, full pager'),
'help' => t('Paged output, full Drupal style'),
'handler' => 'views_plugin_pager_full',
'help topic' => 'pager-full',
'uses options' => TRUE,
),
'mini' => array(
'title' => t('Paged output, mini pager'),
'help' => t('Use the mini pager output.'),
'handler' => 'views_plugin_pager_mini',
'help topic' => 'pager-mini',
'uses options' => TRUE,
'parent' => 'full',
),
),
Earl Miles
committed
'localization' => array(
'parent' => array(
'no ui' => TRUE,
'handler' => 'views_plugin_localization',
'parent' => '',
),
'none' => array(
'title' => t('None'),
'help' => t('Do not pass admin strings for translation.'),
'handler' => 'views_plugin_localization_none',
'help topic' => 'localization-none',
),
'core' => array(
'title' => t('Core'),
'help' => t("Use Drupal core t() function. Not recommended, as it doesn't support updates to existing strings."),
'handler' => 'views_plugin_localization_core',
'help topic' => 'localization-core',
),
),
Earl Miles
committed
// Add a help message pointing to the i18views module if it is not present.
if (!module_exists('i18nviews')) {
$plugins['localization']['core']['help'] .= ' ' . t('If you need to translate Views labels into other languages, consider installing the <a href="!path">Internationalization</a> package\'s Views translation module.', array('!path' => url('http://drupal.org/project/i18n', array('absolute' => TRUE))));
}
if (module_invoke('ctools', 'api_version', '1.3')) {
$plugins['style']['jump_menu_summary'] = array(
'title' => t('Jump menu'),
'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.'),
'handler' => 'views_plugin_style_summary_jump_menu',
'theme' => 'views_view_summary_jump_menu',
'type' => 'summary', // only shows up as a summary style
'uses options' => TRUE,
'help topic' => 'style-summary-jump-menu',
);
$plugins['style']['jump_menu'] = array(
'title' => t('Jump menu'),
'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.'),
'handler' => 'views_plugin_style_jump_menu',
'theme' => 'views_view_jump_menu',
'uses row plugin' => TRUE,
'uses fields' => TRUE,
'uses options' => TRUE,
'type' => 'normal',
'help topic' => 'style-jump-menu',
);
}
return $plugins;
/**
* Builds and return a list of all plugins available in the system.
*
* @return Nested array of plugins, grouped by type.
*/
function views_discover_plugins() {
Earl Miles
committed
$cache = array('display' => array(), 'style' => array(), 'row' => array(), 'argument default' => array(), 'argument validator' => array(), 'access' => array(), 'cache' => array(), 'exposed_form' => array());
// Get plugins from all mdoules.
foreach (module_implements('views_plugins') as $module) {
$function = $module . '_views_plugins';
$result = $function();
if (!is_array($result)) {
continue;
}
$module_dir = isset($result['module']) ? $result['module'] : $module;
// Setup automatic path/file finding for theme registration
if ($module_dir == 'views') {
Earl Miles
committed
$theme_path = drupal_get_path('module', $module_dir) . '/theme';
$theme_file = 'theme.inc';
$path = drupal_get_path('module', $module_dir) . '/plugins';
Earl Miles
committed
$theme_path = $path = drupal_get_path('module', $module_dir);
$theme_file = "$module.views.inc";
Earl Miles
committed
foreach ($result as $type => $info) {
if ($type == 'module') {
continue;
}
foreach ($info as $plugin => $def) {
Earl Miles
committed
if (!isset($def['theme path'])) {
$def['theme path'] = $theme_path;
}
if (!isset($def['theme file'])) {
$def['theme file'] = $theme_file;
}
if (!isset($def['path'])) {
$def['path'] = $path;
Earl Miles
committed
}
if (!isset($def['file'])) {
$def['file'] = $def['handler'] . '.inc';
}
if (!isset($def['parent'])) {
$def['parent'] = 'parent';
}
// merge the new data in
$cache[$type][$plugin] = $def;
}
}
}
// Let other modules modify the plugins.
drupal_alter('views_plugins', $cache);
return $cache;
}
Earl Miles
committed
/**
* Abstract base class to provide interface common to all plugins.
*/
class views_plugin extends views_object {
/**
* The top object of a view.
* @var view
*/
var $view = NULL;
* The current used views display.
*/
var $display = NULL;
/**
* The plugin type of this plugin, for example style or query.
*/
var $plugin_type = NULL;
Earl Miles
committed
/**
* Provide a form to edit options for this plugin.
*/
function options_form(&$form, &$form_state) { }
/**
* Validate the options form.
*/
function options_validate(&$form, &$form_state) { }
Earl Miles
committed
/**
* Handle any special handling on the validate form.
*/
Earl Miles
committed
function options_submit($form, &$form_state) { }
Earl Miles
committed
/**
* Add anything to the query that we might need to.
*/
function query() { }
/**
* Provide a full list of possible theme templates used by this style.
*/
function theme_functions() {
return views_theme_functions($this->definition['theme'], $this->view, $this->display);
}
Earl Miles
committed
/**
* Provide a list of additional theme functions for the theme information page
*/
function additional_theme_functions() {
$funcs = array();
if (!empty($this->definition['additional themes'])) {
Earl Miles
committed
foreach ($this->definition['additional themes'] as $theme => $type) {
Earl Miles
committed
$funcs[] = views_theme_functions($theme, $this->view, $this->display);
}
}
return $funcs;
}
/**
* Validate that the plugin is correct and can be saved.
*
* @return
* An array of error strings to tell the user what is wrong with this
* plugin.
*/
function validate() { return array(); }