? .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	14 Dec 2009 03:02:31 -0000
@@ -43,9 +43,13 @@ class views_plugin_display extends views
     $this->unpack_options($this->options, $options);
 
     // Translate changed settings:
-    if ($this->get_option('items_per_page')) {
-      $type = $this->get_option('use_pager');
-      $items_per_page = $this->get_option('items_per_page');
+    // Check if any of the previous values now managed by
+    // pluggable pagers have been changed. 
+    // If yes, perform the conversion
+    $items_per_page = $this->get_option('items_per_page');
+    $offset = $this->get_option('offset');
+    $type = $this->get_option('use_pager');
+    if ((!empty($items_per_page) && $items_per_page != 10) || !empty($offset) || !empty($type)) {
       if (!$type) {
         $type = $items_per_page ? 'some' : 'none';
       }
@@ -57,7 +61,7 @@ class views_plugin_display extends views
       $pager = array(
         'type' => $type,
         'options' => array(
-          'offset' => $this->get_option('offset'),
+          'offset' => $offset
         ),
       );
 
@@ -68,6 +72,11 @@ class views_plugin_display extends views
         $pager['options']['id'] = $id;
       }
 
+      // Unset the previous options
+      // After edit and save the view they will be erased
+      $this->set_option('items_per_page', NULL);
+      $this->set_option('offset', NULL);
+      $this->set_option('use_pager', NULL);
       $this->set_option('pager', $pager);
     }
   }
@@ -109,6 +118,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;
     }
 
@@ -283,6 +297,7 @@ class views_plugin_display extends views
 
           'use_ajax' => TRUE,
           'items_per_page' => TRUE,
+          'use_pager' => TRUE,
           'offset' => TRUE,
           'pager' => TRUE,
           'use_more' => TRUE,
@@ -350,6 +365,10 @@ class views_plugin_display extends views
       'offset' => array(
         'default' => 0,
       ),
+      'use_pager' => array(
+        'default' => FALSE,
+        'bool' => TRUE,
+      ),
       'use_more' => array(
         'default' => FALSE,
         'bool' => TRUE,
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	14 Dec 2009 03:02:34 -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	14 Dec 2009 03:02:35 -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	14 Dec 2009 03:02:35 -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['total_items'] = array('default' => '');
+    $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' => '5, 10, 20, 40, 60'),
+
+        'offset' => array('default' => FALSE, 'bool' => TRUE),
+        'offset_label' => array('default' => 'Offset', 'translatable' => TRUE),
+      ),
+    );
     return $options;
   }
 
@@ -47,11 +57,109 @@ 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['total_items'] = array(
+      '#type' => 'textfield',
+      '#title' => t('Number of items'),
+      '#description' => t('The number of items in the list. Leave empty to use all posible values of the view.'),
+      '#default_value' =>  $this->options['total_items'],
+    );
+
+    $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() {
-    $this->view->query->set_limit($this->options['items_per_page']);
-    $this->view->query->set_offset($this->current_page * $this->options['items_per_page'] + $this->options['offset']);
+    $limit = $this->options['items_per_page'];
+    $offset = $this->current_page * $this->options['items_per_page'] + $this->options['offset'];
+    if (!empty($this->options['total_items'])) {
+      if ($offset + $limit > $this->options['total_items']) {
+        $limit =  $this->options['total_items'] - $offset;
+      }
+    }
+
+    $this->view->query->set_limit($limit);
+    $this->view->query->set_offset($offset);
   }
 
   function render($input) {
@@ -82,6 +190,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'];
+      }
+    }
   }
 
   /**
@@ -114,4 +232,22 @@ class views_plugin_pager_full extends vi
     $pager_page_array[$this->options['id']] = $this->current_page;
   }
 
+  /**
+   * Execute the count query, which will be done just prior to the query
+   * itself being executed.
+   */
+  function execute_count_query(&$count_query, $args) {
+    $this->total_items = db_result(db_query($count_query, $args));
+    if (!empty($this->options['total_items'])) {
+      if ($this->options['total_items'] < $this->total_items) {
+        $this->total_items = $this->options['total_items'];
+      }
+    }
+    if (!empty($this->options['offset'])) {
+      $this->total_items -= $this->options['offset'];
+    }
+
+    $this->update_page_info();
+    return $this->total_items;
+  }
 }
