Projet

Général

Profil

Révision 5d12d676

Ajouté par Assos Assos il y a environ 6 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/handlers/views_handler_field_counter.inc
11 11
 * @ingroup views_field_handlers
12 12
 */
13 13
class views_handler_field_counter extends views_handler_field {
14
  function option_definition() {
14

  
15
  /**
16
   * {@inheritdoc}
17
   */
18
  public function option_definition() {
15 19
    $options = parent::option_definition();
16 20
    $options['counter_start'] = array('default' => 1);
17 21
    $options['reverse'] = array('default' => FALSE);
18 22
    return $options;
19 23
  }
20 24

  
21
  function options_form(&$form, &$form_state) {
25
  /**
26
   * {@inheritdoc}
27
   */
28
  public function options_form(&$form, &$form_state) {
22 29
    $form['counter_start'] = array(
23 30
      '#type' => 'textfield',
24 31
      '#title' => t('Starting value'),
......
37 44
    parent::options_form($form, $form_state);
38 45
  }
39 46

  
40
  function query() {
41
    // do nothing -- to override the parent query.
47
  /**
48
   * {@inheritdoc}
49
   */
50
  public function query() {
51
    // Do nothing -- to override the parent query.
42 52
  }
43 53

  
44
  function render($values) {
54
  /**
55
   * {@inheritdoc}
56
   */
57
  public function render($values) {
45 58
    $reverse = empty($this->options['reverse']) ? 1 : -1;
46 59

  
47
    // Note:  1 is subtracted from the counter start value below because the
60
    // Note: 1 is subtracted from the counter start value below because the
48 61
    // counter value is incremented by 1 at the end of this function.
49 62
    $counter_start = is_numeric($this->options['counter_start']) ? $this->options['counter_start'] : 0;
50
    $count = ($reverse == -1) ? count($this->view->result) + $counter_start : $counter_start -1;
63
    $count = ($reverse == -1) ? count($this->view->result) + $counter_start : $counter_start - 1;
51 64
    $pager = $this->view->query->pager;
52 65

  
53 66
    // Get the base count of the pager.
54 67
    if ($pager->use_pager()) {
55 68
      if ($reverse == -1) {
56 69
        $count = ($pager->total_items + $counter_start - ($pager->get_current_page() * $pager->get_items_per_page()) + $pager->get_offset());
57
      } else {
70
      }
71
      else {
58 72
        $count += (($pager->get_items_per_page() * $pager->get_current_page() + $pager->get_offset())) * $reverse;
59 73
      }
60 74
    }
......
63 77

  
64 78
    return $count;
65 79
  }
80

  
66 81
}

Formats disponibles : Unified diff