00001 <?php
00002
00008 class views_handler_field_counter extends views_handler_field {
00009 function option_definition() {
00010 $options = parent::option_definition();
00011 $options['counter_start'] = array('default' => 1);
00012 return $options;
00013 }
00014
00015 function options_form(&$form, &$form_state) {
00016 $form['counter_start'] = array(
00017 '#type' => 'textfield',
00018 '#title' => t('Starting value'),
00019 '#default_value' => $this->options['counter_start'],
00020 '#description' => t('Specify the number the counter should start at.'),
00021 '#size' => 2,
00022 );
00023
00024 parent::options_form($form, $form_state);
00025 }
00026
00027 function query() {
00028
00029 }
00030
00031 function render($values) {
00032
00033
00034 $count = is_numeric($this->options['counter_start']) ? $this->options['counter_start'] - 1 : 0;
00035 $pager = $this->view->query->pager;
00036
00037 if ($pager->use_pager()) {
00038 $count += ($pager->get_items_per_page() * $pager->get_current_page() + $pager->get_offset());
00039 }
00040
00041 $count += $this->view->row_index + 1;
00042
00043 return $count;
00044 }
00045 }