00001 <?php 00002 00008 class views_plugin_pager_some extends views_plugin_pager { 00009 function summary_title() { 00010 if (!empty($this->options['offset'])) { 00011 return format_plural($this->options['items_per_page'], '@count item, skip @skip', '@count items, skip @skip', array('@count' => $this->options['items_per_page'], '@skip' => $this->options['offset'])); 00012 } 00013 return format_plural($this->options['items_per_page'], '@count item', '@count items', array('@count' => $this->options['items_per_page'])); 00014 } 00015 00016 function option_definition() { 00017 $options = parent::option_definition(); 00018 $options['items_per_page'] = array('default' => 10); 00019 $options['offset'] = array('default' => 0); 00020 00021 return $options; 00022 } 00023 00027 function options_form(&$form, &$form_state) { 00028 parent::options_form($form, $form_state); 00029 $pager_text = $this->display->handler->get_pager_text(); 00030 $form['items_per_page'] = array( 00031 '#title' => $pager_text['items per page title'], 00032 '#type' => 'textfield', 00033 '#description' => $pager_text['items per page description'], 00034 '#default_value' => $this->options['items_per_page'], 00035 ); 00036 00037 $form['offset'] = array( 00038 '#type' => 'textfield', 00039 '#title' => t('Offset'), 00040 '#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.'), 00041 '#default_value' => $this->options['offset'], 00042 ); 00043 } 00044 00045 function use_pager() { 00046 return FALSE; 00047 } 00048 00049 function use_count_query() { 00050 return FALSE; 00051 } 00052 00053 function query() { 00054 $this->view->query->set_limit($this->options['items_per_page']); 00055 $this->view->query->set_offset($this->options['offset']); 00056 } 00057 }