Projet

Général

Profil

Révision 5a7e6170

Ajouté par Florent Torregrosa il y a environ 10 ans

Update :

  • panels : 7.x-3.3 -> 7.x-3.4
  • pdf_reader : 7.x-1.0-rc4 -> 7.x-1.0-rc5

Voir les différences:

drupal7/sites/all/modules/panels/panels.module
258 258
  }
259 259

  
260 260
  ctools_add_css('panels', 'panels');
261
  ctools_add_js('panels', 'panels');
262 261
}
263 262

  
264 263
/**
......
308 307
      'title' => t('Use panel locks'),
309 308
      'description' => t('Allows a user to lock and unlock panes in a panel display.'),
310 309
    ),
310
    'use ipe with page manager' => array(
311
      'title' => t("Use the Panels In-Place Editor with Page Manager"),
312
      'description' => t('Allows users with access to the In-Place editor to administer page manager pages. This permission is only needed for users without "use page manager" access.'),
313
    ),
311 314
  );
312 315
}
313 316

  
......
322 325
//  $legacy->determineStatus();
323 326
//}
324 327

  
328
/**
329
 * Implements hook_flush_caches().
330
 */
331
function panels_flush_caches() {
332
  return array('cache_panels');
333
}
334

  
325 335
// ---------------------------------------------------------------------------
326 336
// CTools hook implementations
327 337
//
......
652 662
      $pane->panel = $location;
653 663
    }
654 664

  
655
    // Get a temporary pid for this pane.
656
    $pane->pid = "new-" . $this->next_new_pid();
665
    // Generate a permanent uuid for this pane, and use
666
    // it as a temporary pid.
667
    $pane->uuid = ctools_uuid_generate();
668
    $pane->pid = 'new-' . $pane->uuid;
657 669

  
658 670
    // Add the pane to the approprate spots.
659 671
    $this->content[$pane->pid] = &$pane;
......
667 679

  
668 680
  function clone_pane($pid) {
669 681
    $pane = clone $this->content[$pid];
682
    $pane->uuid = ctools_uuid_generate();
670 683
    return $pane;
671 684
  }
672 685

  
673
  function next_new_pid() {
674
    // We don't use static vars to record the next new pid because
675
    // temporary pids can last for years in exports and in caching
676
    // during editing.
677
    $id = array(0);
678
    foreach (array_keys($this->content) as $pid) {
679
      if (!is_numeric($pid)) {
680
        $id[] = substr($pid, 4);
681
      }
682
    }
683
    $next_id = max($id);
684
    return ++$next_id;
685
  }
686

  
687 686
  /**
688 687
   * Get the title from a display.
689 688
   *
......
867 866
 *
868 867
 * @ingroup mainapi
869 868
 *
870
 * Note a new $display only receives a real did once it is run through this function.
871
 * Until then, it uses a string placeholder, 'new', in place of a real did. The same
872
 * applies to all new panes (whether on a new $display or not); in addition,
873
 * panes have sequential numbers appended, of the form 'new-1', 'new-2', etc.
869
 * Note that a new $display only receives a real did once it is run through
870
 * this function, and likewise for the pid of any new pane.
871
 *
872
 * Until then, a new display uses a string placeholder, 'new', in place of
873
 * a real did, and a new pane (whether on a new $display or not) appends a
874
 * universally-unique identifier (which is stored permanently in the 'uuid'
875
 * field). This format is also used in place of the real pid for exports.
874 876
 *
875 877
 * @param object $display instanceof panels_display \n
876 878
 *  The display object to be saved. Passed by reference so the caller need not use
......
880 882
 */
