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-6.x/themes/garland/template.php
View source
  1. <?php
  2. /**
  3. * Sets the body-tag class attribute.
  4. *
  5. * Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
  6. */
  7. function phptemplate_body_class($left, $right) {
  8. if ($left != '' && $right != '') {
  9. $class = 'sidebars';
  10. }
  11. else {
  12. if ($left != '') {
  13. $class = 'sidebar-left';
  14. }
  15. if ($right != '') {
  16. $class = 'sidebar-right';
  17. }
  18. }
  19. if (isset($class)) {
  20. print ' class="'. $class .'"';
  21. }
  22. }
  23. /**
  24. * Return a themed breadcrumb trail.
  25. *
  26. * @param $breadcrumb
  27. * An array containing the breadcrumb links.
  28. * @return a string containing the breadcrumb output.
  29. */
  30. function phptemplate_breadcrumb($breadcrumb) {
  31. if (!empty($breadcrumb)) {
  32. return '<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>';
  33. }
  34. }
  35. /**
  36. * Override or insert PHPTemplate variables into the templates.
  37. */
  38. function phptemplate_preprocess_page(&$vars) {
  39. $vars['tabs2'] = menu_secondary_local_tasks();
  40. // Hook into color.module
  41. if (module_exists('color')) {
  42. _color_page_alter($vars);
  43. }
  44. }
  45. /**
  46. * Add a "Comments" heading above comments except on forum pages.
  47. */
  48. function garland_preprocess_comment_wrapper(&$vars) {
  49. if ($vars['content'] && $vars['node']->type != 'forum') {
  50. $vars['content'] = '<h2 class="comments">'. t('Comments') .'</h2>'. $vars['content'];
  51. }
  52. }
  53. /**
  54. * Returns the rendered local tasks. The default implementation renders
  55. * them as tabs. Overridden to split the secondary tasks.
  56. *
  57. * @ingroup themeable
  58. */
  59. function phptemplate_menu_local_tasks() {
  60. return menu_primary_local_tasks();
  61. }
  62. /**
  63. * Returns the themed submitted-by string for the comment.
  64. */
  65. function phptemplate_comment_submitted($comment) {
  66. return t('!datetime — !username',
  67. array(
  68. '!username' => theme('username', $comment),
  69. '!datetime' => format_date($comment->timestamp)
  70. ));
  71. }
  72. /**
  73. * Returns the themed submitted-by string for the node.
  74. */
  75. function phptemplate_node_submitted($node) {
  76. return t('!datetime — !username',
  77. array(
  78. '!username' => theme('username', $node),
  79. '!datetime' => format_date($node->created),
  80. ));
  81. }
  82. /**
  83. * Generates IE CSS links for LTR and RTL languages.
  84. */
  85. function phptemplate_get_ie_styles() {
  86. global $language;
  87. $iecss = '<link type="text/css" rel="stylesheet" media="all" href="'. base_path() . path_to_theme() .'/fix-ie.css" />';
  88. if ($language->direction == LANGUAGE_RTL) {
  89. $iecss .= '<style type="text/css" media="all">@import "'. base_path() . path_to_theme() .'/fix-ie-rtl.css";</style>';
  90. }
  91. return $iecss;
  92. }