delta_blocks.theme.inc 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. <?php
  2. /**
  3. * @file
  4. * Theme functions for the Delta blocks module.
  5. */
  6. /**
  7. * Returns the rendered branding.
  8. *
  9. * @ingroup themeable
  10. */
  11. function theme_delta_blocks_branding($variables) {
  12. $logo = theme('delta_blocks_logo', $variables);
  13. $site_name = theme('delta_blocks_site_name', $variables);
  14. $site_slogan = theme('delta_blocks_site_slogan', $variables);
  15. $attributes['class'] = array('site-name-slogan');
  16. if ($variables['site_name_hidden'] && $variables['site_slogan_hidden']) {
  17. $attributes['class'][] = 'element-invisible';
  18. }
  19. return $logo . '<hgroup' . drupal_attributes($attributes) . '>' . $site_name . $site_slogan . '</hgroup>';
  20. }
  21. /**
  22. * Returns the rendered logo.
  23. *
  24. * @ingroup themeable
  25. */
  26. function theme_delta_blocks_logo($variables) {
  27. if ($variables['logo']) {
  28. $image = array(
  29. '#theme' => 'image',
  30. '#path' => $variables['logo'],
  31. '#alt' => $variables['site_name'],
  32. );
  33. $image = render($image);
  34. if ($variables['logo_linked']) {
  35. $options['html'] = TRUE;
  36. $options['attributes']['id'] = 'logo';
  37. $options['attributes']['title'] = t('Return to the @name home page', array('@name' => $variables['site_name']));
  38. $image = l($image, '<front>', $options);
  39. }
  40. return '<div class="logo-img">' . $image . '</div>';
  41. }
  42. }
  43. /**
  44. * Returns the rendered site name.
  45. *
  46. * @ingroup themeable
  47. */
  48. function theme_delta_blocks_site_name($variables) {
  49. // If there is no page title set for this page, use a h1 for the site name.
  50. $tag = drupal_get_title() !== '' ? 'h2' : 'h1';
  51. $site_name = $variables['site_name'];
  52. if ($variables['site_name_linked']) {
  53. $options['html'] = TRUE;
  54. $options['attributes']['title'] = t('Return to the @name home page', array('@name' => $variables['site_name']));
  55. $link = array(
  56. '#theme' => 'link',
  57. '#path' => '<front>',
  58. '#text' => '<span>' . $site_name . '</span>',
  59. '#options' => $options,
  60. );
  61. $site_name = render($link);
  62. }
  63. $attributes['class'] = array('site-name');
  64. if ($variables['site_name_hidden']) {
  65. $attributes['class'][] = 'element-invisible';
  66. }
  67. return '<' . $tag . drupal_attributes($attributes) . '>' . $site_name . '</' . $tag . '>';
  68. }
  69. /**
  70. * Returns the rendered site slogan.
  71. *
  72. * @ingroup themeable
  73. */
  74. function theme_delta_blocks_site_slogan($variables) {
  75. if ($variables['site_slogan'] !== '') {
  76. $attributes['class'] = array('site-slogan');
  77. if ($variables['site_slogan_hidden']) {
  78. $attributes['class'][] = 'element-invisible';
  79. }
  80. return '<h6' . drupal_attributes($attributes) . '>' . $variables['site_slogan'] . '</h6>';
  81. }
  82. }
  83. /**
  84. * Returns the rendered page title.
  85. *
  86. * @ingroup themeable
  87. */
  88. function theme_delta_blocks_page_title($variables) {
  89. if ($variables['page_title'] !== '') {
  90. $attributes['id'] = 'page-title';
  91. $attributes['class'][] = 'title';
  92. if ($variables['page_title_hidden']) {
  93. $attributes['class'][] = 'element-invisible';
  94. }
  95. return '<h1' . drupal_attributes($attributes) . '>' . $variables['page_title'] . '</h1>';
  96. }
  97. }
  98. /**
  99. * Returns the rendered breadcrumb.
  100. *
  101. * @ingroup themeable
  102. */
  103. function theme_delta_blocks_breadcrumb($variables) {
  104. $output = '';
  105. if (!empty($variables['breadcrumb'])) {
  106. if ($variables['breadcrumb_current']) {
  107. $variables['breadcrumb'][] = l(drupal_get_title(), current_path(), array('html' => TRUE));
  108. }
  109. $output = '<div id="breadcrumb" class="clearfix"><ul class="breadcrumb">';
  110. $switch = array('odd' => 'even', 'even' => 'odd');
  111. $zebra = 'even';
  112. $last = count($variables['breadcrumb']) - 1;
  113. foreach ($variables['breadcrumb'] as $key => $item) {
  114. $zebra = $switch[$zebra];
  115. $attributes['class'] = array('depth-' . ($key + 1), $zebra);
  116. if ($key == 0) {
  117. $attributes['class'][] = 'first';
  118. }
  119. if ($key == $last) {
  120. $attributes['class'][] = 'last';
  121. }
  122. $output .= '<li' . drupal_attributes($attributes) . '>' . $item . '</li>';
  123. }
  124. $output .= '</ul></div>';
  125. }
  126. return $output;
  127. }
  128. /**
  129. * Returns the rendered action items.
  130. *
  131. * @ingroup themeable
  132. */
  133. function theme_delta_blocks_action_links($variables) {
  134. $actions = render($variables['action_links']);
  135. if (!empty($actions)) {
  136. return '<div id="action-links" class="clearfix"><ul class="action-links">' . $actions . '</ul></div>';
  137. }
  138. }
  139. /**
  140. * Returns the rendered feed icons.
  141. *
  142. * @ingroup themeable
  143. */
  144. function theme_delta_blocks_feed_icons($variables) {
  145. return $variables['feed_icons'];
  146. }
  147. /**
  148. * Returns the rendered menu local tasks.
  149. *
  150. * @ingroup themeable
  151. */
  152. function theme_delta_blocks_tabs($variables) {
  153. $tabs = theme('menu_local_tasks', $variables);
  154. if (!empty($tabs)) {
  155. return '<div id="tabs" class="clearfix">' . $tabs . '</div>';
  156. }
  157. }