PageRenderTime 54ms CodeModel.GetById 19ms RepoModel.GetById 0ms app.codeStats 0ms

/themes/bartik/template.php

https://bitbucket.org/hjain/trinet
PHP | 194 lines | 128 code | 18 blank | 48 comment | 26 complexity | ec5e23bc9cecaed814dbabf7ec204bb9 MD5 | raw file
Possible License(s): GPL-2.0, LGPL-3.0, AGPL-1.0
  1. <?php
  2. /**
  3. * Add body classes if certain regions have content.
  4. */
  5. function bartik_preprocess_html(&$variables) {
  6. //echo "<pre>"; print_r($variables['page']);exit;
  7. if (!empty($variables['page']['featured'])) {
  8. $variables['classes_array'][] = 'featured';
  9. }
  10. if (!empty($variables['page']['triptych_first'])
  11. || !empty($variables['page']['triptych_middle'])
  12. || !empty($variables['page']['triptych_last'])) {
  13. $variables['classes_array'][] = 'triptych';
  14. }
  15. if (!empty($variables['page']['footer_firstcolumn'])
  16. || !empty($variables['page']['footer_secondcolumn'])
  17. || !empty($variables['page']['footer_thirdcolumn'])
  18. || !empty($variables['page']['footer_fourthcolumn'])) {
  19. $variables['classes_array'][] = 'footer-columns';
  20. }
  21. // Add conditional stylesheets for IE
  22. drupal_add_css(path_to_theme() . '/css/ie.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'lte IE 7', '!IE' => FALSE), 'preprocess' => FALSE));
  23. drupal_add_css(path_to_theme() . '/css/ie6.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 6', '!IE' => FALSE), 'preprocess' => FALSE));
  24. }
  25. /**
  26. * Override or insert variables into the page template for HTML output.
  27. */
  28. function bartik_process_html(&$variables) {
  29. // Hook into color.module.
  30. if (module_exists('color')) {
  31. _color_html_alter($variables);
  32. }
  33. }
  34. /**
  35. * Override or insert variables into the page template.
  36. */
  37. function bartik_process_page(&$variables) {
  38. // Hook into color.module.
  39. if (module_exists('color')) {
  40. _color_page_alter($variables);
  41. }
  42. // Always print the site name and slogan, but if they are toggled off, we'll
  43. // just hide them visually.
  44. $variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
  45. $variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
  46. if ($variables['hide_site_name']) {
  47. // If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
  48. $variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
  49. }
  50. if ($variables['hide_site_slogan']) {
  51. // If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
  52. $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
  53. }
  54. if($variables['main_menu']){
  55. global $user;
  56. $userid=$user->uid;
  57. $menu_names = menu_get_names();
  58. $menu = menu_load_links('secondary_menu');
  59. $menu_entity=menu_load('secondary_menu');
  60. $variables['secondary_menu']['menu-775']['href']='user/'. $userid .'/edit/';
  61. }
  62. // Since the title and the shortcut link are both block level elements,
  63. // positioning them next to each other is much simpler with a wrapper div.
  64. if (!empty($variables['title_suffix']['add_or_remove_shortcut']) && $variables['title']) {
  65. // Add a wrapper div using the title_prefix and title_suffix render elements.
  66. $variables['title_prefix']['shortcut_wrapper'] = array(
  67. '#markup' => '<div class="shortcut-wrapper clearfix">',
  68. '#weight' => 100,
  69. );
  70. $variables['title_suffix']['shortcut_wrapper'] = array(
  71. '#markup' => '</div>',
  72. '#weight' => -99,
  73. );
  74. // Make sure the shortcut link is the first item in title_suffix.
  75. $variables['title_suffix']['add_or_remove_shortcut']['#weight'] = -100;
  76. }
  77. }
  78. /**
  79. * Implements hook_preprocess_maintenance_page().
  80. */
  81. function bartik_preprocess_maintenance_page(&$variables) {
  82. if (!$variables['db_is_active']) {
  83. unset($variables['site_name']);
  84. }
  85. drupal_add_css(drupal_get_path('theme', 'bartik') . '/css/maintenance-page.css');
  86. }
  87. /**
  88. * Override or insert variables into the maintenance page template.
  89. */
  90. function bartik_process_maintenance_page(&$variables) {
  91. // Always print the site name and slogan, but if they are toggled off, we'll
  92. // just hide them visually.
  93. $variables['hide_site_name'] = theme_get_setting('toggle_name') ? FALSE : TRUE;
  94. $variables['hide_site_slogan'] = theme_get_setting('toggle_slogan') ? FALSE : TRUE;
  95. if ($variables['hide_site_name']) {
  96. // If toggle_name is FALSE, the site_name will be empty, so we rebuild it.
  97. $variables['site_name'] = filter_xss_admin(variable_get('site_name', 'Drupal'));
  98. }
  99. if ($variables['hide_site_slogan']) {
  100. // If toggle_site_slogan is FALSE, the site_slogan will be empty, so we rebuild it.
  101. $variables['site_slogan'] = filter_xss_admin(variable_get('site_slogan', ''));
  102. }
  103. }
  104. /**
  105. * Override or insert variables into the node template.
  106. */
  107. function bartik_preprocess_node(&$variables) {
  108. if ($variables['view_mode'] == 'full' && node_is_page($variables['node'])) {
  109. $variables['classes_array'][] = 'node-full';
  110. }
  111. }
  112. /**
  113. * Override or insert variables into the block template.
  114. */
  115. function bartik_preprocess_block(&$variables) {
  116. // In the header region visually hide block titles.
  117. if ($variables['block']->region == 'header') {
  118. $variables['title_attributes_array']['class'][] = 'element-invisible';
  119. }
  120. }
  121. /**
  122. * Implements theme_menu_tree().
  123. */
  124. function bartik_menu_tree($variables) {
  125. return '<ul class="menu clearfix">' . $variables['tree'] . '</ul>';
  126. }
  127. /**
  128. * Implements theme_field__field_type().
  129. */
  130. function bartik_field__taxonomy_term_reference($variables) {
  131. $output = '';
  132. // Render the label, if it's not hidden.
  133. if (!$variables['label_hidden']) {
  134. $output .= '<h3 class="field-label">' . $variables['label'] . ': </h3>';
  135. }
  136. // Render the items.
  137. $output .= ($variables['element']['#label_display'] == 'inline') ? '<ul class="links inline">' : '<ul class="links">';
  138. foreach ($variables['items'] as $delta => $item) {
  139. $output .= '<li class="taxonomy-term-reference-' . $delta . '"' . $variables['item_attributes'][$delta] . '>' . drupal_render($item) . '</li>';
  140. }
  141. $output .= '</ul>';
  142. // Render the top-level DIV.
  143. $output = '<div class="' . $variables['classes'] . (!in_array('clearfix', $variables['classes_array']) ? ' clearfix' : '') . '">' . $output . '</div>';
  144. return $output;
  145. }
  146. function bartik_preprocess_page(&$variables, $hook){
  147. //echo "<pre>"; print_r($variables);exit;
  148. if(isset($variables['node'])){
  149. switch($variables['node']->nid){
  150. case '38':
  151. $variables['title'] = '';
  152. $variables['tabs'] = '';
  153. $variables['action_links'] = '';
  154. $variables['breadcrumb'] = '';
  155. break;
  156. case '44':
  157. $variables['title'] = '';
  158. $variables['tabs'] = '';
  159. $variables['action_links'] = '';
  160. $variables['breadcrumb'] = '';
  161. break;
  162. case '45':
  163. $variables['title'] = '';
  164. $variables['tabs'] = '';
  165. $variables['action_links'] = '';
  166. $variables['breadcrumb'] = '';
  167. break;
  168. case '61':
  169. $variables['title'] = '';
  170. $variables['tabs'] = '';
  171. $variables['action_links'] = '';
  172. $variables['breadcrumb'] = '';
  173. break;
  174. }
  175. }
  176. }