? .git 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.24 diff -u -p -r1.20.2.24 views_plugin_display.inc --- plugins/views_plugin_display.inc 4 Dec 2009 19:05:18 -0000 1.20.2.24 +++ plugins/views_plugin_display.inc 7 Dec 2009 21:13:32 -0000 @@ -109,6 +109,11 @@ class views_plugin_display extends views } } } + $pager = $this->get_plugin('pager'); + if ($pager->offset_exposed() || $pager->items_per_page_exposed()) { + $this->has_exposed = TRUE; + return TRUE; + } $this->has_exposed = FALSE; } Index: plugins/views_plugin_exposed_form.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/plugins/Attic/views_plugin_exposed_form.inc,v retrieving revision 1.1.2.5 diff -u -p -r1.1.2.5 views_plugin_exposed_form.inc --- plugins/views_plugin_exposed_form.inc 3 Dec 2009 23:28:53 -0000 1.1.2.5 +++ plugins/views_plugin_exposed_form.inc 7 Dec 2009 21:13:36 -0000 @@ -106,6 +106,37 @@ class views_plugin_exposed_form extends '#type' => 'submit', ); } + + $pager = $this->view->display_handler->get_plugin('pager'); + if ($pager->items_per_page_exposed()) { + $options = explode(',', $pager->options['expose']['items_per_page_options']); + $sanitized_options = array(); + if (is_array($options)) { + foreach ($options as $option) { + $sanitized_options[intval($option)] = intval($option); + } + + $form['items_per_page'] = array( + '#type' => 'select', + '#title' => $pager->options['expose']['items_per_page_label'], + '#options' => $sanitized_options, + '#default_value' => $pager->get_items_per_page(), + ); + } + $form['submit']['#weight'] = 10; + } + + if ($pager->offset_exposed()) { + $form['offset'] = array( + '#type' => 'textfield', + '#size' => 10, + '#maxlength' => 10, + '#title' => $pager->options['expose']['offset_label'], + '#default_value' => $pager->get_offset(), + ); + $form['submit']['#weight'] = 10; + } + } function exposed_form_validate(&$form, &$form_state) { } Index: plugins/views_plugin_pager.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/plugins/Attic/views_plugin_pager.inc,v retrieving revision 1.1.2.2 diff -u -p -r1.1.2.2 views_plugin_pager.inc --- plugins/views_plugin_pager.inc 3 Dec 2009 23:28:53 -0000 1.1.2.2 +++ plugins/views_plugin_pager.inc 7 Dec 2009 21:13:36 -0000 @@ -177,4 +177,12 @@ class views_plugin_pager extends views_p return $this->get_items_per_page() && $this->total_items > (intval($this->current_page) + 1) * $this->get_items_per_page(); } + + function items_per_page_exposed() { + return !empty($this->options['expose']['items_per_page']); + } + + function offset_exposed() { + return !empty($this->options['expose']['offset']); + } } Index: plugins/views_plugin_pager_full.inc =================================================================== RCS file: /cvs/drupal-contrib/contributions/modules/views/plugins/Attic/views_plugin_pager_full.inc,v retrieving revision 1.1.2.1 diff -u -p -r1.1.2.1 views_plugin_pager_full.inc --- plugins/views_plugin_pager_full.inc 3 Dec 2009 01:47:31 -0000 1.1.2.1 +++ plugins/views_plugin_pager_full.inc 7 Dec 2009 21:13:37 -0000 @@ -19,7 +19,17 @@ class views_plugin_pager_full extends vi $options['items_per_page'] = array('default' => 10); $options['offset'] = array('default' => 0); $options['id'] = array('default' => 0); - + $options['expose'] = array( + 'contains' => array( + 'items_per_page' => array('default' => FALSE, 'bool' => TRUE), + 'items_per_page_label' => array('default' => 'Items per page', 'translatable' => TRUE), + 'items_per_page_options' => array('default' => '10, 20, 30, 50, 100'), + + 'offset' => array('default' => FALSE, 'bool' => TRUE), + 'offset_label' => array('default' => 'Offset', 'translatable' => TRUE), + ), + 'export' => 'FALSE', + ); return $options; } @@ -47,6 +57,89 @@ class views_plugin_pager_full extends vi '#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' => $this->options['id'], ); + + $form['expose'] = array ( + '#type' => 'fieldset', + '#collapsible' => FALSE, + '#collapsed' => FALSE, + '#tree' => TRUE, + '#title' => t('Exposed options'), + '#input' => TRUE, + '#description' => t('Exposing this options allows users to define their values in a exposed form when view is displayed'), + ); + + $form['expose']['items_per_page'] = array( + '#type' => 'checkbox', + '#title' => t('Expose items per page'), + '#description' => t('When checked, users can determine how many items per page show in a view'), + '#default_value' => $this->options['expose']['items_per_page'], + ); + + $form['expose']['items_per_page_label'] = array( + '#type' => 'textfield', + '#title' => t('Items per page label'), + '#required' => TRUE, + '#description' => t('Label to use in the exposed items per page form element.'), + '#default_value' => $this->options['expose']['items_per_page_label'], + '#process' => array('views_process_dependency'), + '#dependency' => array( + 'edit-pager-options-expose-items-per-page' => array(1) + ), + ); + + $form['expose']['items_per_page_options'] = array( + '#type' => 'textfield', + '#title' => t('Exposed items per page options'), + '#required' => TRUE, + '#description' => t('Set between which values the user can choose when determining the items per page. Separated by colon.'), + '#default_value' => $this->options['expose']['items_per_page_options'], + '#process' => array('views_process_dependency'), + '#dependency' => array( + 'edit-pager-options-expose-items-per-page' => array(1) + ), + ); + + $form['expose']['offset'] = array( + '#type' => 'checkbox', + '#title' => t('Expose Offset'), + '#description' => t('When checked, users can determine how many items per page show in a view'), + '#default_value' => $this->options['expose']['items_per_page'], + ); + + $form['expose']['offset_label'] = array( + '#type' => 'textfield', + '#title' => t('Offset label'), + '#required' => TRUE, + '#description' => t('Label to use in the exposed offset form element.'), + '#default_value' => $this->options['expose']['offset_label'], + '#process' => array('views_process_dependency'), + '#dependency' => array( + 'edit-pager-options-expose-offset' => array(1) + ), + ); + } + + function options_validate(&$form, &$form_state) { + // Only accept integer values. + $error = FALSE; + $exposed_options = $form_state['values']['pager_options']['expose']['items_per_page_options']; + if (strpos($exposed_options, '.') !== FALSE) { + $error = TRUE; + } + $options = explode(',',$exposed_options); + if (!$error && is_array($options)) { + foreach ($options as $option) { + if (!is_numeric($option) || intval($option) == 0) { + $error = TRUE; + } + } + } + else { + $error = TRUE; + } + if ($error) { + form_set_error('pager_options][expose][items_per_page_options', t('Please insert a list of integer numeric values separated by colons: e.g: 10, 20, 50, 100')); + } } function query() { @@ -82,6 +175,16 @@ class views_plugin_pager_full extends vi if (!empty($pager_page_array[$this->options['id']])) { $this->current_page = intval($pager_page_array[$this->options['id']]); } + if ($this->items_per_page_exposed()) { + if (!empty($_GET['items_per_page'])){ + $this->options['items_per_page'] = $_GET['items_per_page']; + } + } + if ($this->offset_exposed()) { + if (!empty($_GET['offset'])){ + $this->options['offset'] = $_GET['offset']; + } + } } /**