Index: includes/plugins.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/includes/plugins.inc,v retrieving revision 1.152.2.4 diff -u -p -r1.152.2.4 plugins.inc --- includes/plugins.inc 21 Sep 2009 21:25:53 -0000 1.152.2.4 +++ includes/plugins.inc 24 Sep 2009 13:33:35 -0000 @@ -266,6 +266,33 @@ function views_views_plugins() { 'help topic' => 'cache-time', ), ), + 'pager' => array( + 'parent' => array( + 'no ui' => TRUE, + 'handler' => 'views_plugin_pager', + 'parent' => '', + 'uses options' => TRUE, + ), + 'none' => array( + 'title' => t('None'), + 'help' => t("Don't use Pager"), + 'handler' => 'views_plugin_pager_none', + 'help topic' => 'pager-none', + ), + 'mini' => array( + 'title' => t('Mini'), + 'help' => t('Mini Pager'), + 'handler' => 'views_plugin_pager_mini', + 'help topic' => 'pager-mini', + ), + 'full' => array( + 'title' => t('Full'), + 'help' => t('Full pager'), + 'handler' => 'views_plugin_pager_full', + 'help topic' => 'pager-full', + 'uses options' => TRUE, + ), + ), ); } Index: plugins/views_plugin_display.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/plugins/views_plugin_display.inc,v retrieving revision 1.20.2.8 diff -u -p -r1.20.2.8 views_plugin_display.inc --- plugins/views_plugin_display.inc 21 Sep 2009 21:23:40 -0000 1.20.2.8 +++ plugins/views_plugin_display.inc 24 Sep 2009 13:33:40 -0000 @@ -113,10 +113,8 @@ class views_plugin_display extends views * Does the display have a pager enabled? */ function use_pager() { - if (!empty($this->definition['use pager'])) { - return $this->get_option('use_pager'); - } - return FALSE; + $pager = $this->get_pager_plugin(); + return $pager->use_pager(); } /** @@ -165,7 +163,7 @@ class views_plugin_display extends views 'empty' => array('empty', 'empty_format'), 'use_ajax' => array('use_ajax'), 'items_per_page' => array('items_per_page', 'offset', 'use_pager', 'pager_element'), - 'use_pager' => array('items_per_page', 'offset', 'use_pager', 'pager_element'), + 'pager' => array('pager'), 'use_more' => array('use_more', 'use_more_text'), 'link_display' => array('link_display'), 'distinct' => array('distinct'), @@ -237,8 +235,7 @@ class views_plugin_display extends views 'use_ajax' => TRUE, 'items_per_page' => TRUE, 'offset' => TRUE, - 'use_pager' => TRUE, - 'pager_element' => TRUE, + 'pager' => TRUE, 'use_more' => TRUE, 'use_more_text' => TRUE, 'distinct' => TRUE, @@ -288,6 +285,11 @@ class views_plugin_display extends views 'type' => array('default' => 'none'), ), ), + 'pager' => array( + 'contains' => array( + 'type' => array('default' => 'none'), + ), + ), 'title' => array( 'default' => '', 'translatable' => TRUE, @@ -328,12 +330,6 @@ class views_plugin_display extends views 'offset' => array( 'default' => 0, ), - 'use_pager' => array( - 'default' => FALSE, - ), - 'pager_element' => array( - 'default' => 0, - ), 'use_more' => array( 'default' => FALSE, ), @@ -520,6 +516,22 @@ class views_plugin_display extends views } /** + * Get the pager plugin + */ + function get_pager_plugin($name = NULL) { + if (!$name) { + $pager = $this->get_option('pager'); + $name = $pager['type']; + } + + $plugin = views_get_plugin('pager', $name); + if ($plugin) { + $plugin->init($this->view, $this->display); + return $plugin; + } + } + + /** * Get the handler object for a single handler. */ function &get_handler($type, $id) { @@ -674,10 +686,19 @@ class views_plugin_display extends views } if (!empty($this->definition['use pager'])) { - $options['use_pager'] = array( + + $pager_plugin = $this->get_pager_plugin(); + if (!$pager_plugin) { + // default to the no access control plugin. + $pager_plugin = views_get_plugin('pager', 'none'); + } + + $pager_str = $pager_plugin->summary_title(); + + $options['pager'] = array( 'category' => 'basic', 'title' => t('Use pager'), - 'value' => $this->get_option('use_pager') ? ($this->get_option('use_pager') === 'mini' ? t('Mini') : t('Yes')) : t('No'), + 'value' => $pager_str, 'desc' => t("Change this display's pager setting."), ); } @@ -744,6 +765,14 @@ class views_plugin_display extends views $options['cache']['links']['cache_options'] = t('Change settings for this caching type.'); } + if (!empty($access_plugin->definition['uses options'])) { + $options['access']['links']['access_options'] = t('Change settings for this access type.'); + } + + if (!empty($pager_plugin->definition['uses options'])) { + $options['pager']['links']['pager_options'] = t('Change settings for this pager type.'); + } + if ($this->uses_link_display()) { // Only show the 'link display' if there is more than one option. $count = 0; @@ -861,19 +890,47 @@ class views_plugin_display extends views '#default_value' => $this->get_option('use_ajax') ? 1 : 0, ); break; - case 'use_pager': + case 'pager': $form['#title'] .= t('Use a pager for this view'); - $form['use_pager'] = array( - '#type' => 'radios', - '#options' => array(TRUE => t('Full pager'), 'mini' => t('Mini pager'), 0 => t('No')), - '#default_value' => $this->get_option('use_pager'), + $form['pager'] = array( + '#prefix' => '
', + '#suffix' => '
', + '#tree' => TRUE, ); - $form['pager_element'] = array( - '#type' => 'textfield', - '#title' => t('Pager element'), - '#description' => t("Unless you're experiencing problems with pagers related to this view, you should leave this at 0. If using multiple pagers on one page you may need to set this number to a higher value so as not to conflict within the ?page= array. Large values will add a lot of commas to your URLs, so avoid if possible."), - '#default_value' => intval($this->get_option('pager_element')), + + $pager = $this->get_option('pager'); + $form['pager']['type'] = array( + '#type' => 'radios', + '#options' => views_fetch_plugin_names('pager'), + '#default_value' => $pager['type'], ); + + $pager_plugin = views_fetch_plugin_data('pager', $pager['type']); + if (!empty($pager_plugin['uses options'])) { + $form['markup'] = array( + '#prefix' => '
', + '#suffix' => '
', + '#value' => t('You may also adjust the !settings for the currently selected access restriction by clicking on the icon.', array('!settings' => $this->option_link(t('settings'), 'access_options'))), + ); + } + + break; + case 'pager_options': + $pager = $this->get_option('pager'); + $plugin = $this->get_pager_plugin(); + $form['#title'] .= t('Pager options'); + if ($plugin) { + $form['#help_topic'] = $plugin->definition['help topic']; + + $form['pager_options'] = array( + '#tree' => TRUE, + ); + $form['pager_options']['type'] = array( + '#type' => 'value', + '#value' => $pager['type'], + ); + $plugin->options_form($form['pager_options'], $form_state); + } break; case 'items_per_page': $form['#title'] .= $this->use_pager() ? t('Items per page') : t('Items to display'); @@ -1477,12 +1534,27 @@ class views_plugin_display extends views case 'link_display': $this->set_option($section, $form_state['values'][$section]); break; - case 'use_ajax': - $this->set_option($section, (bool)$form_state['values'][$section]); + case 'pager': + $pager = $this->get_option('pager'); + if ($pager['type'] != $form_state['values']['pager']['type']) { + $plugin = views_get_plugin('pager', $form_state['values']['pager']['type']); + if ($plugin) { + $pager = array('type' => $form_state['values']['pager']['type']); + $plugin->option_defaults($pager); + $this->set_option('pager', $pager); + if (!empty($plugin->definition['uses options'])) { + views_ui_add_form_to_stack('display', $this->view, $this->display->id, array('pager_options')); + } + } + } + break; - case 'use_pager': - $this->set_option($section, $form_state['values'][$section]); - $this->set_option('pager_element', intval($form_state['values']['pager_element'])); + case 'pager_options': + $plugin = views_get_plugin('pager', $form_state['values'][$section]['type']); + if ($plugin) { + $plugin->options_submit($form['pager_options'], $form_state); + $this->set_option('pager', $form_state['values'][$section]); + } break; case 'items_per_page': $this->set_option($section, intval($form_state['values'][$section])); Index: plugins/views_plugin_pager.inc =================================================================== RCS file: plugins/views_plugin_pager.inc diff -N plugins/views_plugin_pager.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ plugins/views_plugin_pager.inc 24 Sep 2009 13:33:40 -0000 @@ -0,0 +1,63 @@ +view = &$view; + $this->display = &$display; + $this->options = array(); + + if (is_object($display->handler)) { + // Note: The below is read only. + $this->options = $display->handler->get_option('pager'); + } + } + + /** + * Retrieve the default options when this is a new pager plugin + */ + function option_defaults(&$options) { } + + /** + * Provide the default form for setting options. + */ + function options_form(&$form, &$form_state) { } + + /** + * Provide the default form form for validating options + */ + function options_validate(&$form, &$form_state) { } + + /** + * Provide the default form form for submitting options + */ + function options_submit(&$form, &$form_state) { } + + /** + * Return a string to display as the clickable title for the + * pager plugin. + */ + function summary_title() { + return t('Unknown'); + } + + function use_pager() { + return TRUE; + } + + function render() { } +} Index: plugins/views_plugin_pager_full.inc =================================================================== RCS file: plugins/views_plugin_pager_full.inc diff -N plugins/views_plugin_pager_full.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ plugins/views_plugin_pager_full.inc 24 Sep 2009 13:33:41 -0000 @@ -0,0 +1,35 @@ + 'textfield', + '#title' => t('Pager element'), + '#description' => t("Unless you're experiencing problems with pagers related to this view, you should leave this at 0. If using multiple pagers on one page you may need to set this number to a higher value so as not to conflict within the ?page= array. Large values will add a lot of commas to your URLs, so avoid if possible."), + '#default_value' => 20, + ); + + $form['pager_pages'] = array ( + '#type' => 'textfield', + '#title' => t('Pages for pager'), + '#description' => t('How many pages display in pager.'), + '#default_value' => 0, + ); + } + + /** + * Return a string to display as the clickable title for the + * pager plugin. + */ + function summary_title() { + return t('Full Pager'); + } +} Index: plugins/views_plugin_pager_mini.inc =================================================================== RCS file: plugins/views_plugin_pager_mini.inc diff -N plugins/views_plugin_pager_mini.inc --- /dev/null 1 Jan 1970 00:00:00 -0000 +++ plugins/views_plugin_pager_mini.inc 24 Sep 2009 13:33:41 -0000 @@ -0,0 +1,19 @@ +