[ Index ]

PHP Cross Reference of Drupal 6 (yi-drupal)

title

Body

[close]

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

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


Generated: Mon Jul 9 18:01:44 2012 Cross-referenced by PHPXref 0.7