Projet

Général

Profil

Révision b4adf10d

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

Udpate to 7.33

Voir les différences:

drupal7/includes/theme.inc
1029 1029
    }
1030 1030
    $hook = $candidate;
1031 1031
  }
1032
  $theme_hook_original = $hook;
1032 1033

  
1033 1034
  // If there's no implementation, check for more generic fallbacks. If there's
1034 1035
  // still no implementation, log an error and return an empty string.
......
1090 1091
    $variables += array($info['render element'] => array());
1091 1092
  }
1092 1093

  
1094
  $variables['theme_hook_original'] = $theme_hook_original;
1095

  
1093 1096
  // Invoke the variable processors, if any. The processors may specify
1094 1097
  // alternate suggestions for which hook's template/function to use. If the
1095 1098
  // hook is a suggestion of a base hook, invoke the variable processors of
......
1198 1201
    if (isset($info['path'])) {
1199 1202
      $template_file = $info['path'] . '/' . $template_file;
1200 1203
    }
1201
    $output = $render_function($template_file, $variables);
1204
    if (variable_get('theme_debug', FALSE)) {
1205
      $output = _theme_render_template_debug($render_function, $template_file, $variables, $extension);
1206
    }
1207
    else {
1208
      $output = $render_function($template_file, $variables);
1209
    }
1202 1210
  }
1203 1211

  
1204 1212
  // restore path_to_theme()
......
1520 1528
  return ob_get_clean();
1521 1529
}
1522 1530

  
1531
/**
1532
 * Renders a template for any engine.
1533
 *
1534
 * Includes the possibility to get debug output by setting the
1535
 * theme_debug variable to TRUE.
1536
 *
1537
 * @param string $template_function
1538
 *   The function to call for rendering the template.
1539
 * @param string $template_file
1540
 *   The filename of the template to render.
1541
 * @param array $variables
1542
 *   A keyed array of variables that will appear in the output.
1543
 * @param string $extension
1544
 *   The extension used by the theme engine for template files.
1545
 *
1546
 * @return string
1547
 *   The output generated by the template including debug information.
1548
 */
1549
function _theme_render_template_debug($template_function, $template_file, $variables, $extension) {
1550
  $output = array(
1551
    'debug_prefix' => '',
1552
    'debug_info' => '',
1553
    'rendered_markup' => call_user_func($template_function, $template_file, $variables),
1554
    'debug_suffix' => '',
1555
  );
1556
  $output['debug_prefix'] .= "\n\n<!-- THEME DEBUG -->";
1557
  $output['debug_prefix'] .= "\n<!-- CALL: theme('" . check_plain($variables['theme_hook_original']) . "') -->";
1558
  // If there are theme suggestions, reverse the array so more specific
1559
  // suggestions are shown first.
1560
  if (!empty($variables['theme_hook_suggestions'])) {
1561
    $variables['theme_hook_suggestions'] = array_reverse($variables['theme_hook_suggestions']);
1562
  }
1563
  // Add debug output for directly called suggestions like
1564
  // '#theme' => 'comment__node__article'.
1565
  if (strpos($variables['theme_hook_original'], '__') !== FALSE) {
1566
    $derived_suggestions[] = $hook = $variables['theme_hook_original'];
1567
    while ($pos = strrpos($hook, '__')) {
1568
      $hook = substr($hook, 0, $pos);
1569
      $derived_suggestions[] = $hook;
1570
    }
1571
    // Get the value of the base hook (last derived suggestion) and append it
1572
    // to the end of all theme suggestions.
1573
    $base_hook = array_pop($derived_suggestions);
1574
    $variables['theme_hook_suggestions'] = array_merge($derived_suggestions, $variables['theme_hook_suggestions']);
1575
    $variables['theme_hook_suggestions'][] = $base_hook;
1576
  }
1577
  if (!empty($variables['theme_hook_suggestions'])) {
1578
    $current_template = basename($template_file);
1579
    $suggestions = $variables['theme_hook_suggestions'];
1580
    // Only add the original theme hook if it wasn't a directly called
1581
    // suggestion.
1582
    if (strpos($variables['theme_hook_original'], '__') === FALSE) {
1583
      $suggestions[] = $variables['theme_hook_original'];
1584
    }
1585
    foreach ($suggestions as &$suggestion) {
1586
      $template = strtr($suggestion, '_', '-') . $extension;
1587
      $prefix = ($template == $current_template) ? 'x' : '*';
1588
      $suggestion = $prefix . ' ' . $template;
1589
    }
1590
    $output['debug_info'] .= "\n<!-- FILE NAME SUGGESTIONS:\n   " . check_plain(implode("\n   ", $suggestions)) . "\n-->";
1591
  }
1592
  $output['debug_info'] .= "\n<!-- BEGIN OUTPUT from '" . check_plain($template_file) . "' -->\n";
1593
  $output['debug_suffix'] .= "\n<!-- END OUTPUT from '" . check_plain($template_file) . "' -->\n\n";
1594
  return implode('', $output);
1595
}
1596

  
1523 1597
/**
1524 1598
 * Enables a given list of themes.
1525 1599
 *
......
1690 1764
  $output = '';
1691 1765

  
1692 1766
  if (count($links) > 0) {
1693
    $output = '';
1694

  
1695 1767
    // Treat the heading first if it is present to prepend it to the
1696 1768
    // list of links.
1697 1769
    if (!empty($heading)) {

Formats disponibles : Unified diff