881 883
function panels_save_display(&$display) {
882 884
  $update = (isset($display->did) && is_numeric($display->did)) ? array('did') : array();
885
  if (empty($display->uuid) || !ctools_uuid_is_valid($display->uuid)) {
886
    $display->uuid = ctools_uuid_generate();
887
  }
883 888
  drupal_write_record('panels_display', $display, $update);
884 889

  
885 890
  $pids = array();
......
910 915
      $pane->did = $display->did;
911 916

  
912 917
      $old_pid = $pane->pid;
918

  
919
      if (empty($pane->uuid) || !ctools_uuid_is_valid($pane->uuid)) {
920
        $pane->uuid = ctools_uuid_generate();
921
      }
922

  
913 923
      drupal_write_record('panels_pane', $pane, is_numeric($pid) ? array('pid') : array());
914 924

  
925
      // Allow other modules to take action after a pane is saved.
926
      if ($pane->pid == $old_pid) {
927
        module_invoke_all('panels_pane_update', $pane);
928
      }
929
      else {
930
        module_invoke_all('panels_pane_insert', $pane);
931
      }
932

  
915 933
      if ($pane->pid != $old_pid) {
916
        // and put it back so our pids and positions can be used
917
        unset($display->content[$id]);
934
        // Remove the old new-* entry from the displays content.
935
        unset($display->content[$pid]);
936

  
937
        // and put it back so our pids and positions can be used.
918 938
        $display->content[$pane->pid] = $pane;
919 939

  
920 940
        // If the title pane was one of our panes that just got its ID changed,
......
945 965
    $display->panels[$id] = $new_panes;
946 966
  }
947 967
  if (!empty($pids)) {
968
    // Allow other modules to take action before a panes are deleted.
969
    module_invoke_all('panels_pane_delete', $pids);
948 970
    db_delete('panels_pane')->condition('pid', $pids)->execute();
949 971
  }
950 972

  
......
978 1000
  else {
979 1001
    $did = $display;
980 1002
  }
1003
  module_invoke_all('panels_delete_display', $did);
981 1004
  db_delete('panels_display')->condition('did', $did)->execute();
982 1005
  db_delete('panels_pane')->condition('did', $did)->execute();
983 1006
}
......
987 1010
 *
988 1011
 * This function is primarily intended as a mechanism for cloning displays.
989 1012
 * It generates an exact replica (in code) of the provided $display, with
990
 * the exception that it replaces all ids (dids and pids) with 'new-*' values.
991
 * Only once panels_save_display() is called on the code version of $display will
992
 * the exported display written to the database and permanently saved.
1013
 * the exception that it replaces all ids (dids and pids) with place-holder
