Projet

Général

Profil

Révision 4003efde

Ajouté par Assos Assos il y a environ 4 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/handlers/views_handler_area_result.inc
102 102
    }
103 103
    // Send the output.
104 104
    if (!empty($total) || !empty($this->options['empty'])) {
105
      $output .= filter_xss_admin(str_replace(array_keys($replacements), array_values($replacements), $format));
105
      // We don't want to sanitize with filter_xss_admin() here because Views
106
      // administrators are trusted users and should be allowed to insert
107
      // arbitrary markup.
108
      $output .= str_replace(array_keys($replacements), array_values($replacements), $format);
106 109
    }
107 110
    return $output;
108 111
  }
drupal7/sites/all/modules/views/handlers/views_handler_argument_string.inc
225 225
    if ($formula) {
226 226
      $placeholder = $this->placeholder();
227 227
      if (count($this->value) > 1) {
228
        $placeholder = "($placeholder)";
228
        $field .= " $operator ($placeholder)";
229
      }
230
      else {
231
        $field .= " $operator $placeholder";
229 232
      }
230
      $field .= " $operator $placeholder";
231 233
      $placeholders = array(
232 234
        $placeholder => $argument,
233 235
      );
drupal7/sites/all/modules/views/handlers/views_handler_field.inc
159 159
              '@identifier' => $identifier,
160 160
              '@table' => $info['table'],
161 161
            );
162
            debug(t('Handler @handler tried to add additional_field @identifier but @table could not be added!', $t_args));
162
            debug(t('Handler @handler tried to add additional field @identifier but @table could not be added.', $t_args));
163 163
            $this->aliases[$identifier] = 'broken';
164 164
            continue;
165 165
          }
......
1249 1249
    // displays such as XML where we should not mess with tags.
1250 1250
    $value = $alter['text'];
1251 1251
    $value = strtr($value, $tokens);
1252
    // User might already used '%5B' and '%5D' instead of literal [ and ].
1253
    // After token replacements, we need to convert those codes to literal
1254
    // square bracket characters. Otherwise problems like comment #5 and #6 of
1255
    // https://www.drupal.org/node/578772 will happen.
1256
    // We could have used rawurldecode() also, but not sure about the consequences.
1257
    $value = strtr($value, array('%5B' => '[', '%5D' => ']'));
1252 1258

  
1253 1259
    return $value;
1254 1260
  }
drupal7/sites/all/modules/views/handlers/views_handler_filter.inc
1387 1387
      // Various ways to check for the absence of non-required input.
1388 1388
      if (empty($this->options['expose']['required'])) {
1389 1389
        if ($this->operator == 'empty' || $this->operator == 'not empty') {
1390
          $value = is_array($value) ? $value['value'] : $value;
1390
          if (is_array($value) && array_key_exists('value', $value)) {
1391
            $value = $value['value'];
1392
          }
1391 1393
          $this->operator = ($this->operator == 'empty' && empty($value)) || ($this->operator == 'not empty' && !empty($value)) ? 'not empty' : 'empty';
1392 1394
        }
1393 1395

  
drupal7/sites/all/modules/views/handlers/views_handler_filter_combine.inc
129 129
    foreach ($matches as $match) {
130 130
      $phrase = FALSE;
131 131
      // Strip off phrase quotes.
132
      if ($match[2]{0} == '"') {
132
      if ($match[2][0] == '"') {
133 133
        $match[2] = substr($match[2], 1, -1);
134 134
        $phrase = TRUE;
135 135
      }
drupal7/sites/all/modules/views/handlers/views_handler_filter_numeric.inc
379 379
          'value' => $value,
380 380
        );
381 381
      }
382
      if (!empty($this->options['expose']['use_operator']) && !empty($this->options['expose']['operator_id']) && isset($input[$this->options['expose']['operator_id']])) {
383
        if ($input[$this->options['expose']['operator_id']] === 'empty' || $input[$this->options['expose']['operator_id']] === 'not empty') {
384
          // Parent method will expect a boolean value. We don't ask for a value
385
          // so we'll force "Yes".
386
          $value['value'] = 1;
387
        }
388
      }
382 389
    }
383 390

  
384 391
    $rc = parent::accept_exposed_input($input);
