[ Index ]

PHP Cross Reference of Drupal 6 (gatewave)

title

Body

[close]

/sites/all/modules/views/handlers/ -> views_handler_field_counter.inc (source)

   1  <?php
   2  // $Id: views_handler_field_counter.inc,v 1.3.2.2 2009/11/06 18:19:40 merlinofchaos Exp $
   3  
   4  class views_handler_field_counter extends views_handler_field {
   5    function option_definition() {
   6      $options = parent::option_definition();
   7      $options['counter_start'] = array('default' => 1);
   8      return $options;
   9    }
  10  
  11    function options_form(&$form, &$form_state) {
  12      parent::options_form($form, $form_state);
  13  
  14      $form['counter_start'] = array(
  15        '#type' => 'textfield',
  16        '#title' => t('Starting value'),
  17        '#default_value' => $this->options['counter_start'],
  18        '#description' => t('Specify the number the counter should start at.'),
  19        //'#process' => array('views_process_dependency'),
  20        '#size' => 2,
  21      );
  22    }
  23  
  24    function query() {
  25      // do nothing -- to override the parent query.
  26    }
  27  
  28    function render($values) {
  29      // Note:  1 is subtracted from the counter start value below because the
  30      // counter value is incremented by 1 at the end of this function.
  31      $count = is_numeric($this->options['counter_start']) ? $this->options['counter_start'] - 1 : 0;
  32      $pager = $this->view->pager;
  33      // Get the base count of the pager.
  34      if ($pager['use_pager']) {
  35        $count += ($pager['items_per_page'] * $pager['current_page']) + $pager['offset'];
  36      }
  37      // Add the counter for the current site.
  38      $count += $this->view->row_index + 1;
  39  
  40      return $count;
  41    }
  42  }


Generated: Thu Mar 24 11:18:33 2011 Cross-referenced by PHPXref 0.7