Projet

Général

Profil

Révision 6f57d8c7

Ajouté par Assos Assos il y a environ 9 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/drush/views.drush.inc
42 42
    ),
43 43
    'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_FULL,
44 44
    'aliases' => array('vr'),
45
    'options' => array(
46
      'all' => 'If provided, all views will be reverted.',
47
    ),
45 48
    'examples' => array(
46 49
      'drush vr archive' => 'Reverts the "archive" view.',
47 50
      'drush rln archive frontpage' => 'Reverts the "archive" and "frontpage" view.',
48 51
      'drush vr' => 'Will present you with a list of overridden views to choose from, and an option to revert all overridden views.',
52
      'drush vr --all' => 'Will revert all overridden views.',
49 53
    ),
50 54
  );
51 55
  $items['views-dev'] = array(
......
126 130
    }
127 131
  }
128 132

  
129
  // Return early if there are no overridden views in the system.
133
  // If there are no overridden views in the system, report it.
130 134
  if (empty($overridden)) {
131
    return drush_set_error(dt('There are no overridden views in the system.'));
135
    drush_log(dt('There are no overridden views in the system.'), 'ok');
132 136
  }
133 137

  
134
  // If the user specified in the command the views to be overridden.
135
  if (!empty($viewnames)) {
138
  // If the user provided the "--all" option, revert all views.
139
  if (drush_get_option('all')) {
140
    $i = views_revert_allviews($views);
141
  }
142

  
143
  // If the user specified a list of views on the CLI, revert those.
144
  elseif (!empty($viewnames)) {
136 145
    foreach ($viewnames as $key => $viewname) {
137 146
      $is_overridden = key_exists($viewname, $overridden);
147

  
138 148
      // Check if the provided view name is in the system
139 149
      if ($viewname && !key_exists($viewname, $views)) {
140 150
        drush_set_error(dt("'@viewname' view is not present in the system.", array('@viewname' => $viewname)));
......
144 154
        drush_set_error(dt("The view specified '@viewname' is not overridden.", array('@viewname' => $viewname)));
145 155
      }
146 156
      // If the view is overriden, revert it.
147
      elseif ($is_overridden){
157
      elseif ($is_overridden) {
148 158
        views_revert_view($views[$viewname]);
149 159
        $i++;
150 160
      }
151 161
      // We should never get here but well...
152 162
      else {
153
        drush_set_error(dt("The view specified '@viewname' is not provided in code, and thus cannot be reverted.", array('@viewname' => $viewname)));
163
        drush_set_error(dt(
164
          "The view specified '@viewname' is not provided in code, and thus cannot be reverted.",
165
          array('@viewname' => $viewname)
166
        ));
154 167
      }
155 168
    }
156 169
  }
157 170

  
158
  // The user did not specify any views in the command, prompt the user
171
  // The user neither selected the "--all" option, nor provided a list of views to revert.
172
  // Prompt the user.
159 173
  else {
160 174
    // list of choices for the user
161 175
    $overridden['all'] = dt('Revert all overridden views'); // add a choice at the end
drupal7/sites/all/modules/views/handlers/views_handler_filter_date.inc
158 158
  }
159 159

  
160 160
  function op_between($field) {
161
    $a = intval(strtotime($this->value['min'], 0));
162
    $b = intval(strtotime($this->value['max'], 0));
161
    // Use the substitutions to ensure a consistent timestamp.
162
    $query_substitutions = views_views_query_substitutions($this->view);
163
    $a = intval(strtotime($this->value['min'], $query_substitutions['***CURRENT_TIME***']));
164
    $b = intval(strtotime($this->value['max'], $query_substitutions['***CURRENT_TIME***']));
163 165

  
164
    if ($this->value['type'] == 'offset') {
165
      $a = '***CURRENT_TIME***' . sprintf('%+d', $a); // keep sign
166
      $b = '***CURRENT_TIME***' . sprintf('%+d', $b); // keep sign
167
    }
168 166
    // This is safe because we are manually scrubbing the values.
169 167
    // It is necessary to do it this way because $a and $b are formulas when using an offset.
170 168
    $operator = strtoupper($this->operator);
......
172 170
  }
173 171

  
174 172
  function op_simple($field) {
175
    $value = intval(strtotime($this->value['value'], 0));
176
    if (!empty($this->value['type']) && $this->value['type'] == 'offset') {
177
      $value = '***CURRENT_TIME***' . sprintf('%+d', $value); // keep sign
178
    }
173
    // Use the substitutions to ensure a consistent timestamp.
174
    $query_substitutions = views_views_query_substitutions($this->view);
175
    $value = intval(strtotime($this->value['value'], $query_substitutions['***CURRENT_TIME***']));
176

  
179 177
    // This is safe because we are manually scrubbing the value.
180 178
    // It is necessary to do it this way because $value is a formula when using an offset.
181 179
    $this->query->add_where_expression($this->options['group'], "$field $this->operator $value");
drupal7/sites/all/modules/views/includes/cache.inc
67 67
  }
68 68
  else {
69 69
    if (!$fully_loaded) {
70
      $data = views_cache_get('views_data', TRUE);
71
      if (!empty($data->data)) {
70
      if ($data = views_cache_get('views_data', TRUE)) {
72 71
        $cache = $data->data;
73 72
      }
74

  
75
      if (empty($cache)) {
73
      else {
74
        // No cache entry, rebuild.
76 75
        $cache = _views_fetch_data_build();
77 76
      }
78 77
      $fully_loaded = TRUE;
......
127 126
function _views_fetch_plugin_data($type = NULL, $plugin = NULL, $reset = FALSE) {
128 127
  static $cache = NULL;
129 128
  if (!isset($cache) || $reset) {
130
    $start = microtime(TRUE);
131
    views_include('plugins');
132
    views_include_handlers();
133

  
134
    $cache = views_discover_plugins();
135

  
129
    // Load necessary code once.
130
    if (!isset($cache)) {
131
      views_include('plugins');
132
      views_include_handlers();
133
    }
134
    // Because plugin data contains translated strings, and as such can be
135
    // expensive to build, the results are cached per language.
136
    global $language;
137
    $cache_key = 'views:plugin_data:' . $language->language;
138
    if (!$reset) {
139
      if ($cache = cache_get($cache_key)) {
140
        $cache = $cache->data;
141
      }
142
    }
143
    // If not available in the cache, build it and cache it.
144
    if (!$cache) {
145
      $cache = views_discover_plugins();
146
      cache_set($cache_key, $cache);
147
    }
136 148
  }
137 149

  
138 150
  if (!$type && !$plugin) {
drupal7/sites/all/modules/views/modules/comment/views_plugin_row_comment_rss.inc
107 107
      ),
108 108
      array(
109 109
        'key' => 'dc:creator',
110
        'value' => $comment->name,
110
        'value' => format_username($comment),
111 111
      ),
112 112
      array(
113 113
        'key' => 'guid',
drupal7/sites/all/modules/views/modules/node/views_plugin_row_node_rss.inc
117 117
      ),
118 118
      array(
119 119
        'key' => 'dc:creator',
120
        'value' => $node->name,
120
        'value' => format_username($node),
121 121
      ),
122 122
      array(
123 123
        'key' => 'guid',
drupal7/sites/all/modules/views/plugins/views_plugin_cache.inc
206 206
    // Slightly less simple for CSS:
207 207
    $css = drupal_add_css();
208 208
    $css_start = isset($this->storage['css']) ? $this->storage['css'] : array();
209
    $this->storage['css'] = $array_mapping_func($css, $css_start);
209
    $this->storage['css'] = $this->assetDiff($css, $css_start, $array_mapping_func);
210 210

  
211 211
    // Get javascript after/before views renders.
212 212
    $js = drupal_add_js();
213 213
    $js_start = isset($this->storage['js']) ? $this->storage['js'] : array();
214 214
    // If there are any differences between the old and the new javascript then
215 215
    // store them to be added later.
216
    $this->storage['js'] = $array_mapping_func($js, $js_start);
216
    $this->storage['js'] = $this->assetDiff($js, $js_start, $array_mapping_func);
217 217

  
218 218
    // Special case the settings key and get the difference of the data.
219 219
    $settings = isset($js['settings']['data']) ? $js['settings']['data'] : array();
......
224 224
    $this->storage['headers'] = $array_mapping_func(drupal_get_http_header(), $this->storage['headers']);
225 225
  }
226 226

  
227
  /**
228
   * Computes the differences between two JS/CSS asset arrays.
229
   *
230
   * @param array $assets
231
   *   The current asset array.
232
   * @param array $start_assets
233
   *   The original asset array.
234
   * @param string $diff_function
235
   *   The function that should be used for computing the diff.
236
   *
237
   * @return array
238
   *   A CSS or JS asset array that contains all entries that are new/different
239
   *   in $assets.
240
   */
241
  protected function assetDiff(array $assets, array $start_assets, $diff_function) {
242
    $diff = $diff_function($assets, $start_assets);
243

  
244
    // Cleanup the resulting array since drupal_array_diff_assoc_recursive() can
245
    // leave half populated arrays behind.
246
    foreach ($diff as $key => $entry) {
247
      // If only the weight was different we can remove this entry.
248
      if (count($entry) == 1 && isset($entry['weight'])) {
249
        unset($diff[$key]);
250
      }
251
      // If there are other differences we override with the latest entry.
252
      elseif ($entry != $assets[$key]) {
253
        $diff[$key] = $assets[$key];
254
      }
255
    }
256
    return $diff;
257
  }
258

  
227 259
  /**
228 260
   * Restore out of band data saved to cache. Copied from Panels.
229 261
   */
drupal7/sites/all/modules/views/plugins/views_plugin_display.inc
2140 2140
          '#default_value' => $pager['type'],
2141 2141
        );
2142 2142

  
2143
        $pager_plugin = views_fetch_plugin_data('pager', $pager['type'], array($this->view->base_table));
2143
        $pager_plugin = views_fetch_plugin_data('pager', $pager['type']);
2144 2144
        if (!empty($pager_plugin['uses options'])) {
2145 2145
          $form['markup'] = array(
2146 2146
            '#prefix' => '<div class="form-item description">',
drupal7/sites/all/modules/views/plugins/views_plugin_display_attachment.inc
227 227

  
228 228
    $args = $this->get_option('inherit_arguments') ? $this->view->args : array();
229 229
    $view->set_arguments($args);
230
    $exposed_input = $this->get_option('inherit_exposed_filters') ? $this->view->exposed_input : array();
231
    $view->set_exposed_input($exposed_input);
230 232
    $view->set_display($this->display->id);
231 233
    if ($this->get_option('inherit_pager')) {
232 234
      $view->display_handler->use_pager = $this->view->display[$display_id]->handler->use_pager();
drupal7/sites/all/modules/views/plugins/views_plugin_query_default.inc
1322 1322
    if (count($this->having)) {
1323 1323
      $this->has_aggregate = TRUE;
1324 1324
    }
1325
    elseif (!$this->has_aggregate) {
1326
      // Allow 'GROUP BY' even no aggregation function has been set.
1327
      $this->has_aggregate = $this->view->display_handler->get_option('group_by');
1328
    }
1325 1329
    if ($this->has_aggregate && (!empty($this->groupby) || !empty($non_aggregates))) {
1326 1330
      $groupby = array_unique(array_merge($this->groupby, $non_aggregates));
1327 1331
      foreach ($groupby as $field) {
drupal7/sites/all/modules/views/tests/handlers/views_handler_filter_date.test
50 50
    $this->assertIdenticalResultset($view, $expected_result, $this->map);
51 51
    $view->destroy();
52 52

  
53
    // Test "first day of" type of relative dates for simple operator.
54
    $view->set_display('default');
55
    $view->init_handlers();
56
    $view->filter['created']->operator = '<';
57
    $view->filter['created']->value['type'] = 'offset';
58
    $view->filter['created']->value['value'] = 'last day of January 1970';
59
    $view->execute_display('default');
60
    $expected_result = array(
61
      array('nid' => $this->nodes[0]->nid),
62
      array('nid' => $this->nodes[1]->nid),
63
      array('nid' => $this->nodes[2]->nid),
64
    );
65
    $this->assertIdenticalResultset($view, $expected_result, $this->map);
66
    $view->destroy();
67

  
53 68
    // Test offset for between operator.
54 69
    $view->set_display('default');
55 70
    $view->init_handlers();
......
63 78
    );
64 79
    $this->assertIdenticalResultset($view, $expected_result, $this->map);
65 80
    $view->destroy();
81

  
82
    // Test "first day of" type of relative dates for between operator.
83
    $view->set_display('default');
84
    $view->init_handlers();
85
    $view->filter['created']->operator = 'between';
86
    $view->filter['created']->value['type'] = 'offset';
87
    $view->filter['created']->value['max'] = 'last day of January 1970';
88
    $view->filter['created']->value['min'] = 'first day of January 1970';
89
    $view->execute_display('default');
90
    $expected_result = array(
91
      array('nid' => $this->nodes[0]->nid),
92
      array('nid' => $this->nodes[1]->nid),
93
      array('nid' => $this->nodes[2]->nid),
94
    );
95
    $this->assertIdenticalResultset($view, $expected_result, $this->map);
96
    $view->destroy();
66 97
  }
67 98

  
68 99

  
drupal7/sites/all/modules/views/tests/views_groupby.test
108 108
  }
109 109

  
110 110
  /**
111
   * @param $group_by
112
   *   Which group_by function should be used, for example sum or count.
111
   * @param string|null $group_by
112
   *   (optional) Which group_by function should be used, for example sum or
113
   *   count. If omitted, the aggregation is tested with no group function.
114
   * @param array|null $values
115
   *   (optional) Expected values.
113 116
   */
114
  function GroupByTestHelper($group_by, $values) {
115
    // Create 2 nodes of type1 and 3 nodes of type2
117
  function GroupByTestHelper($group_by = NULL, $values = NULL) {
118
    // Create 4 nodes of type1 and 3 nodes of type2
116 119
    $type1 = $this->drupalCreateContentType();
117 120
    $type2 = $this->drupalCreateContentType();
118 121

  
......
136 139
    $output = $view->execute_display();
137 140

  
138 141
    $this->assertEqual(count($view->result), 2, 'Make sure the count of items is right.');
142

  
143
    $results = array();
144
    // There's no need for a function in order to have aggregation.
145
    if (empty($group_by)) {
146
      $types = array($type1->type, $type2->type);
147
      $results = array_map(function ($item) { return $item->node_type; }, $view->result);
148
      sort($types);
149
      sort($results);
150
      $this->assertIdentical($results, $types);
151
      // Exit here with no aggregation function.
152
      return;
153
    }
154

  
139 155
    // Group by nodetype to identify the right count.
140 156
    foreach ($view->result as $item) {
141 157
      $results[$item->node_type] = $item->nid;
......
144 160
    $this->assertEqual($results[$type2->type], $values[1]);
145 161
  }
146 162

  
147
  function viewsGroupByViewHelper($group_by) {
163
  function viewsGroupByViewHelper($group_by = NULL) {
148 164
    $view = new view;
149 165
    $view->name = 'group_by_count';
150 166
    $view->description = '';
......
164 180
    $handler->display->display_options['pager']['type'] = 'some';
165 181
    $handler->display->display_options['style_plugin'] = 'default';
166 182
    $handler->display->display_options['row_plugin'] = 'fields';
167
    /* Field: Content: Nid */
168
    $handler->display->display_options['fields']['nid']['id'] = 'nid';
169
    $handler->display->display_options['fields']['nid']['table'] = 'node';
170
    $handler->display->display_options['fields']['nid']['field'] = 'nid';
171
    $handler->display->display_options['fields']['nid']['group_type'] = $group_by;
172
    $handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0;
173
    $handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
174
    $handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
175
    $handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
176
    $handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
177
    $handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
178
    $handler->display->display_options['fields']['nid']['alter']['html'] = 0;
179
    $handler->display->display_options['fields']['nid']['hide_empty'] = 0;
180
    $handler->display->display_options['fields']['nid']['empty_zero'] = 0;
181
    $handler->display->display_options['fields']['nid']['link_to_node'] = 0;
183

  
184
    // The test view has 2 fields ('nid' and 'type'). Don't add 'nid' when
185
    // having no aggregation function. We just want to aggregate on node type.
186
    if (!empty($group_by)) {
187
      /* Field: Content: Nid */
188
      $handler->display->display_options['fields']['nid']['id'] = 'nid';
189
      $handler->display->display_options['fields']['nid']['table'] = 'node';
190
      $handler->display->display_options['fields']['nid']['field'] = 'nid';
191
      $handler->display->display_options['fields']['nid']['group_type'] = $group_by;
192
      $handler->display->display_options['fields']['nid']['alter']['alter_text'] = 0;
193
      $handler->display->display_options['fields']['nid']['alter']['make_link'] = 0;
194
      $handler->display->display_options['fields']['nid']['alter']['trim'] = 0;
195
      $handler->display->display_options['fields']['nid']['alter']['word_boundary'] = 1;
196
      $handler->display->display_options['fields']['nid']['alter']['ellipsis'] = 1;
197
      $handler->display->display_options['fields']['nid']['alter']['strip_tags'] = 0;
198
      $handler->display->display_options['fields']['nid']['alter']['html'] = 0;
199
      $handler->display->display_options['fields']['nid']['hide_empty'] = 0;
200
      $handler->display->display_options['fields']['nid']['empty_zero'] = 0;
201
      $handler->display->display_options['fields']['nid']['link_to_node'] = 0;
202
    }
203

  
182 204
    /* Field: Content: Type */
183 205
    $handler->display->display_options['fields']['type']['id'] = 'type';
184 206
    $handler->display->display_options['fields']['type']['table'] = 'node';
......
218 240
    $this->GroupByTestHelper('max', array(4, 7));
219 241
  }
220 242

  
243
  function testGroupByNone() {
244
    $this->GroupByTestHelper();
245
  }
246

  
221 247
  public function testGroupByCountOnlyFilters() {
222 248
    // Check if GROUP BY and HAVING are included when a view
223 249
    // Doesn't display SUM, COUNT, MAX... functions in SELECT statment
drupal7/sites/all/modules/views/tests/views_module.test
194 194
    $this->assertEqual(variable_get('views_test_views_data_count', 0), 1, 'Views data rebuilt once');
195 195
    $this->assertFalse(drupal_static('_views_fetch_data_fully_loaded'), 'Views data is not fully loaded');
196 196

  
197

  
198
    // Test if the cache consistency is ensured. There was an issue where
199
    // calling _views_fetch_data() first with a table would prevent the function
200
    // from properly rebuilt a missing the general cache entry.
201
    // See https://www.drupal.org/node/2475669 for details.
202
    // Make sure we start with a empty cache.
203
    $this->resetStaticViewsDataCache();
204
    cache_clear_all('*', 'cache_views', TRUE);
205

  
206
    // Prime the static cache of _views_fetch_data() by calling it with a table
207
    // first.
208
    views_fetch_data('views_test');
209
    // Now remove the general cache.
210
    cache_clear_all('views_data:en', 'cache_views');
211
    // Reset the static cache to see if fetches from the persistent cache
212
    // properly rebuild the static cache.
213
    $this->resetStaticViewsDataCache();
214
    // Prime the static cache of _views_fetch_data() by calling it with a table
215
    // first.
216
    views_fetch_data('views_test');
217
    // Fetch the general cache, which was deleted, an see if it is rebuild
218
    // properly.
219
    views_fetch_data();
220
    $this->assertTrue(cache_get('views_data:en', 'cache_views'), 'Cache for all tables was properly rebuild.');
197 221
  }
198 222

  
199 223
  /**
drupal7/sites/all/modules/views/tests/views_test.info
5 5
dependencies[] = views
6 6
hidden = TRUE
7 7

  
8
; Information added by Drupal.org packaging script on 2015-02-11
9
version = "7.x-3.10"
8
; Information added by Drupal.org packaging script on 2015-04-29
9
version = "7.x-3.11"
10 10
core = "7.x"
11 11
project = "views"
12
datestamp = "1423648085"
12
datestamp = "1430321048"
13 13

  
drupal7/sites/all/modules/views/views.api.php
1075 1075
    // Traverse through the 'where' part of the query.
1076 1076
    foreach ($query->where as &$condition_group) {
1077 1077
      foreach ($condition_group['conditions'] as &$condition) {
1078
        // If this is the part of the query filtering on title, chang the
1078
        // If this is the part of the query filtering on title, change the
1079 1079
        // condition to filter on node ID.
1080 1080
        if ($condition['field'] == 'node.title') {
1081 1081
          $condition = array(
drupal7/sites/all/modules/views/views.info
318 318
files[] = tests/views_view.test
319 319
files[] = tests/views_ui.test
320 320

  
321
; Information added by Drupal.org packaging script on 2015-02-11
322
version = "7.x-3.10"
321
; Information added by Drupal.org packaging script on 2015-04-29
322
version = "7.x-3.11"
323 323
core = "7.x"
324 324
project = "views"
325
datestamp = "1423648085"
325
datestamp = "1430321048"
326 326

  
drupal7/sites/all/modules/views/views_ui.info
7 7
files[] = views_ui.module
8 8
files[] = plugins/views_wizard/views_ui_base_views_wizard.class.php
9 9

  
10
; Information added by Drupal.org packaging script on 2015-02-11
11
version = "7.x-3.10"
10
; Information added by Drupal.org packaging script on 2015-04-29
11
version = "7.x-3.11"
12 12
core = "7.x"
13 13
project = "views"
14
datestamp = "1423648085"
14
datestamp = "1430321048"
15 15

  

Formats disponibles : Unified diff