Projet

Général

Profil

Révision 74f6bef0

Ajouté par Assos Assos il y a plus de 10 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/themes/adaptivetheme/at_core/inc/plugins.inc
1 1
<?php
2

  
2 3
/**
3 4
 * @file
4 5
 * AT's liteweight plugin sub-system.
......
17 18
 * @param $theme_name, usually the active theme.
18 19
 */
19 20
function at_get_plugins($theme_name) {
20
  $plugins = drupal_static(__FUNCTION__, array());
21
  $plugins = &drupal_static(__FUNCTION__, array());
21 22
  if (empty($plugins)) {
22 23
    if ($plugins_cache = cache_get('at_get_plugins_plugins')) {
23 24
      $plugins = $plugins_cache->data;
24 25
    }
25 26
    else {
27
      $plugins_list = array();
26 28
      $themes_info = at_get_info_trail($theme_name);
27 29
      // Look for and get all the plugins
28 30
      if (!empty($themes_info)) {
......
35 37
            }
36 38
          }
37 39
        }
38
        array_unique($plugins_list);
40

  
39 41
        $plugins = $plugins_list;
40 42
      }
41 43
    }
......
108 110
function at_load_plugins($theme_name, $plugin_type) {
109 111
  $plugin_data_structures = array();
110 112
  $plugins_list = at_get_plugins_files($theme_name);
111

  
113
  $plugins_array = array();
112 114
  foreach ($plugins_list as $plugin_provider => $plugin_types) {
113 115
    $plugin_providers[] = $plugin_provider;
114 116
    foreach ($plugin_types as $type => $plugins) {
......
127 129
  }
128 130

  
129 131
  foreach ($plugin_files as $file_data) {
130

  
131 132
    include_once(DRUPAL_ROOT . '/' . $file_data->uri);
132 133

  
133 134
    // panels
......
176 177
 * This returns the full data structures for all page layout plugins. Because
177 178
 * this can be a lot of data and appears to be computationally expensive to get
178 179
 * it is cached in the cache table.
180
 *
181
 * @param $theme_name, the active theme.
179 182
 */
180
function responsive_page_layouts_data_structure() {
181
  global $theme_key;
182
  $theme_name = $theme_key;
183
function responsive_page_layouts_data_structure($theme_name = NULL) {
184
  // Use the passed in theme_name, else grab it from the global variable
185
  if ($theme_name == NULL) {
186
    global $theme_key;
187
    $theme_name = $theme_key;
188
  }
183 189

  
184
  $page_data_structure = drupal_static(__FUNCTION__, array());
190
  $page_data_structure = &drupal_static(__FUNCTION__, array());
185 191
  if (empty($page_data_structure)) {
186
    if ($cache = cache_get('at_page_layouts_data_structure')) {
192
    if ($cache = cache_get('at_page_layouts_data_structure') && !empty($cache->data)) {
187 193
      $page_data_structure = $cache->data;
188 194
    }
189 195
    else {
190

  
191 196
      $data_structure = at_load_plugins($theme_name, $plugin_type = 'page_layout');
192

  
193 197
      foreach ($data_structure as $plugin => $datum) {
194 198
        foreach ($datum as $method => $layout) {
195 199
          $page_data_structure[$method] = $layout;
......
211 215
function responsive_panels_data_structure() {
212 216
  global $theme_key;
213 217
  $theme_name = $theme_key;
214

  
215
  $panels_data_structure = drupal_static(__FUNCTION__, array());
218
  $panels_data_structure = &drupal_static(__FUNCTION__, array());
216 219
  if (empty($panels_data_structure)) {
217 220
    if ($cache = cache_get('at_panels_data_structure')) {
218 221
      $panels_data_structure = $cache->data;
219 222
    }
220 223
    else {
221

  
222 224
      $data_structure = at_load_plugins($theme_name, $plugin_type = 'panels');
223

  
225
      // If this theme doesn't define any Panels layouts, use those
226
      // provided by at_core.
227
      if (empty($data_structure)) {
228
        $data_structure = at_load_plugins('adaptivetheme', $plugin_type = 'panels');
229
      }
224 230
      foreach ($data_structure as $plugin => $datum) {
225 231
        foreach ($datum as $key => $value) {
226 232
          $type = $value['type'];
227 233
          $panels_data_structure[$type][] = $datum;
228 234
        }
229 235
      }
230
      if (empty($panels_data_structure)) {
231
        return; // fail silently
232
      }
236

  
233 237
      cache_set('at_panels_data_structure', $panels_data_structure, 'cache');
234 238
    }
235 239
  }
236

  
237 240
  return $panels_data_structure;
238 241
}
239 242

  
240
/**
241
 * Return just the plugin names.
242
 * This is used primarily in one place - adaptivetheme_process_node() so we can
243
 * search for matches against Display Suite template suggestions, sounds weird
244
 * buts a work-around for a bug in Display Suite.
245
 *
246
 * @see adaptivetheme_process_node()
247
 * @see http://drupal.org/node/1514216
248
 * TODO: marked for removal due to new features in Display Suite.
249
 */
250
function responsive_panels_plugin_names() {
251
  $plugin_names = drupal_static(__FUNCTION__, array());
252
  if (empty($plugin_names)) {
253
    $data_structure = responsive_panels_data_structure();
254
    foreach ($data_structure as $key => $value) {
255
      foreach ($value as $type => $sub_types) {
256
        foreach ($sub_types as $k => $v) {
257
          $plugin_names[] = $k;
258
        }
259
      }
260
    }
261
  }
262

  
263
  return $plugin_names;
264
}
265

  
266 243
/**
267 244
 * Return option arrays for forms.
268 245
 * Returns the options for radio lists in the page layout settings in the
......
271 248
 * @param $theme_name
272 249
 */
273 250
function responsive_page_layouts_device_group_options($theme_name) {
274
  $device_group_options = drupal_static(__FUNCTION__, array());
251
  $device_group_options = &drupal_static(__FUNCTION__, array());
275 252
  if (empty($device_group_options)) {
276 253
    $layout_methods = responsive_page_layouts_data_structure();
277 254
    foreach ($layout_methods as $method => $values) {
......
355 332
/**
356 333
 * Base config for page layout builder.
357 334
 * This is used in at_core.submit.responsive.inc to help retrieve the form
358
 * values for each device groups layout.
335
 * values for each device groups layout. Not really part of the plugin
336
 * system and can't recall why I put it here :/
359 337
 */
360 338
function page_layout() {
361 339
  $variables_array = array(
......
371 349
}
372 350

  
373 351
/**
374
 * Return an array of standard gpanel regions
352
 * Return an array of standard gpanel regions. Not really part of the plugin
353
 * system and can't recall why I put it here :/
375 354
 */
376 355
function gpanel_regions() {
377
  $gpanel_regions_array = drupal_static(__FUNCTION__, array());
356
  $gpanel_regions_array = &drupal_static(__FUNCTION__, array());
378 357
  if (empty($gpanel_regions_array)) {
379 358
    $gpanel_regions_array = array(
380 359
      'one' => array(
......
425 404
      'three_inset_right' => array(
426 405
        'title' => t('AT Inset right'),
427 406
        'regions' => array(
428
          'threecol_inset_right_sidebar',
429
          'threecol_inset_right_top',
430
          'threecol_inset_right_middle',
431
          'threecol_inset_right_inset',
432
          'threecol_inset_right_bottom',
407
          'three_inset_right_sidebar',
408
          'three_inset_right_top',
409
          'three_inset_right_middle',
410
          'three_inset_right_inset',
411
          'three_inset_right_bottom',
433 412
        ),
434 413
      ),
435 414
      'three_inset_left' => array(
436 415
        'title' => t('AT Inset left'),
437 416
        'regions' => array(
438
          'threecol_inset_left_sidebar',
439
          'threecol_inset_left_top',
440
          'threecol_inset_left_middle',
441
          'threecol_inset_left_inset',
442
          'threecol_inset_left_bottom',
417
          'three_inset_left_sidebar',
418
          'three_inset_left_top',
419
          'three_inset_left_middle',
420
          'three_inset_left_inset',
421
          'three_inset_left_bottom',
443 422
        ),
444 423
      ),
445 424
      'three_50_25_25' => array(

Formats disponibles : Unified diff