? .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.19
diff -u -p -r1.20.2.19 views_plugin_display.inc
--- plugins/views_plugin_display.inc	30 Nov 2009 19:05:43 -0000	1.20.2.19
+++ plugins/views_plugin_display.inc	2 Dec 2009 15:34:38 -0000
@@ -80,6 +80,11 @@ class views_plugin_display extends views
           }
         }
       }
+      // Check if other items are exposed
+      if ($this->items_per_page_exposed()) {
+        $this->has_exposed = TRUE;
+        return TRUE;
+      }
       $this->has_exposed = FALSE;
     }
 
@@ -99,6 +104,13 @@ class views_plugin_display extends views
     return TRUE;
   }
 
+  /*
+   * Does the display have items per page exposed?
+   */
+  function items_per_page_exposed() {
+    return $this->get_option('items_per_page_exposed');
+  }
+
   /**
    * Does the display use AJAX?
    */
@@ -188,8 +200,8 @@ class views_plugin_display extends views
       'footer' => array('footer', 'footer_format', 'footer_empty'),
       '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'),
+      'items_per_page' => array('items_per_page', 'offset', 'use_pager', 'pager_element', 'items_per_page_label', 'items_per_page_exposed_options'),
+      'use_pager' => array('items_per_page', 'offset', 'use_pager', 'pager_element', 'items_per_page_label', 'items_per_page_exposed_options'),
       'use_more' => array('use_more', 'use_more_always', 'use_more_text'),
       'link_display' => array('link_display'),
       'distinct' => array('distinct'),
@@ -261,6 +273,9 @@ class views_plugin_display extends views
 
           'use_ajax' => TRUE,
           'items_per_page' => TRUE,
+          'items_per_page_exposed' => TRUE,
+          'items_per_page_label' => TRUE,
+          'items_per_page_exposed_options' => TRUE,
           'offset' => TRUE,
           'use_pager' => TRUE,
           'pager_element'  => TRUE,
@@ -329,6 +344,16 @@ class views_plugin_display extends views
       'offset' => array(
         'default' => 0,
       ),
+      'items_per_page_exposed' => array(
+        'default' => FALSE,
+      ),
+      'items_per_page_label' => array(
+        'default' => 'Items per page',
+        'translatable' => TRUE,
+      ),      
+      'items_per_page_exposed_options' => array(
+        'default' => '10, 20, 30, 50, 100',
+      ),
       'use_pager' => array(
         'default' => FALSE,
         'bool' => TRUE,
@@ -764,10 +789,11 @@ class views_plugin_display extends views
     }
 
     $items = intval($this->get_option('items_per_page'));
+    $items_exposed = intval($this->get_option('items_per_page_exposed'));
     $options['items_per_page'] = array(
       'category' => 'basic',
       'title' => $this->use_pager() ? t('Items per page') : t('Items to display'),
-      'value' => $items ? $items : t('Unlimited'),
+      'value' => ($items ? $items : t('Unlimited')) . ($items_exposed ? ' <em>' . t('exposed') . '</em>' : ''),
       'desc' => t('Change how many items to display.'),
     );
 
@@ -999,6 +1025,32 @@ class views_plugin_display extends views
           '#description' => t('The number of items to skip. For example, if this field is 3, the first 3 items will be skipped and not displayed. Offset can not be used if items to display is 0; instead use a very large number there.'),
           '#default_value' => intval($this->get_option('offset')),
         );
+        $form['items_per_page_exposed'] = 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->get_option('items_per_page_exposed'),
+        );
+        $form['items_per_page_label'] = array(
+          '#type' => 'textfield',
+          '#title' => t('Label'),
+          '#description' => t('Label to use in the exposed items per page form element.'),
+          '#default_value' => $this->get_option('items_per_page_label'),
+          '#process' => array('views_process_dependency'),
+          '#dependency' => array(
+            'edit-items-per-page-exposed' => array(1)
+          ),
+        );
+        $form['items_per_page_exposed_options'] = array(
+          '#type' => 'textfield',
+          '#default_value' => $this->get_option('items_per_page_exposed_options'),
+          '#title' => t('Exposed items per page options'),
+          '#description' => t('Set between which values the user can choose when determining the items per page. Separated by colon.'),
+          '#process' => array('views_process_dependency'),
+          '#dependency' => array(
+            'edit-items-per-page-exposed' => array(1)
+          ),
+        );
         break;
       case 'use_more':
         $form['#title'] .= t('Add a more link to the bottom of the display.');
@@ -1580,6 +1632,28 @@ class views_plugin_display extends views
           $plugin->options_validate($form['exposed_form_options'], $form_state);
         }
         break;
+      case 'items_per_page':
+        // Only accept integer values.
+        $error = FALSE;
+        $exposed_options = $form_state['values']['items_per_page_exposed_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('items_per_page_exposed_options', t('Please insert a list of integer numeric values separated by colons: e.g: 10, 20, 50, 100'));
+        }
+        break;
     }
   }
 
@@ -1655,6 +1729,9 @@ class views_plugin_display extends views
       case 'items_per_page':
         $this->set_option($section, intval($form_state['values'][$section]));
         $this->set_option('offset', intval($form_state['values']['offset']));
+        $this->set_option('items_per_page_exposed', $form_state['values']['items_per_page_exposed']);
+        $this->set_option('items_per_page_label', $form_state['values']['items_per_page_label']);
+        $this->set_option('items_per_page_exposed_options', $form_state['values']['items_per_page_exposed_options']);
         break;
       case 'use_more':
         $this->set_option($section, intval($form_state['values'][$section]));
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.3
diff -u -p -r1.1.2.3 views_plugin_exposed_form.inc
--- plugins/views_plugin_exposed_form.inc	30 Nov 2009 21:54:19 -0000	1.1.2.3
+++ plugins/views_plugin_exposed_form.inc	2 Dec 2009 15:34:38 -0000
@@ -89,9 +89,33 @@ class views_plugin_exposed_form extends 
 
   function post_render(&$output) { }
 
-  function pre_execute() { }
+  function pre_execute() {
+    if ($this->view->display_handler->items_per_page_exposed()) {
+      if (isset($_GET['items_per_page'])) {
+        $this->view->set_items_per_page($_GET['items_per_page']);
+      }
+    }    
+  }
 
-  function exposed_form_alter(&$form, &$form_state) { }
+  function exposed_form_alter(&$form, &$form_state) {
+    if ($this->view->display_handler->items_per_page_exposed()) {     
+      $options = explode(',', $this->view->display_handler->get_option('items_per_page_exposed_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' => $this->view->display_handler->get_option('items_per_page_label'),      
+          '#options' => $sanitized_options,
+          '#default_value' => $this->view->display_handler->get_option('items_per_page'),
+        );
+      }
+      $form['submit']['#weight'] = 10;
+    }
+  }
   
   function exposed_form_validate(&$form, &$form_state) { }
   