drupal7/sites/all/modules/views/handlers/views_handler_filter_string.inc
300 300
    foreach ($matches as $match) {
301 301
      $phrase = FALSE;
302 302
      // Strip off phrase quotes
303
      if ($match[2]{0} == '"') {
303
      if ($match[2][0] == '"') {
304 304
        $match[2] = substr($match[2], 1, -1);
305 305
        $phrase = TRUE;
306 306
      }
drupal7/sites/all/modules/views/includes/ajax.inc
26 26
    $commands = array();
27 27

  
28 28
    // Remove all of this stuff from $_GET so it doesn't end up in pagers and
29
    // tablesort URLs.
29
    // tablesort URLs; do not modify $_POST itself but make a new "clean"
30
    // copy to merge it with $_GET later.
31
    $cleaned_post = $_POST;
30 32
    foreach (array('view_name', 'view_display_id', 'view_args', 'view_path', 'view_dom_id', 'pager_element', 'view_base_path', 'ajax_html_ids', 'ajax_page_state') as $key) {
31 33
      if (isset($_GET[$key])) {
32 34
        unset($_GET[$key]);
......
34 36
      if (isset($_REQUEST[$key])) {
35 37
        unset($_REQUEST[$key]);
36 38
      }
37
      if (isset($_POST[$key])) {
38
        unset($_POST[$key]);
39
      if (isset($cleaned_post[$key])) {
40
        unset($cleaned_post[$key]);
39 41
      }
40 42
    }
41 43

  
......
52 54
      $exclude = isset($_POST['page']) ? array('page') : array();
53 55
      // Add all $_POST data to $_GET as many things, such as tablesorts,
54 56
      // exposed filters and paging assume $_GET.
55
      $_GET = $_POST + drupal_get_query_parameters($_GET, $exclude);
57
      $_GET = $cleaned_post + drupal_get_query_parameters($_GET, $exclude);
56 58

  
57 59
      // Overwrite the destination.
58 60
      // @see drupal_get_destination()
drupal7/sites/all/modules/views/includes/analyze.inc
113 113
    if ($display->handler->has_path() && $path = $display->handler->get_option('path')) {
114 114
      $normal_path = drupal_get_normal_path($path);
115 115
      if ($path != $normal_path) {
116
        $ret[] = views_ui_analysis(t('You have configured display %display with a path which is an path alias as well. This might lead to unwanted effects so better use an internal path.', array('%display' => $display->display_title)), 'warning');
116
        $ret[] = views_ui_analysis(t('You have configured display %display with a path which is a path alias as well. This might lead to unwanted effects so you should use an internal path.', array('%display' => $display->display_title)), 'warning');
117 117
      }
118 118
    }
119 119
  }
drupal7/sites/all/modules/views/includes/view.inc
1000 1000
    // Let the handlers interact with each other if they really want.
1001 1001
    $this->_pre_query();
1002 1002

  
1003
    $exposed_form = FALSE;
1003 1004
    if ($this->display_handler->uses_exposed()) {
1004 1005
      $exposed_form = $this->display_handler->get_plugin('exposed_form');
1005 1006
      // (1) Record the errors before rendering the exposed form widgets.
......
1080 1081
    $this->style_plugin->query($this->display_handler->use_group_by());
1081 1082

  
1082 1083
    // Allow exposed form to affect the query.
1083
    if (isset($exposed_form)) {
1084
    if ($exposed_form) {
1084 1085
      $exposed_form->query();
1085 1086
    }
1086 1087

  
drupal7/sites/all/modules/views/js/ajax_view.js
80 80
    // Add a trigger to update this view specifically.
81 81
    var self_settings = this.element_settings;
82 82
    self_settings.event = 'RefreshView';
83
    this.refreshViewAjax = new Drupal.ajax(this.selector, this.$view, self_settings);
83
    var self = this;
84
    this.$view.once('refresh', function () {
85
      self.refreshViewAjax = new Drupal.ajax(self.selector, self.$view, self_settings);
86
    });
84 87
  };
85 88

  
86 89
  Drupal.views.ajaxView.prototype.attachExposedFormAjax = function() {
......
101 104
   * Attach the ajax behavior to each link.
102 105
   */
103 106
  Drupal.views.ajaxView.prototype.attachPagerAjax = function() {
104
    this.$view.find('ul.pager > li > a, th.views-field a, .attachment .views-summary a')
107
    this.$view.find('ul.pager > li > a, ol.pager > li > a, th.views-field a, .attachment .views-summary a')
105 108
      .each(jQuery.proxy(this.attachPagerLinkAjax, this));
106 109
  };
107 110

  
108 111
  /**
109
   * Attach the ajax behavior to a singe link.
112
   * Attach the ajax behavior to a single link.
110 113
   */
111 114
  Drupal.views.ajaxView.prototype.attachPagerLinkAjax = function(id, link) {
112 115
    var $link = $(link);
116
    var viewData = {};
117
    var href = $link.attr('href');
113 118
    // Don't attach to pagers inside nested views.
114
    if ($link.closest('.view')[0] !== this.$view[0]) {
119
    if ($link.closest('.view')[0] !== this.$view[0] &&
120
      $link.closest('.view').parent().hasClass('attachment') === false) {
115 121
      return;
116 122
    }
117
    var viewData = {};
118
    var href = $link.attr('href');
119 123

  
120 124
    // Provide a default page if none has been set. This must be done
121 125
    // prior to merging with settings to avoid accidentally using the
......
127 131
    // Construct an object using the settings defaults and then overriding
128 132
    // with data specific to the link.
129 133
    $.extend(
130
    viewData,
131
    this.settings,
132
    Drupal.Views.parseQueryString(href),
133
    // Extract argument data from the URL.
134
    Drupal.Views.parseViewArgs(href, this.settings.view_base_path)
134
      viewData,
135
      this.settings,
136
      Drupal.Views.parseQueryString(href),
137
      // Extract argument data from the URL.
138
      Drupal.Views.parseViewArgs(href, this.settings.view_base_path)
135 139
    );
136 140

  
137 141
    // For anchor tags, these will go to the target of the anchor rather
drupal7/sites/all/modules/views/js/exposed-form-ajax.js
1
/**
2
 * @file
3
 * Handles Views' exposed form AJAX data submission.
4
 */
5

  
6
(function ($) {
7
  'use strict';
8

  
9
  /**
10
   * Gets Form build info from settings and adds it to ajax data.
11
   *
12
   * @see views_exposed_form_ajax_enable().
13
   */
14
  Drupal.behaviors.ViewsExposedFormAjax = {
15
    attach: function (context, settings) {
16
      for (var ajaxObject in Drupal.ajax) {
17
        for (var name in Drupal.settings.ViewsExposedFormInfo) {
18
          if (Drupal.ajax[ajaxObject].options && Drupal.ajax[ajaxObject].options.data._triggering_element_name === name) {
19
            jQuery.extend(Drupal.ajax[ajaxObject].options.data, Drupal.settings.ViewsExposedFormInfo[name]);
20
          }
21
        }
22
      }
23
    }
24
  };
25

  
26
})(jQuery);
drupal7/sites/all/modules/views/js/views-admin.js
231 231
    return;
232 232
  }
233 233
  var $addDisplayDropdown = $('<li class="add"><a href="#"><span class="icon add"></span>' + Drupal.t('Add') + '</a><ul class="action-list" style="display:none;"></ul></li>');
234
  var $displayButtons = $menu.nextAll('input.add-display').detach();
234
  var $displayButtons = $menu.nextAll('.add-display').detach();
235 235
  $displayButtons.appendTo($addDisplayDropdown.find('.action-list')).wrap('<li>')
236 236
    .parent().first().addClass('first').end().last().addClass('last');
237 237
  // Remove the 'Add ' prefix from the button labels since they're being palced
drupal7/sites/all/modules/views/modules/comment.views.inc
419 419
    ),
420 420
  );
421 421

  
422
  $data['comment']['cid'] = array(
423
    'title' => t('Comment id'),
424
    'help' => t('Unique identifier for the comment.'),
425
    'filter' => array(
426
      'handler' => 'views_handler_filter_numeric',
427
    ),
428
    'argument' => array(
429
      'handler' => 'views_handler_argument_numeric',
430
    ),
431
    'field' => array(
432
      'handler' => 'views_handler_field_numeric',
433
    ),
434
  );
435

  
436 422
  $data['comment']['uid'] = array(
437 423
    'title' => t('Author uid'),
438 424
    'help' => t('If you need more fields than the uid add the comment: author relationship'),
drupal7/sites/all/modules/views/modules/locale/views_handler_field_locale_language.inc
39 39
   * {@inheritdoc}
40 40
   */
41 41
  public function render($values) {
42
    $languages = locale_language_list(empty($this->options['native_language']) ? 'name' : 'native');
42
    $languages = views_language_list(empty($this->options['native_language']) ? 'name' : 'native');
43 43
    $value = $this->get_value($values);
44 44
    return isset($languages[$value]) ? $languages[$value] : '';
45 45
  }
drupal7/sites/all/modules/views/modules/system.views.inc
112 112
  $data['file_managed']['extension'] = array(
113 113
    'title' => t('Extension'),
114 114
    'help' => t('The extension of the file.'),
115
    'real field' => 'filename',
115
    'real field' => 'uri',
116 116
    'field' => array(
117 117
      'handler' => 'views_handler_field_file_extension',
118 118
      'click sortable' => FALSE,
drupal7/sites/all/modules/views/modules/taxonomy/views_handler_field_term_link_edit.inc
76 76
    $term->vocabulary_machine_name = $values->{$this->aliases['vocabulary_machine_name']};
77 77
    if ($data && taxonomy_term_edit_access($term)) {
78 78
      $text = !empty($this->options['text']) ? $this->options['text'] : t('edit');
79
      $this->options['alter']['make_link'] = TRUE;
79 80
      $this->options['alter']['path'] = "taxonomy/term/$data/edit";
80 81
      $this->options['alter']['query'] = drupal_get_destination();
81 82
      return $text;
drupal7/sites/all/modules/views/modules/taxonomy/views_handler_filter_term_node_tid.inc
152 152
      }
153 153
    }
154 154
    else {
155
      $options = array();
155 156
      if (!empty($this->options['hierarchy']) && $this->options['limit']) {
156 157
        $tree = taxonomy_get_tree($vocabulary->vid, 0, NULL, TRUE);
158
        $options = array();
157 159
        if (!empty($tree)) {
158 160
          if (!empty($this->options['optgroups'])) {
159 161
            foreach ($tree as $term) {
......
174 176
        }
175 177
      }
176 178
      else {
177
        $options = array();
178 179
        $query = db_select('taxonomy_term_data', 'td');
179 180
        $query->innerJoin('taxonomy_vocabulary', 'tv', 'td.vid = tv.vid');
180 181
        $query->fields('td');
drupal7/sites/all/modules/views/modules/translation/views_handler_relationship_translation.inc
34 34
      'current' => t('Current language'),
35 35
      'default' => t('Default language'),
36 36
    );
37
    $options = array_merge($options, locale_language_list());
37
    $options = array_merge($options, views_language_list());
38 38
    $form['language'] = array(
39 39
      '#type' => 'select',
40 40
      '#options' => $options,
drupal7/sites/all/modules/views/modules/user/views_handler_field_user_roles.inc
20 20
    $this->additional_fields['uid'] = array('table' => 'users', 'field' => 'uid');
21 21
  }
22 22

  
23
  function option_definition() {
24
    $options = parent::option_definition();
25
    $options['display_roles'] = array('default' => array());
26

  
27
    return $options;
28
  }
29

  
30
  function options_form(&$form, &$form_state) {
31
    $roles = user_roles(TRUE);
32
    unset($roles[DRUPAL_AUTHENTICATED_RID]);
33
    if (!empty($roles)) {
34
      $form['display_roles'] = array(
35
        '#type' => 'checkboxes',
36
        '#title' => t('Only display the selected roles'),
37
        '#description' => t("If no roles are selected, all of the user's roles will be shown."),
38
        '#options' => $roles,
39
        '#default_value' => $this->options['display_roles'],
40
      );
41
    }
42
    parent::options_form($form, $form_state);
43
  }
44

  
23 45
  /**
24 46
   * {@inheritdoc}
25 47
   */
......
40 62
    }
41 63

  
42 64
    if ($uids) {
43
      $result = db_query("SELECT u.uid, u.rid, r.name FROM {role} r INNER JOIN {users_roles} u ON u.rid = r.rid WHERE u.uid IN (:uids) ORDER BY r.name",
44
        array(':uids' => $uids));
65
      $rids = array_filter($this->options['display_roles']);
66
      if (!empty($rids)) {
67
        $result = db_query("SELECT u.uid, u.rid, r.name FROM {role} r INNER JOIN {users_roles} u ON u.rid = r.rid WHERE u.uid IN (:uids) AND r.rid IN (:rids) ORDER BY r.name",
68
          array(':uids' => $uids, ':rids' => $rids));
69
      }
70
      else {
71
        $result = db_query("SELECT u.uid, u.rid, r.name FROM {role} r INNER JOIN {users_roles} u ON u.rid = r.rid WHERE u.uid IN (:uids) ORDER BY r.name",
72
          array(':uids' => $uids));
73
      }
45 74
      foreach ($result as $role) {
46 75
        $this->items[$role->uid][$role->rid]['role'] = check_plain($role->name);
47 76
        $this->items[$role->uid][$role->rid]['rid'] = $role->rid;
......
53 82
   * {@inheritdoc}
54 83
   */
55 84
  public function render_item($count, $item) {
56
    return $item['role'];
85
    return t($item['role']);
57 86
  }
58 87

  
59 88
  /**
drupal7/sites/all/modules/views/plugins/views_plugin_display.inc
314 314
        }
315 315
      }
316 316
      $pager = $this->get_plugin('pager');
317
      if (isset($pager) && $pager->uses_exposed()) {
317
      if ($pager && $pager->uses_exposed()) {
318 318
        $this->has_exposed = TRUE;
319 319
        return TRUE;
320 320
      }
......
1400 1400
      '***DEFAULT_LANGUAGE***' => t("Default site language"),
1401 1401
      LANGUAGE_NONE => t('Language neutral'),
1402 1402
    );
1403
    if (module_exists('locale')) {
1404
      $languages = array_merge($languages, locale_language_list());
1405
    }
1403
    $languages = array_merge($languages, views_language_list());
1404

  
1406 1405
    $field_language = array();
1407 1406
    $options['field_language'] = array(
1408 1407
      'category' => 'other',
drupal7/sites/all/modules/views/plugins/views_plugin_display_page.inc
87 87
    $path = implode('/', $bits);
88 88

  
89 89
    $access_plugin = $this->get_plugin('access');
90
    if (!isset($access_plugin)) {
90
    if (!$access_plugin) {
91 91
      $access_plugin = views_get_plugin('access', 'none');
92 92
    }
93 93

  
drupal7/sites/all/modules/views/plugins/views_plugin_style.inc
71 71
  public function destroy() {
72 72
    parent::destroy();
73 73

  
74
    if (isset($this->row_plugin)) {
74
    if ($this->row_plugin) {
75 75
      $this->row_plugin->destroy();
76 76
    }
77 77
  }
......
625 625
   */
626 626
  public function query() {
627 627
    parent::query();
628
    if (isset($this->row_plugin)) {
628
    if ($this->row_plugin) {
629 629
      $this->row_plugin->query();
630 630
    }
631 631
  }
drupal7/sites/all/modules/views/tests/comment/views_handler_argument_comment_user_uid.test
35 35
    return comment_save((object) $comment);
36 36
  }
37 37

  
38
  function setUp() {
39
    parent::setUp();
38
  /**
39
   * {@inheritdoc}
40
   */
41
  public function setUp(array $modules = array()) {
42
    parent::setUp($modules);
40 43

  
41 44
    // Add two users, create a node with the user1 as author and another node
42 45
    // with user2 as author. For the second node add a comment from user1.
drupal7/sites/all/modules/views/tests/field/views_fieldapi.test
119 119
    );
120 120
  }
121 121

  
122
  function setUp() {
123
    parent::setUp();
122
  /**
123
   * {@inheritdoc}
124
   */
125
  public function setUp(array $modules = array()) {
126
    parent::setUp($modules);
124 127

  
125 128
    $langcode = LANGUAGE_NONE;
126 129

  
......
285 288
    );
286 289
  }
287 290

  
288
  protected function setUp() {
289
    parent::setUp();
291
  /**
292
   * {@inheritdoc}
293
   */
294
  public function setUp(array $modules = array()) {
295
    parent::setUp($modules);
290 296

  
291 297
    // Setup basic fields.
292 298
    $this->setUpFields(3);
drupal7/sites/all/modules/views/tests/handlers/views_handler_argument_string.test
1
<?php
2
/**
3
 * @file
4
 * Definition of ViewsHandlerArgumentNullTest.
5
 */
6

  
7
/**
8
 * Tests the core views_handler_argument_string handler.
9
 */
10
class ViewsHandlerArgumentStringTest extends ViewsSqlTest {
11
  public static function getInfo() {
12
    return array(
13
      'name' => 'Argument: String',
14
      'description' => 'Test the core views_handler_argument_string handler.',
15
      'group' => 'Views Handlers',
16
    );
17
  }
18

  
19
  /**
20
   * Tests the glossary feature.
21
   */
22
  function testGlossary() {
23
    // Setup some nodes, one with a, two with b and three with c.
24
    $counter = 1;
25
    foreach (array('a', 'b', 'c') as $char) {
26
      for ($i = 0; $i < $counter; $i++) {
27
        $edit = array(
28
          'title' => $char . $this->randomName(),
29
        );
30
        $this->drupalCreateNode($edit);
31
      }
32
    }
33

  
34
    $view = $this->viewGlossary();
35
    $view->init_display();
36
    $this->executeView($view);
37

  
38
    $count_field = 'nid';
39
    foreach ($view->result as &$row) {
40
      if (strpos($row->node_title, 'a') === 0) {
41
        $this->assertEqual(1, $row->{$count_field});
42
      }
43
      if (strpos($row->node_title, 'b') === 0) {
44
        $this->assertEqual(2, $row->{$count_field});
45
      }
46
      if (strpos($row->node_title, 'c') === 0) {
47
        $this->assertEqual(3, $row->{$count_field});
48
      }
49
    }
50
  }
51

  
52
  /**
53
   * Provide a test view for testGlossary.
54
   *
55
   * @see testGlossary
56
   *
57
   * @return view
58
   */
59
  function viewGlossary() {
60
    $view = new view();
61
    $view->name = 'test_glossary';
62
    $view->description = '';
63
    $view->tag = 'default';
64
    $view->base_table = 'node';
65
    $view->human_name = 'test_glossary';
66
    $view->core = 7;
67
    $view->api_version = '3.0';
68
    $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
69

  
70
    /* Display: Master */
71
    $handler = $view->new_display('default', 'Master', 'default');
72
    $handler->display->display_options['access']['type'] = 'perm';
73
    $handler->display->display_options['cache']['type'] = 'none';
74
    $handler->display->display_options['query']['type'] = 'views_query';
75
    $handler->display->display_options['exposed_form']['type'] = 'basic';
76
    $handler->display->display_options['pager']['type'] = 'full';
77
    $handler->display->display_options['style_plugin'] = 'default';
78
    $handler->display->display_options['row_plugin'] = 'fields';
79
    /* Field: Content: Title */
80
    $handler->display->display_options['fields']['title']['id'] = 'title';
81
    $handler->display->display_options['fields']['title']['table'] = 'node';
82
    $handler->display->display_options['fields']['title']['field'] = 'title';
83
    $handler->display->display_options['fields']['title']['label'] = '';
84
    /* Contextual filter: Content: Title */
85
    $handler->display->display_options['arguments']['title']['id'] = 'title';
86
    $handler->display->display_options['arguments']['title']['table'] = 'node';
87
    $handler->display->display_options['arguments']['title']['field'] = 'title';
88
    $handler->display->display_options['arguments']['title']['default_argument_type'] = 'fixed';
89
    $handler->display->display_options['arguments']['title']['summary']['number_of_records'] = '0';
90
    $handler->display->display_options['arguments']['title']['summary']['format'] = 'default_summary';
91
    $handler->display->display_options['arguments']['title']['summary_options']['items_per_page'] = '25';
92
    $handler->display->display_options['arguments']['title']['glossary'] = TRUE;
93
    $handler->display->display_options['arguments']['title']['limit'] = '1';
94

  
95
    return $view;
96
  }
97

  
98
}
drupal7/sites/all/modules/views/tests/handlers/views_handler_field.test
24 24
  }
25 25

  
26 26
  /**
27
   *
27
   * {@inheritdoc}
28 28
   */
29
  protected function setUp() {
30
    parent::setUp();
29
  public function setUp(array $modules = array()) {
30
    parent::setUp($modules);
31

  
31 32
    $this->column_map = array(
32 33
      'views_test_name' => 'name',
33 34
    );
drupal7/sites/all/modules/views/tests/handlers/views_handler_field_xss.test
29 29
    return $map;
30 30
  }
31 31

  
32

  
33 32
  function viewsData() {
34 33
    $data = parent::viewsData();
35 34
    $data['views_test']['name']['field']['handler'] = 'views_handler_field_xss';
drupal7/sites/all/modules/views/tests/handlers/views_handler_filter_combine.test
19 19
    );
20 20
  }
21 21

  
22
  function setUp() {
23
    parent::setUp();
22
  /**
23
   * {@inheritdoc}
24
   */
25
  public function setUp(array $modules = array()) {
26
    parent::setUp($modules);
27

  
24 28
    $this->column_map = array(
25 29
      'views_test_name' => 'name',
26 30
      'views_test_job' => 'job',
drupal7/sites/all/modules/views/tests/handlers/views_handler_filter_date.test
17 17
    );
18 18
  }
19 19

  
20
  function setUp() {
21
    parent::setUp();
20
  /**
21
   * {@inheritdoc}
22
   */
23
  public function setUp(array $modules = array()) {
24
    parent::setUp($modules);
25

  
22 26
    // Add some basic test nodes.
23 27
    $this->nodes = array();
24 28
    $this->nodes[] = $this->drupalCreateNode(array('created' => 100000));
drupal7/sites/all/modules/views/tests/handlers/views_handler_filter_equality.test
17 17
    );
18 18
  }
19 19

  
20
  function setUp() {
21
    parent::setUp();
20
  /**
21
   * {@inheritdoc}
22
   */
23
  public function setUp(array $modules = array()) {
24
    parent::setUp($modules);
25

  
22 26
    $this->column_map = array(
23 27
      'views_test_name' => 'name',
24 28
    );
drupal7/sites/all/modules/views/tests/handlers/views_handler_filter_numeric.test
19 19
    );
20 20
  }
21 21

  
22
  function setUp() {
23
    parent::setUp();
22
  /**
23
   * {@inheritdoc}
24
   */
25
  protected function dataSet() {
26
    $data_set = parent::dataSet();
27
    $data_set[] = array(
28
      'name' => 'Charles',
29
      'age' => NULL,
30
      'job' => 'Bassist',
31
        'created' => gmmktime(6, 30, 10, 1, 1, 2001),
32
    );
33
    return $data_set;
34
  }
35

  
36
  /**
37
   * {@inheritdoc}
38
   */
39
  protected function schemaDefinition() {
40
    $schema = parent::schemaDefinition();
41
    $schema['views_test']['fields']['age']['not null'] = FALSE;
42
    $schema['views_test']['indexes'] = array();
43
    return $schema;
44
  }
45

  
46
  /**
47
   * {@inheritdoc}
48
   */
49
  public function setUp(array $modules = array()) {
50
    parent::setUp($modules);
51

  
24 52
    $this->column_map = array(
25 53
      'views_test_name' => 'name',
26 54
      'views_test_age' => 'age',
......
114 142
    );
115 143
    $this->assertIdenticalResultset($view, $resultset, $this->column_map);
116 144

  
117
    // test not between.
145
    // Test not between.
118 146
    $view->delete();
119 147
    $view = $this->getBasicView();
120 148

  
......
182 210
    $filters = $this->getGroupedExposedFilters();
183 211
    $view = $this->getBasicPageView();
184 212

  
185
    // Filter: Age, Operator: between, Value: 26 and 29
213
    // Filter: Age, Operator: not between, Value: 26 and 29
186 214
    $filters['age']['group_info']['default_group'] = 3;
187 215
    $view->set_display('page_1');
188 216
    $view->display['page_1']->handler->override_option('filters', $filters);
......
221 249
    ));
222 250

  
223 251
    $this->executeView($view);
224
    $resultset = array();
252
    $resultset = array(
253
      array(
254
        'name' => 'Charles',
255
        'age' => NULL,
256
      ),
257
    );
225 258
    $this->assertIdenticalResultset($view, $resultset, $this->column_map);
226 259

  
227 260
    $view->delete();
......
275 308
    $view->display['page_1']->handler->override_option('filters', $filters);
276 309

  
277 310
    $this->executeView($view);
278
    $resultset = array();
311
    $resultset = array(
312
      array(
313
        'name' => 'Charles',
314
        'age' => NULL,
315
      ),
316
    );
279 317
    $this->assertIdenticalResultset($view, $resultset, $this->column_map);
280 318
  }
281 319

  
......
346 384
    }
347 385
  }
348 386

  
387
  /**
388
   * Tests exposed numeric filter with exposed operator.
389
   */
390
  public function testFilterNumericExposedOperator() {
391
    $this->applyFilterNumericExposedOperator('=', array('value' => '27'), array(
392
      array(
393
        'name' => 'George',
394
        'age' => 27,
395
      ),
396
    ));
397
    $this->applyFilterNumericExposedOperator('<', array('value' => '27'), array(
398
      array(
399
        'name' => 'John',
400
        'age' => 25,
401
      ),
402
      array(
403
        'name' => 'Paul',
404
        'age' => 26,
405
      ),
406
    ));
407
    $this->applyFilterNumericExposedOperator('<=', array(
408
      'value' => '27',
409
    ), array(
410
      array(
411
        'name' => 'John',
412
        'age' => 25,
413
      ),
414
      array(
415
        'name' => 'George',
416
        'age' => 27,
417
      ),
418
      array(
419
        'name' => 'Paul',
420
        'age' => 26,
421
      ),
422
    ));
423
    $this->applyFilterNumericExposedOperator('!=', array(
424
      'value' => '27',
425
    ), array(
426
      array(
427
        'name' => 'John',
428
        'age' => 25,
429
      ),
430
      array(
431
        'name' => 'Ringo',
432
        'age' => 28,
433
      ),
434
      array(
435
        'name' => 'Paul',
436
        'age' => 26,
437
      ),
438
      array(
439
        'name' => 'Meredith',
440
        'age' => 30,
441
      ),
442
    ));
443
    $this->applyFilterNumericExposedOperator('>=', array(
444
      'value' => '27',
445
    ), array(
446
      array(
447
        'name' => 'George',
448
        'age' => 27,
449
      ),
450
      array(
451
        'name' => 'Ringo',
452
        'age' => 28,
453
      ),
454
      array(
455
        'name' => 'Meredith',
456
        'age' => 30,
457
      ),
458
    ));
459
    $this->applyFilterNumericExposedOperator('>', array('value' => '27'), array(
460
      array(
461
        'name' => 'Ringo',
462
        'age' => 28,
463
      ),
464
      array(
465
        'name' => 'Meredith',
466
        'age' => 30,
467
      ),
468
    ));
469
    $this->applyFilterNumericExposedOperator('between', array(
470
      'min' => '28',
471
      'max' => '31',
472
    ), array(
473
      array(
474
        'name' => 'Ringo',
475
        'age' => 28,
476
      ),
477
      array(
478
        'name' => 'Meredith',
479
        'age' => 30,
480
      ),
481
    ));
482
    $this->applyFilterNumericExposedOperator('not between', array(
483
      'min' => '28',
484
      'max' => '31',
485
    ), array(
486
      array(
487
        'name' => 'John',
488
        'age' => 25,
489
      ),
490
      array(
491
        'name' => 'George',
492
        'age' => 27,
493
      ),
494
      array(
495
        'name' => 'Ringo',
496
        'age' => 28,
497
      ),
498
      array(
499
        'name' => 'Paul',
500
        'age' => 26,
501
      ),
502
    ));
503
    $this->applyFilterNumericExposedOperator('empty', array(), array(
504
      array(
505
        'name' => 'Charles',
506
        'age' => NULL,
507
      ),
508
    ));
509
    $this->applyFilterNumericExposedOperator('not empty', array(), array(
510
      array(
511
        'name' => 'John',
512
        'age' => 25,
513
      ),
514
      array(
515
        'name' => 'George',
516
        'age' => 27,
517
      ),
518
      array(
519
        'name' => 'Ringo',
520
        'age' => 28,
521
      ),
522
      array(
523
        'name' => 'Paul',
524
        'age' => 26,
525
      ),
526
      array(
527
        'name' => 'Meredith',
528
        'age' => 30,
529
      ),
530
    ));
531
    $this->applyFilterNumericExposedOperator('regular_expression', array(
532
      'value' => '^(0|[1-9][0-9]*)$',
533
    ), array(
534
      array(
535
        'name' => 'John',
536
        'age' => 25,
537
      ),
538
      array(
539
        'name' => 'George',
540
        'age' => 27,
541
      ),
542
      array(
543
        'name' => 'Ringo',
544
        'age' => 28,
545
      ),
546
      array(
547
        'name' => 'Paul',
548
        'age' => 26,
549
      ),
550
      array(
551
        'name' => 'Meredith',
552
        'age' => 30,
553
      ),
554
    ));
555
    $this->applyFilterNumericExposedOperator('not_regular_expression', array(
556
      'value' => '^(0|[1-9][0-9]*)$',
557
    ), array());
558
  }
559

  
560
  /**
561
   * Tests exposed numeric filter with an individual exposed operator.
562
   *
563
   * @param string $operator
564
   *   Operator to test.
565
   * @param array $value
566
   *   Filter value to use in exposed input. Keys might be 'value', 'min' or
567
   *   'max'. If one of those keys doesn't exist, an empty string is used as the
568
   *   key's value.
569
   * @param array $resultset
570
   *   The expected result set.
571
   */
572
  protected function applyFilterNumericExposedOperator($operator, array $value, array $resultset) {
573
    $exposed_input = array(
574
      'age' => ($value += array(
575
        'value' => '',
576
        'min' => '',
577
        'max' => '',
578
      )),
579
      'age_op' => $operator,
580
    );
581
    $filters = array(
582
      'age' => array(
583
        'id' => 'age',
584
        'table' => 'views_test',
585
        'field' => 'age',
586
        'relationship' => 'none',
587
        'exposed' => TRUE,
588
        'expose' => array(
589
          'operator' => 'age_op',
590
          'label' => 'age',
591
          'identifier' => 'age',
592
          'use_operator' => TRUE,
593
        ),
594
      ),
595
    );
596
    $view = $this->getBasicPageView();
597
    $view->set_display('page_1');
598
    $view->display['page_1']->handler->override_option('filters', $filters);
599
    $view->set_exposed_input($exposed_input);
600
    $this->executeView($view);
601
    $this->assertIdenticalResultset($view, $resultset, $this->column_map, 'Identical result set for ' . $operator . ' with untouched values.');
602
    $view->destroy();
603

  
604
    // Min, max and value fields are shown/hidden only via JS, so they might
605
    // still be set from a previous operation. Assert that this doesn't change
606
    // the expected result set.
607
    $exposed_input['age'] += array(
608
      'value' => '25',
609
      'min' => '28',
610
      'max' => '30',
611
    );
612
    $view = $this->getBasicPageView();
613
    $view->set_display('page_1');
614
    $view->display['page_1']->handler->override_option('filters', $filters);
615
    $view->set_exposed_input($exposed_input);
616
    $this->executeView($view);
617
    $this->assertIdenticalResultset($view, $resultset, $this->column_map, 'Identical result set for ' . $operator . ' with leftover values from previous operation.');
618
  }
349 619

  
350 620
  public function testAllowEmpty() {
351 621
    $view = $this->getBasicView();
drupal7/sites/all/modules/views/tests/handlers/views_handler_filter_string.test
19 19
    );
20 20
  }
21 21

  
22
  function setUp() {
23
    parent::setUp();
22
  /**
23
   * {@inheritdoc}
24
   */
25
  public function setUp(array $modules = array()) {
26
    parent::setUp($modules);
27

  
24 28
    $this->column_map = array(
25 29
      'views_test_name' => 'name',
26 30
    );
drupal7/sites/all/modules/views/tests/handlers/views_handler_manytoone.test
83 83
  /**
84 84
   * {@inheritdoc}
85 85
   */
86
  public function setUp() {
87
    parent::setUp();
86
  public function setUp(array $modules = array()) {
87
    parent::setUp($modules);
88 88

  
89 89
    // Create boolean field.
90 90
    $this->fields[0] = array(
drupal7/sites/all/modules/views/tests/styles/views_plugin_style_jump_menu.test
29 29
  }
30 30

  
31 31
  /**
32
   *
32
   * {@inheritdoc}
33 33
   */
34
  public function setUp() {
35
    parent::setUp();
34
  public function setUp(array $modules = array()) {
35
    parent::setUp($modules);
36

  
36 37
    $this->nodes = array();
37 38
    $this->nodes['page'][] = $this->drupalCreateNode(array('type' => 'page'));
38 39
    $this->nodes['page'][] = $this->drupalCreateNode(array('type' => 'page'));
drupal7/sites/all/modules/views/tests/styles/views_plugin_style_mapping.test
18 18
    );
19 19
  }
20 20

  
21
  public function setUp() {
22
    parent::setUp();
21
  /**
22
   * {@inheritdoc}
23
   */
24
  public function setUp(array $modules = array()) {
25
    parent::setUp($modules);
23 26

  
24 27
    // Reset the plugin data.
25 28
    views_fetch_plugin_data(NULL, NULL, TRUE);
drupal7/sites/all/modules/views/tests/taxonomy/views_handler_relationship_node_term_data.test
31 31
    return $term;
32 32
  }
33 33

  
34
  function setUp() {
35
    parent::setUp();
34
  /**
35
   * {@inheritdoc}
36
   */
37
  public function setUp(array $modules = array()) {
38
    parent::setUp($modules);
36 39

  
37 40
    // $web_user = $this->drupalCreateUser(array('create article content'));
38 41
    // $this->drupalLogin($web_user);
drupal7/sites/all/modules/views/tests/user/views_user.test
34 34
  /**
35 35
   *
36 36
   */
37
  protected function setUp() {
38
    parent::setUp();
37
  public function setUp(array $modules = array()) {
38
    parent::setUp($modules);
39 39

  
40 40
    $this->users[] = $this->drupalCreateUser();
41 41
    $this->users[] = user_load(1);
drupal7/sites/all/modules/views/tests/user/views_user_argument_validate.test
17 17
    );
18 18
  }
19 19

  
20
  function setUp() {
21
    parent::setUp('views');
20
  /**
21
   * {@inheritdoc}
22
   */
23
  public function setUp(array $modules = array()) {
24
    $modules[] = 'views';
25
    parent::setUp($modules);
26

  
22 27
    $this->account = $this->drupalCreateUser();
23 28
  }
24 29

  
drupal7/sites/all/modules/views/tests/views_access.test
20 20
  /**
21 21
   * {@inheritdoc}
22 22
   */
23
  public function setUp() {
24
    parent::setUp();
23
  public function setUp(array $modules = array()) {
24
    parent::setUp($modules);
25 25

  
26 26
    $this->admin_user = $this->drupalCreateUser(array('access all views'));
27 27
    $this->web_user = $this->drupalCreateUser();
......
161 161
    $this->assertTrue(views_access($expected_hook_menu, $argument1, $argument2));
162 162
  }
163 163

  
164
  /**
165
   * Tests access for a view with a missing access plugin.
166
   */
167
  public function testMissingAccessPlugin() {
168
    $view = $this->getMissingAccessPluginTestView();
169

  
170
    $view->set_display('default');
171
    $access_plugin = $view->display_handler->get_plugin('access');
172
    $this->assertFalse($access_plugin);
173

  
174
    $this->assertTrue($view->display_handler->access($this->admin_user), t('Admin-Account should be able to access the view everytime'));
175
    $this->assertTrue($view->display_handler->access($this->web_user));
176
    $this->assertTrue($view->display_handler->access($this->normal_user));
177

  
178
    $hook_menu = $view->execute_hook_menu('page_1');
179
    $this->assertTrue($hook_menu['test_access_missing']['access arguments'][0]);
180

  
181
    $this->assertTrue(views_access(TRUE));
182
  }
183

  
164 184
  function view_access_none() {
165 185
    $view = new view;
166 186
    $view->name = 'test_access_none';
......
285 305

  
286 306
    return $view;
287 307
  }
308

  
309
  /**
310
   * Generates a view with an access plugin that doesn't exist.
311
   */
312
  protected function getMissingAccessPluginTestView() {
313
    $view = new view();
314
    $view->name = 'test_access_missing';
315
    $view->description = '';
316
    $view->tag = '';
317
    $view->view_php = '';
318
    $view->base_table = 'node';
319
    $view->is_cacheable = FALSE;
320
    $view->api_version = 2;
321
    $view->disabled = FALSE; /* Edit this to true to make a default view disabled initially */
322

  
323
    /* Display: Master */
324
    $handler = $view->new_display('default', 'Master', 'default');
325
    $handler->display->display_options['access']['type'] = 'does_not_exist';
326
    $handler->display->display_options['cache']['type'] = 'none';
327
    $handler->display->display_options['exposed_form']['type'] = 'basic';
328
    $handler->display->display_options['pager']['type'] = 'full';
329
    $handler->display->display_options['style_plugin'] = 'default';
330
    $handler->display->display_options['row_plugin'] = 'fields';
331

  
332
    $handler = $view->new_display('page', 'Page', 'page_1');
333
    $handler->display->display_options['path'] = 'test_access_missing';
334

  
335
    return $view;
336
  }
337

  
288 338
}
drupal7/sites/all/modules/views/tests/views_ajax.test
17 17
    );
18 18
  }
19 19

  
20
  public function setUp() {
21
    parent::setUp('views', 'views_test');
20
  /**
21
   * {@inheritdoc}
22
   */
23
  public function setUp(array $modules = array()) {
24
    parent::setUp($modules);
25

  
22 26
    // Create a second node.
23 27
    $this->drupalCreateNode(array('type' => 'article', 'status' => NODE_PUBLISHED));
24 28
  }
drupal7/sites/all/modules/views/tests/views_analyze.test
17 17
    );
18 18
  }
19 19

  
20
  public function setUp() {
21
    parent::setUp('views_ui');
22
    module_enable(array('views_ui'));
20
  /**
21
   * {@inheritdoc}
22
   */
23
  public function setUp(array $modules = array()) {
24
    parent::setUp($modules);
25

  
23 26
    // @todo Figure out why it's required to clear the cache here.
24 27
    views_module_include('views_default', TRUE);
25 28
    views_get_all_views(TRUE);
drupal7/sites/all/modules/views/tests/views_argument_default.test
9 9
 * Basic test for pluggable argument default.
10 10
 */
11 11
class ViewsArgumentDefaultTest extends ViewsSqlTest {
12

  
12 13
  public static function getInfo() {
13 14
    return array(
14 15
      'name' => 'Argument_default',
......
17 18
    );
18 19
  }
19 20

  
20
  public function setUp() {
21
    parent::setUp('views');
21
  /**
22
   * {@inheritdoc}
23
   */
24
  public function setUp(array $modules = array()) {
25
    parent::setUp($modules);
22 26

  
23 27
    $this->random = $this->randomString();
24 28
  }
drupal7/sites/all/modules/views/tests/views_clone.test
33 33
  /**
34 34
   * {@inheritdoc}
35 35
   */
36
  public function setUp() {
37
    parent::setUp();
36
  public function setUp(array $modules = array()) {
37
    parent::setUp($modules);
38 38

  
39 39
    $vocabulary = taxonomy_vocabulary_machine_name_load('tags');
40 40
    $this->term = $this->createTerm($vocabulary);
drupal7/sites/all/modules/views/tests/views_exposed_form.test
22 22
  }
23 23

  
24 24
  /**
25
   *
25
   * {@inheritdoc}
26 26
   */
27
  public function setUp() {
28
    parent::setUp('views_ui');
29
    module_enable(array('views_ui'));
27
  public function setUp(array $modules = array()) {
28
    parent::setUp($modules);
29

  
30 30
    // @todo Figure out why it's required to clear the cache here.
31 31
    views_module_include('views_default', TRUE);
32 32
    views_get_all_views(TRUE);
drupal7/sites/all/modules/views/tests/views_glossary.test
6 6
 */
7 7

  
8 8
/**
9
 * Tests glossary view ( summary of arguments ).
9
 * Tests the glossary feature.
10 10
 */
11 11
class ViewsGlossaryTestCase extends ViewsSqlTest {
12

  
13
  /**
14
   * {@inheritdoc}
15
   */
12 16
  public static function getInfo() {
13 17
    return array(
14 18
      'name' => 'Glossary Test',
......
17 21
    );
18 22
  }
19 23

  
20
  public function setUp() {
21
    parent::setUp('views');
22
  }
23

  
24 24
  /**
25
   * Tests the default glossary view.
25
   * Tests the glossary feature.
26 26
   */
27 27
  public function testGlossaryView() {
28
    // create a contentype and add some nodes, with a non random title.
28
    // Create a content type and add some nodes, with a non random title.
29 29
    $type = $this->drupalCreateContentType();
30
    $nodes_per_char = array(
30
    $nodes_per_character = array(
31 31
      'd' => 1,
32 32
      'r' => 4,
33 33
      'u' => 10,
......
35 35
      'a' => 3,
36 36
      'l' => 6,
37 37
    );
38
    foreach ($nodes_per_char as $char => $count) {
38
    $nodes = array();
39
    foreach ($nodes_per_character as $character => $count) {
39 40
      $setting = array(
40 41
        'type' => $type->type,
41 42
      );
42 43
      for ($i = 0; $i < $count; $i++) {
43 44
        $node = $setting;
44
        $node['title'] = $char . $this->randomString(3);
45
        $this->drupalCreateNode($node);
45
        $node['title'] = $character . strtolower($this->randomName());
46
        $nodes[$character][] = $this->drupalCreateNode($node);
46 47
      }
47 48
    }
48 49

  
50
    // Sort created nodes the same way the view does, so that we can assert
51
    // correct node ids for each row in the result set later.
52
    foreach ($nodes_per_character as $character => $count) {
53
      usort($nodes[$character], function ($a, $b) {
54
        return strcmp($a->title, $b->title);
55
      });
56
    }
57

  
49 58
    // Execute glossary view.
50 59
    $view = views_get_view('glossary');
51 60
    $view->set_display('attachment');
52 61
    $view->execute_display('attachment');
53 62

  
54
    // Check that the amount of nodes per char.
55
    $result_nodes_per_char = array();
63
    // Check the amount of nodes per character.
56 64
    foreach ($view->result as $item) {
57
      $this->assertEqual($nodes_per_char[$item->title_truncated], $item->num_records);
65
      $this->assertEqual($nodes_per_character[$item->title_truncated], $item->num_records);
66
    }
67
    $view->destroy();
68

  
69
    // Checks that a glossary view with an argument containing one letter
70
    // returns only and all the nodes that start with that letter.
71
    $view = views_get_view('glossary');
72
    $view->init_display();
73
    $this->executeView($view, array('a'));
74
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
75
    $this->assertIdentical($result_count, 3, 'View has 3 results.');
76
    foreach ($view->result as $delta => $item) {
77
      $nid = isset($view->result[$delta]->nid) ? $view->result[$delta]->nid : '0';
78
      $this->assertIdentical($nid, $nodes['a'][$delta]->nid, 'View result ' . (string) (int) $delta . ' has correct node id.');
79
    }
80
    $view->destroy();
81

  
82
    // Checks that a glossary view with an argument containing multiple values
83
    // returns only and all nodes that start with these values.
84
    $view = views_get_view('glossary');
85
    $view->init_display();
86
    $arguments = $view->display_handler->get_option('arguments');
87
    $arguments['title']['break_phrase'] = TRUE;
88
    $view->display_handler->set_option('arguments', $arguments);
89
    $this->executeView($view, array('d+p'));
90
    $expected_result_count = $nodes_per_character['d'] + $nodes_per_character['p'];
91
    $result_count = isset($view->result) && is_array($view->result) ? count($view->result) : 0;
92
    $this->assertIdentical($result_count, 3, 'View has 3 results.');
93
    $nid = isset($view->result[0]->nid) ? $view->result[0]->nid : '0';
94
    $this->assertIdentical($nid, $nodes['d'][0]->nid, 'View result 0 has correct node id.');
95
    $nid = isset($view->result[1]->nid) ? $view->result[1]->nid : '0';
96
    $this->assertIdentical($nid, $nodes['p'][0]->nid, 'View result 1 has correct node id.');
97
    $nid = isset($view->result[2]->nid) ? $view->result[2]->nid : '0';
98
    $this->assertIdentical($nid, $nodes['p'][1]->nid, 'View result 2 has correct node id.');
... Ce différentiel a été tronqué car il excède la taille maximale pouvant être affichée.

Formats disponibles : Unified diff