template.php

  1. 7.x drupal-7.x/themes/seven/template.php
  2. 7.x drupal-7.x/themes/garland/template.php
  3. 7.x drupal-7.x/themes/bartik/template.php
  4. 7.x drupal-7.x/modules/simpletest/tests/themes/test_theme/template.php
  5. 6.x drupal-6.x/themes/garland/template.php

File

drupal-7.x/themes/seven/template.php
View source
  1. <?php
  2. /**
  3. * Override or insert variables into the maintenance page template.
  4. */
  5. function seven_preprocess_maintenance_page(&$vars) {
  6. // While markup for normal pages is split into page.tpl.php and html.tpl.php,
  7. // the markup for the maintenance page is all in the single
  8. // maintenance-page.tpl.php template. So, to have what's done in
  9. // seven_preprocess_html() also happen on the maintenance page, it has to be
  10. // called here.
  11. seven_preprocess_html($vars);
  12. }
  13. /**
  14. * Override or insert variables into the html template.
  15. */
  16. function seven_preprocess_html(&$vars) {
  17. // Add conditional CSS for IE8 and below.
  18. drupal_add_css(path_to_theme() . '/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 8', '!IE' => FALSE), 'weight' => 999, 'preprocess' => FALSE));
  19. // Add conditional CSS for IE7 and below.
  20. drupal_add_css(path_to_theme() . '/ie7.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'weight' => 999, 'preprocess' => FALSE));
  21. // Add conditional CSS for IE6.
  22. drupal_add_css(path_to_theme() . '/ie6.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 6', '!IE' => FALSE), 'weight' => 999, 'preprocess' => FALSE));
  23. }
  24. /**
  25. * Override or insert variables into the page template.
  26. */
  27. function seven_preprocess_page(&$vars) {
  28. $vars['primary_local_tasks'] = $vars['tabs'];
  29. unset($vars['primary_local_tasks']['#secondary']);
  30. $vars['secondary_local_tasks'] = array(
  31. '#theme' => 'menu_local_tasks',
  32. '#secondary' => $vars['tabs']['#secondary'],
  33. );
  34. }
  35. /**
  36. * Display the list of available node types for node creation.
  37. */
  38. function seven_node_add_list($variables) {
  39. $content = $variables['content'];
  40. $output = '';
  41. if ($content) {
  42. $output = '<ul class="admin-list">';
  43. foreach ($content as $item) {
  44. $output .= '<li class="clearfix">';
  45. $output .= '<span class="label">' . l($item['title'], $item['href'], $item['localized_options']) . '</span>';
  46. $output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>';
  47. $output .= '</li>';
  48. }
  49. $output .= '</ul>';
  50. }
  51. else {
  52. $output = '<p>' . t('You have not created any content types yet. Go to the <a href="@create-content">content type creation page</a> to add a new content type.', array('@create-content' => url('admin/structure/types/add'))) . '</p>';
  53. }
  54. return $output;
  55. }
  56. /**
  57. * Overrides theme_admin_block_content().
  58. *
  59. * Use unordered list markup in both compact and extended mode.
  60. */
  61. function seven_admin_block_content($variables) {
  62. $content = $variables['content'];
  63. $output = '';
  64. if (!empty($content)) {
  65. $output = system_admin_compact_mode() ? '<ul class="admin-list compact">' : '<ul class="admin-list">';
  66. foreach ($content as $item) {
  67. $output .= '<li class="leaf">';
  68. $output .= l($item['title'], $item['href'], $item['localized_options']);
  69. if (isset($item['description']) && !system_admin_compact_mode()) {
  70. $output .= '<div class="description">' . filter_xss_admin($item['description']) . '</div>';
  71. }
  72. $output .= '</li>';
  73. }
  74. $output .= '</ul>';
  75. }
  76. return $output;
  77. }
  78. /**
  79. * Override of theme_tablesort_indicator().
  80. *
  81. * Use our own image versions, so they show up as black and not gray on gray.
  82. */
  83. function seven_tablesort_indicator($variables) {
  84. $style = $variables['style'];
  85. $theme_path = drupal_get_path('theme', 'seven');
  86. if ($style == 'asc') {
  87. return theme('image', array('path' => $theme_path . '/images/arrow-asc.png', 'alt' => t('sort ascending'), 'width' => 13, 'height' => 13, 'title' => t('sort ascending')));
  88. }
  89. else {
  90. return theme('image', array('path' => $theme_path . '/images/arrow-desc.png', 'alt' => t('sort descending'), 'width' => 13, 'height' => 13, 'title' => t('sort descending')));
  91. }
  92. }
  93. /**
  94. * Implements hook_css_alter().
  95. */
  96. function seven_css_alter(&$css) {
  97. // Use Seven's vertical tabs style instead of the default one.
  98. if (isset($css['misc/vertical-tabs.css'])) {
  99. $css['misc/vertical-tabs.css']['data'] = drupal_get_path('theme', 'seven') . '/vertical-tabs.css';
  100. $css['misc/vertical-tabs.css']['type'] = 'file';
  101. }
  102. if (isset($css['misc/vertical-tabs-rtl.css'])) {
  103. $css['misc/vertical-tabs-rtl.css']['data'] = drupal_get_path('theme', 'seven') . '/vertical-tabs-rtl.css';
  104. $css['misc/vertical-tabs-rtl.css']['type'] = 'file';
  105. }
  106. // Use Seven's jQuery UI theme style instead of the default one.
  107. if (isset($css['misc/ui/jquery.ui.theme.css'])) {
  108. $css['misc/ui/jquery.ui.theme.css']['data'] = drupal_get_path('theme', 'seven') . '/jquery.ui.theme.css';
  109. $css['misc/ui/jquery.ui.theme.css']['type'] = 'file';
  110. }
  111. }