1014
 * values (consisting of the display or pane's uuid, with a 'new-' prefix).
1015
 *
1016
 * Only once panels_save_display() is called on the code version of $display
1017
 * will the exported display be written to the database and permanently saved.
993 1018
 *
994 1019
 * @see panels_page_export() or _panels_page_fetch_display() for sample implementations.
995 1020
 *
......
1011 1036
 */
1012 1037
function panels_export_display($display, $prefix = '') {
1013 1038
  ctools_include('export');
1039
  if (empty($display->uuid) || !ctools_uuid_is_valid($display->uuid)) {
1040
    $display->uuid = ctools_uuid_generate();
1041
  }
1042
  $display->did = 'new-' . $display->uuid;
1014 1043
  $output = ctools_export_object('panels_display', $display, $prefix);
1015 1044

  
1016
  $pid_counter = &drupal_static(__FUNCTION__, 0);
1017

  
1018 1045
  // Initialize empty properties.
1019 1046
  $output .= $prefix . '$display->content = array()' . ";\n";
1020 1047
  $output .= $prefix . '$display->panels = array()' . ";\n";
......
1024 1051
  if (!empty($display->content)) {
1025 1052
    $region_counters = array();
1026 1053
    foreach ($display->content as $pane) {
1027
      $pid = 'new-' . ++$pid_counter;
1054

  
1055
      if (!isset($pane->uuid) || !ctools_uuid_is_valid($pane->uuid)) {
1056
        $pane->uuid = ctools_uuid_generate();
1057
      }
1058
      $pid = 'new-' . $pane->uuid;
1059

  
1028 1060
      if ($pane->pid == $display->title_pane) {
1029 1061
        $title_pid = $pid;
1030 1062
      }
......
1070 1102
  if (!empty($display->context)) {
1071 1103
    if ($form_context = ctools_context_get_form($display->context)) {
1072 1104
      $form_context->form['#theme'] = 'panels_render_display_form';
1105
      if (empty($form_context->form['#theme_wrappers']) || !in_array('form', $form_context->form['#theme_wrappers'])) {
1106
        $form_context['#theme_wrappers'][] = 'form';
1107
      }
1073 1108
      $form_context->form['#display'] = &$display;
1074 1109
      return $form_context->form;
1075 1110
    }
......
1086 1121
 * then operate as a theme function of the form.
1087 1122
 */
1088 1123
function theme_panels_render_display_form($vars) {
1089
  // @todo this is probably broken in D7
1090
  $render = $vars['element']['#display']->render();
1091
  $vars['element']['#children'] = $render;
1092
  return theme('form', $vars);
1124
  return $vars['element']['#display']->render();
1093 1125
}
1094 1126

  
1095 1127
// @layout
......
1226 1258
      }
1227 1259

  
1228 1260
      $element = contextual_pre_render_links($element);
1229
      $links += $element['#links'];
1261
      if(!empty($element['#links'])) {
1262
        $links += $element['#links'];
1263
      }
1230 1264
    }
1231 1265

  
1232 1266
    if ($links) {
......
1276 1310

  
1277 1311
  // Add template file suggestion for content type and sub-type.
1278 1312
  $vars['theme_hook_suggestions'][] = $base . $delimiter . $content->type;
1279
  $vars['theme_hook_suggestions'][] = $base . $delimiter . strtr($content->type, '-', '_') . $delimiter . strtr($content->subtype, '-', '_');
1313
  $vars['theme_hook_suggestions'][] = $base . $delimiter . strtr(ctools_cleanstring($content->type, array('lower case' => TRUE)), '-', '_') . $delimiter . strtr(ctools_cleanstring($content->subtype, array('lower case' => TRUE)), '-', '_');
1280 1314

  
1281 1315
  $vars['pane_prefix'] = !empty($content->pane_prefix) ? $content->pane_prefix : '';
1282 1316
  $vars['pane_suffix'] = !empty($content->pane_suffix) ? $content->pane_suffix : '';
......
1526 1560
 * Get display edit cache on behalf of panel context.
1527 1561
 *
1528 1562
 * The key is the second half of the key in this form:
1529
 * panel_context:TASK_NAME:HANDLER_NAME;
1563
 * panel_context:TASK_NAME::HANDLER_NAME::args::url;
1530 1564
 */
1531 1565
function panel_context_panels_cache_get($key) {
1532 1566
  ctools_include('common', 'panels');
......
1535 1569
  // this loads the panel context inc even if we don't use the plugin.
1536 1570
  $plugin = page_manager_get_task_handler('panel_context');
1537 1571

  
1538
  list($task_name, $handler_name) = explode(':', $key, 2);
1572
  list($task_name, $handler_name, $args, $q) = explode('::', $key, 4);
1539 1573
  $page = page_manager_get_page_cache($task_name);
1540 1574
  if (isset($page->display_cache[$handler_name])) {
1541 1575
    return $page->display_cache[$handler_name];
......
1549 1583
  }
1550 1584
  $cache = new stdClass();
1551 1585

  
1586
  $task = page_manager_get_task($page->task_id);
1587
  //ctools_context_handler_get_all_contexts($page->task, $page->subtask, $handler);
1588
  $arguments = array();
1589
  if ($args) {
1590
    $arguments = explode('\\', $args);
1591
    $contexts = ctools_context_handler_get_task_contexts($task, $page->subtask, $arguments);
1592
    $contexts = ctools_context_handler_get_handler_contexts($contexts, $handler);
1593
  }
1594
  else {
1595
    $contexts = ctools_context_handler_get_all_contexts($page->task, $page->subtask, $handler);
1596
  }
1597

  
1552 1598
  $cache->display = &panels_panel_context_get_display($handler);
1553
  $cache->display->context = ctools_context_handler_get_all_contexts($page->task, $page->subtask, $handler);
1599
  $cache->display->context = $contexts;
1554 1600
  $cache->display->cache_key = 'panel_context:' . $key;
1555 1601
  $cache->content_types = panels_common_get_allowed_types('panels_page', $cache->display->context);
1556 1602
  $cache->display_title = TRUE;
......
1563 1609
 * Get the Page Manager cache for the panel_context plugin.
1564 1610
 */
1565 1611
function _panel_context_panels_cache_get_page_cache($key, $cache) {
1566
  list($task_name, $handler_name) = explode(':', $key, 2);
1612
  list($task_name, $handler_name, $args, $q) = explode('::', $key, 4);
1567 1613
  $page = page_manager_get_page_cache($task_name);
1568 1614
  $page->display_cache[$handler_name] = $cache;
1569 1615
  if ($handler_name) {

Formats disponibles : Unified diff