Projet

Général

Profil

Révision 13c3c9b4

Ajouté par Assos Assos il y a environ 9 ans

Weekly update of contrib modules

Voir les différences:

drupal7/sites/all/modules/views/views.module
465 465
 *   The menu argument index. This counts from 1.
466 466
 */
467 467
function views_arg_load($value, $name, $display_id, $index) {
468
  static $views = array();
469

  
470
  // Make sure we haven't already loaded this views argument for a similar menu
471
  // item elsewhere.
472
  $key = $name . ':' . $display_id . ':' . $value . ':' . $index;
473
  if (isset($views[$key])) {
474
    return $views[$key];
468
 static $views = array();
469

  
470
  $display_ids = is_array($display_id) ? $display_id : array($display_id);
471
  $display_id = reset($display_ids);
472

  
473
  foreach ($display_ids as $id) {
474
    // Make sure we haven't already loaded this views argument for a similar
475
    // menu item elsewhere. Since access is always checked for the current user,
476
    // we are sure that the static cache contains valid entries.
477
    $key = $name . ':' . $id . ':' . $value . ':' . $index;
478
    if (isset($views[$key])) {
479
      return $views[$key];
480
    }
481
    // Lazy load the view object to avoid unnecessary work.
482
    if (!isset($view)) {
483
      $view = views_get_view($name);
484
    }
485
    // Pick the first display we have access to.
486
    if ($view && count($display_ids) > 1 && $view->access($id)) {
487
      $display_id = $id;
488
      break;
489
    }
475 490
  }
476 491

  
477
  if ($view = views_get_view($name)) {
492
  if ($view) {
478 493
    $view->set_display($display_id);
479 494
    $view->init_handlers();
480 495

  
......
548 563
}
549 564

  
550 565
/**
551
 * Implements MODULE_preprocess_HOOK().
566
 * Implements MODULE_preprocess_HOOK() for html.tpl.php.
552 567
 */
553 568
function views_preprocess_html(&$variables) {
554 569
  // If the page contains a view as its main content, contextual links may have
......
566 581
  if (!empty($variables['page']['#views_contextual_links_info'])) {
567 582
    $key = array_search('contextual-links-region', $variables['classes_array']);
568 583
    if ($key !== FALSE) {
569
      unset($variables['classes_array'][$key]);
584
      $variables['classes_array'] = array_diff($variables['classes_array'], array('contextual-links-region'));
570 585
      // Add the JavaScript, with a group and weight such that it will run
571 586
      // before modules/contextual/contextual.js.
572 587
      drupal_add_js(drupal_get_path('module', 'views') . '/js/views-contextual.js', array('group' => JS_LIBRARY, 'weight' => -1));
......
574 589
  }
575 590
}
576 591

  
592
/**
593
* Implements hook_preprocess_HOOK() for page.tpl.php.
594
*/
595
function views_preprocess_page(&$variables) {
596
  // If the page contains a view as its main content, contextual links may have
597
  // been attached to the page as a whole; for example, by views_page_alter().
598
  // This allows them to be associated with the page and rendered by default
599
  // next to the page title (which we want). However, it also causes the
600
  // Contextual Links module to treat the wrapper for the entire page (i.e.,
601
  // the <body> tag) as the HTML element that these contextual links are
602
  // associated with. This we don't want; for better visual highlighting, we
603
  // prefer a smaller region to be chosen. The region we prefer differs from
604
  // theme to theme and depends on the details of the theme's markup in
605
  // page.tpl.php, so we can only find it using JavaScript. We therefore remove
606
  // the "contextual-links-region" class from the <body> tag here and add
607
  // JavaScript that will insert it back in the correct place.
608
  if (!empty($variables['page']['#views_contextual_links_info'])) {
609
    $variables['classes_array'] = array_diff($variables['classes_array'], array('contextual-links-region'));
610
  }
611
}
612

  
577 613
/**
578 614
 * Implements hook_contextual_links_view_alter().
579 615
 */

Formats disponibles : Unified diff