5 * Built in plugins for Views output handling.
8 // @todo: Remove this once update.php can use the registry
12 * Implements hook_views_plugins().
14 function views_views_plugins() {
15 $js_path = drupal_get_path('module', 'ctools') . '/js';
17 // display, style, row, argument default, argument validator and access.
19 // Default settings for all display plugins.
21 'title' => t('Master'),
22 'help' => t('Default settings for this view.'),
23 'handler' => 'views_plugin_display_default',
24 'theme' => 'views_view',
27 'js' => array('misc/form.js', 'misc/collapse.js', 'misc/textarea.js', 'misc/tabledrag.js', 'misc/autocomplete.js', "$js_path/dependent.js"),
31 'accept attachments' => TRUE,
32 'help topic' => 'display-default',
36 'help' => t('Display the view as a page, with a URL and menu links.'),
37 'handler' => 'views_plugin_display_page',
38 'theme' => 'views_view',
39 'uses hook menu' => TRUE,
40 'contextual links locations' => array('page'),
44 'accept attachments' => TRUE,
46 'help topic' => 'display-page',
49 'title' => t('Block'),
50 'help' => t('Display the view as a block.'),
51 'handler' => 'views_plugin_display_block',
52 'theme' => 'views_view',
53 'uses hook block' => TRUE,
54 'contextual links locations' => array('block'),
58 'accept attachments' => TRUE,
59 'admin' => t('Block'),
60 'help topic' => 'display-block',
62 'attachment' => array(
63 'title' => t('Attachment'),
64 'help' => t('Attachments added to other displays to achieve multiple views in the same view.'),
65 'handler' => 'views_plugin_display_attachment',
66 'theme' => 'views_view',
67 'contextual links locations' => array(),
71 'accept attachments' => FALSE,
72 'help topic' => 'display-attachment',
76 'help' => t('Display the view as a feed, such as an RSS feed.'),
77 'handler' => 'views_plugin_display_feed',
78 'uses hook menu' => TRUE,
81 'accept attachments' => FALSE,
83 'help topic' => 'display-feed',
86 'title' => t('Embed'),
87 'help' => t('Provide a display which can be embedded using the views api.'),
88 'handler' => 'views_plugin_display_embed',
89 'theme' => 'views_view',
90 'uses hook menu' => FALSE,
93 'accept attachments' => FALSE,
94 'admin' => t('Embed'),
95 'no ui' => !variable_get('views_ui_display_embed', FALSE),
98 'display_extender' => array(
99 // Default settings for all display_extender plugins.
101 'title' => t('Empty display extender'),
102 'help' => t('Default settings for this view.'),
103 'handler' => 'views_plugin_display_extender',
104 // You can force the plugin to be enabled
110 // Default settings for all style plugins.
112 'title' => t('Unformatted list'),
113 'help' => t('Displays rows one after another.'),
114 'handler' => 'views_plugin_style_default',
115 'theme' => 'views_view_unformatted',
116 'uses row plugin' => TRUE,
117 'uses row class' => TRUE,
118 'uses grouping' => TRUE,
119 'uses options' => TRUE,
121 'help topic' => 'style-unformatted',
124 'title' => t('HTML list'),
125 'help' => t('Displays rows as an HTML list.'),
126 'handler' => 'views_plugin_style_list',
127 'theme' => 'views_view_list',
128 'uses row plugin' => TRUE,
129 'uses row class' => TRUE,
130 'uses options' => TRUE,
132 'help topic' => 'style-list',
135 'title' => t('Grid'),
136 'help' => t('Displays rows in a grid.'),
137 'handler' => 'views_plugin_style_grid',
138 'theme' => 'views_view_grid',
139 'uses fields' => FALSE,
140 'uses row plugin' => TRUE,
141 'uses row class' => TRUE,
142 'uses options' => TRUE,
144 'help topic' => 'style-grid',
147 'title' => t('Table'),
148 'help' => t('Displays rows in a table.'),
149 'handler' => 'views_plugin_style_table',
150 'theme' => 'views_view_table',
151 'uses row plugin' => FALSE,
152 'uses row class' => TRUE,
153 'uses fields' => TRUE,
154 'uses options' => TRUE,
156 'help topic' => 'style-table',
158 'default_summary' => array(
159 'title' => t('List'),
160 'help' => t('Displays the default summary as a list.'),
161 'handler' => 'views_plugin_style_summary',
162 'theme' => 'views_view_summary',
163 'type' => 'summary', // only shows up as a summary style
164 'uses options' => TRUE,
165 'help topic' => 'style-summary',
167 'unformatted_summary' => array(
168 'title' => t('Unformatted'),
169 'help' => t('Displays the summary unformatted, with option for one after another or inline.'),
170 'handler' => 'views_plugin_style_summary_unformatted',
171 'theme' => 'views_view_summary_unformatted',
172 'type' => 'summary', // only shows up as a summary style
173 'uses options' => TRUE,
174 'help topic' => 'style-summary-unformatted',
177 'title' => t('RSS Feed'),
178 'help' => t('Generates an RSS feed from a view.'),
179 'handler' => 'views_plugin_style_rss',
180 'theme' => 'views_view_rss',
181 'uses row plugin' => TRUE,
182 'uses options' => TRUE,
184 'help topic' => 'style-rss',
189 'title' => t('Fields'),
190 'help' => t('Displays the fields with an optional template.'),
191 'handler' => 'views_plugin_row_fields',
192 'theme' => 'views_view_fields',
193 'uses fields' => TRUE,
194 'uses options' => TRUE,
196 'help topic' => 'style-row-fields',
198 'rss_fields' => array(
199 'title' => t('Fields'),
200 'help' => t('Display fields as RSS items.'),
201 'handler' => 'views_plugin_row_rss_fields',
202 'theme' => 'views_view_row_rss',
203 'uses fields' => TRUE,
204 'uses options' => TRUE,
206 'help topic' => 'style-row-fields',
209 'argument default' => array(
212 'handler' => 'views_plugin_argument_default',
216 'title' => t('Fixed value'),
217 'handler' => 'views_plugin_argument_default_fixed',
220 'title' => t('PHP Code'),
221 'handler' => 'views_plugin_argument_default_php',
224 'title' => t('Raw value from URL'),
225 'handler' => 'views_plugin_argument_default_raw',
228 'argument validator' => array(
230 'title' => t('PHP Code'),
231 'handler' => 'views_plugin_argument_validate_php',
234 'title' => t('Numeric'),
235 'handler' => 'views_plugin_argument_validate_numeric',
240 'title' => t('None'),
241 'help' => t('Will be available to all users.'),
242 'handler' => 'views_plugin_access_none',
243 'help topic' => 'access-none',
246 'title' => t('Role'),
247 'help' => t('Access will be granted to users with any of the specified roles.'),
248 'handler' => 'views_plugin_access_role',
249 'uses options' => TRUE,
250 'help topic' => 'access-role',
253 'title' => t('Permission'),
254 'help' => t('Access will be granted to users with the specified permission string.'),
255 'handler' => 'views_plugin_access_perm',
256 'uses options' => TRUE,
257 'help topic' => 'access-perm',
263 'handler' => 'views_plugin_query',
266 'views_query' => array(
267 'title' => t('SQL Query'),
268 'help' => t('Query will be generated and run using the Drupal database API.'),
269 'handler' => 'views_plugin_query_default'
275 'handler' => 'views_plugin_cache',
279 'title' => t('None'),
280 'help' => t('No caching of Views data.'),
281 'handler' => 'views_plugin_cache_none',
282 'help topic' => 'cache-none',
285 'title' => t('Time-based'),
286 'help' => t('Simple time-based caching of data.'),
287 'handler' => 'views_plugin_cache_time',
288 'uses options' => TRUE,
289 'help topic' => 'cache-time',
292 'exposed_form' => array(
295 'handler' => 'views_plugin_exposed_form',
299 'title' => t('Basic'),
300 'help' => t('Basic exposed form'),
301 'handler' => 'views_plugin_exposed_form_basic',
302 'uses options' => TRUE,
303 'help topic' => 'exposed-form-basic',
305 'input_required' => array(
306 'title' => t('Input required'),
307 'help' => t('An exposed form that only renders a view if the form contains user input.'),
308 'handler' => 'views_plugin_exposed_form_input_required',
309 'uses options' => TRUE,
310 'help topic' => 'exposed-form-input-required',
316 'handler' => 'views_plugin_pager',
320 'title' => t('Display all items'),
321 'help' => t("Display all items that this view might find"),
322 'handler' => 'views_plugin_pager_none',
323 'help topic' => 'pager-none',
324 'uses options' => TRUE,
328 'title' => t('Display a specified number of items'),
329 'help' => t('Display a limited number items that this view might find.'),
330 'handler' => 'views_plugin_pager_some',
331 'help topic' => 'pager-some',
332 'uses options' => TRUE,
336 'title' => t('Paged output, full pager'),
337 'short title' => t('Full'),
338 'help' => t('Paged output, full Drupal style'),
339 'handler' => 'views_plugin_pager_full',
340 'help topic' => 'pager-full',
341 'uses options' => TRUE,
344 'title' => t('Paged output, mini pager'),
345 'short title' => t('Mini'),
346 'help' => t('Use the mini pager output.'),
347 'handler' => 'views_plugin_pager_mini',
348 'help topic' => 'pager-mini',
349 'uses options' => TRUE,
353 'localization' => array(
356 'handler' => 'views_plugin_localization',
360 'title' => t('None'),
361 'help' => t('Do not pass admin strings for translation.'),
362 'handler' => 'views_plugin_localization_none',
363 'help topic' => 'localization-none',
366 'title' => t('Core'),
367 'help' => t("Use Drupal core t() function. Not recommended, as it doesn't support updates to existing strings."),
368 'handler' => 'views_plugin_localization_core',
369 'help topic' => 'localization-core',
373 // Add a help message pointing to the i18views module if it is not present.
374 if (!module_exists('i18nviews')) {
375 $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))));
378 if (module_invoke('ctools', 'api_version', '1.3')) {
379 $plugins['style']['jump_menu_summary'] = array(
380 'title' => t('Jump menu'),
381 '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.'),
382 'handler' => 'views_plugin_style_summary_jump_menu',
383 'theme' => 'views_view_summary_jump_menu',
384 'type' => 'summary', // only shows up as a summary style
385 'uses options' => TRUE,
386 'help topic' => 'style-summary-jump-menu',
388 $plugins['style']['jump_menu'] = array(
389 'title' => t('Jump menu'),
390 '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.'),
391 'handler' => 'views_plugin_style_jump_menu',
392 'theme' => 'views_view_jump_menu',
393 'uses row plugin' => TRUE,
394 'uses fields' => TRUE,
395 'uses options' => TRUE,
397 'help topic' => 'style-jump-menu',
405 * Builds and return a list of all plugins available in the system.
407 * @return Nested array of plugins, grouped by type.
409 function views_discover_plugins() {
410 $cache = array('display' => array(), 'style' => array(), 'row' => array(), 'argument default' => array(), 'argument validator' => array(), 'access' => array(), 'cache' => array(), 'exposed_form' => array());
411 // Get plugins from all modules.
412 foreach (module_implements('views_plugins') as $module) {
413 $function = $module . '_views_plugins';
414 $result = $function();
415 if (!is_array($result)) {
419 $module_dir = isset($result['module']) ? $result['module'] : $module;
420 // Setup automatic path/file finding for theme registration
421 if ($module_dir == 'views') {
422 $theme_path = drupal_get_path('module', $module_dir) . '/theme';
423 $theme_file = 'theme.inc';
424 $path = drupal_get_path('module', $module_dir) . '/plugins';
427 $theme_path = $path = drupal_get_path('module', $module_dir);
428 $theme_file = "$module.views.inc";
431 foreach ($result as $type => $info) {
432 if ($type == 'module') {
435 foreach ($info as $plugin => $def) {
436 $def['module'] = $module_dir;
437 if (!isset($def['theme path'])) {
438 $def['theme path'] = $theme_path;
440 if (!isset($def['theme file'])) {
441 $def['theme file'] = $theme_file;
443 if (!isset($def['path'])) {
444 $def['path'] = $path;
446 if (!isset($def['file'])) {
447 $def['file'] = $def['handler'] . '.inc';
449 if (!isset($def['parent'])) {
450 $def['parent'] = 'parent';
452 // Set the internal name to be able to read it out later.
453 $def['name'] = $plugin;
455 // merge the new data in
456 $cache[$type][$plugin] = $def;
461 // Let other modules modify the plugins.
462 drupal_alter('views_plugins', $cache);
467 * Abstract base class to provide interface common to all plugins.
469 class views_plugin extends views_object {
471 * The top object of a view.
478 * The current used views display.
485 * The plugin type of this plugin, for example style or query.
487 var $plugin_type = NULL;
490 * The plugin name of this plugin, for example table or full.
492 var $plugin_name = NULL;
495 * Init will be called after construct, when the plugin is attached to a
496 * view and a display.
500 * Provide a form to edit options for this plugin.
502 function options_form(&$form, &$form_state) {
503 // Some form elements belong in a fieldset for presentation, but can't
504 // be moved into one because of the form_state['values'] hierarchy. Those
505 // elements can add a #fieldset => 'fieldset_name' property, and they'll
506 // be moved to their fieldset during pre_render.
507 $form['#pre_render'][] = 'views_ui_pre_render_add_fieldset_markup';
511 * Validate the options form.
513 function options_validate(&$form, &$form_state) { }
516 * Handle any special handling on the validate form.
518 function options_submit(&$form, &$form_state) { }
521 * Add anything to the query that we might need to.
526 * Provide a full list of possible theme templates used by this style.
528 function theme_functions() {
529 if (empty($this->definition['theme'])) {
530 $this->definition['theme'] = 'views_view';
532 return views_theme_functions($this->definition['theme'], $this->view, $this->display);
536 * Provide a list of additional theme functions for the theme information page
538 function additional_theme_functions() {
540 if (!empty($this->definition['additional themes'])) {
541 foreach ($this->definition['additional themes'] as $theme => $type) {
542 $funcs[] = views_theme_functions($theme, $this->view, $this->display);
549 * Validate that the plugin is correct and can be saved.
552 * An array of error strings to tell the user what is wrong with this
555 function validate() { return array(); }
558 * Returns the summary of the settings in the display.
560 function summary_title() {
561 return t('Settings');
564 * Return the human readable name of the display.
566 * This appears on the ui beside each plugin and beside the settings link.
568 function plugin_title() {
569 if (isset($this->definition['short title'])) {
570 return check_plain($this->definition['short title']);
572 return check_plain($this->definition['title']);
577 * Get enabled display extenders.
579 function views_get_enabled_display_extenders() {
580 $enabled = array_filter(variable_get('views_display_extenders', array()));
581 $options = views_fetch_plugin_names('display_extender');
582 foreach ($options as $name => $plugin) {
583 $enabled[$name] = $name;