html.pre.php 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. <?php
  2. // dsm($vars, 'vars');
  3. if (module_exists('rdf')) {
  4. $vars['doctype'] = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML+RDFa 1.1//EN">' . "\n";
  5. $vars['rdf_profile'] = ' profile="' . $vars['grddl_profile'] . '"';
  6. }
  7. else {
  8. $vars['doctype'] = '<!DOCTYPE html>' . "\n";
  9. $vars['rdf_profile'] = '';
  10. }
  11. # Add mobile meta tags to $head ADD this to your subtheme
  12. $heads = array();
  13. // $heads['HandheldFriendly'] = array(
  14. // '#tag' => 'meta',
  15. // '#attributes' => array(
  16. // 'name' => 'HandheldFriendly',
  17. // 'content' => 'true',
  18. // ),
  19. // );
  20. $heads['apple-mobile-web-app-capable'] = array(
  21. '#tag' => 'meta',
  22. '#attributes' => array(
  23. 'name' => 'apple-mobile-web-app-capable',
  24. 'content' => 'yes',
  25. ),
  26. );
  27. # Mobile Viewport Fix
  28. # j.mp/mobileviewport & davidbcalhoun.com/2010/viewport-metatag
  29. # device-width : Occupy full width of the screen in its current orientation
  30. # initial-scale = 1.0 retains dimensions instead of zooming out if page height > device height
  31. # maximum-scale = 1.0 retains dimensions instead of zooming in if page width < device width
  32. $heads['viewport'] = array(
  33. '#tag' => 'meta',
  34. '#attributes' => array(
  35. 'name' => 'viewport',
  36. 'content' => 'width=device-width,initial-scale=1,maximum-scale=1',
  37. ),
  38. );
  39. # Add these icons links to your sub theme
  40. # or Place favicon.ico and apple-touch-icon.png in the root of your domain and delete these references
  41. // $head[] = '<link rel="apple-touch-icon" sizes="72x72" href="'. base_path() . path_to_theme() .'/touch-icon-ipad.png'.'"/>' . "\n";
  42. // $head[] = '<link rel="apple-touch-icon" sizes="114x114" href="'. base_path() . path_to_theme() .'/touch-icon-iphone4.png'.'"/>' . "\n";
  43. $heads['icon'] = array(
  44. '#tag' => 'link',
  45. '#attributes' => array(
  46. 'href' => base_path() . path_to_theme() .'/materio-icon.png',
  47. 'rel' => 'shortcut icon',
  48. 'type' => 'image/png',
  49. ),
  50. );
  51. $heads['apple-touch-icon'] = array(
  52. '#tag' => 'link',
  53. '#attributes' => array(
  54. 'href' => $GLOBALS['base_url'] . base_path() . path_to_theme() .'/materio-touch-icon.png',
  55. 'rel' => 'apple-touch-icon-precomposed',
  56. ),
  57. );
  58. foreach ($heads as $type=>$head)
  59. drupal_add_html_head($head, $type);
  60. $node = isset($vars['node']) ? $vars['node'] : false;
  61. # add body classes
  62. if($node){
  63. # from taxonomy
  64. foreach ($vars['node']->taxonomy as $tid => $term) {
  65. $vars['classes_array'][] = 'term-vid-'. $term->vid .' term-tid-'. $tid;
  66. }
  67. # from menu
  68. $mlid = db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s'", 'node/'. $vars['node']->nid));
  69. // Now get the menu related information.
  70. if (!empty($mlid) || !empty($node->menu['mlid']) || !empty($node->menu['plid'])) {
  71. $menu_link = menu_link_load($mlid);
  72. // krumo($menu_link);
  73. $vars['classes_array'][] = ' mlid-'. $menu_link['mlid'] .' plid-'. $menu_link['plid'];
  74. }
  75. }
  76. foreach ($vars['user']->roles as $key => $value) {
  77. $vars['classes_array'][] = "role-" . $key;
  78. }
  79. // dsm($vars);
  80. // if(){
  81. // $vars['classes_array'][] = "fixed-grid";
  82. // }
  83. /*
  84. if(isset($vars['page']['sidebar_first']) && isset($vars['page']['sidebar_second'])){
  85. $layout = 'two-sidebars';
  86. }else if(isset($vars['page']['sidebar_first']) || isset($vars['page']['sidebar_second'])){
  87. $layout = isset($vars['page']['sidebar_first']) ? 'sidebar-first' : 'sidebar-second';
  88. }else{
  89. $layout = 'no-sidebar';
  90. }
  91. $vars['classes_array'][] = $layout;
  92. */
  93. $currentpath = current_path();
  94. $menu_item = menu_get_item($currentpath);
  95. // $node = false;
  96. // if($menu_item['page_callback'] == 'node_page_view')
  97. // $node = $menu_item['page_arguments'][0];
  98. global $language;
  99. drupal_add_js(array('materiobasetheme' => array(
  100. 'strings'=>array(
  101. 'search'=>t('search'),
  102. // 'filter'=>t('filter'),
  103. 'site_name'=>t(variable_get('site_name', '')),
  104. 'site_slogan'=>t(variable_get('site_slogan', '')),
  105. ),
  106. 'themePath'=> drupal_get_path('theme', 'materiobasetheme'),
  107. // 'current_path' => $currentpath,
  108. // 'menu_item' => $menu_item,
  109. 'page_callback' => $menu_item['page_callback'],
  110. 'node_type' => isset($node->type) ? $node->type : false,
  111. 'node_nid' => isset($node->nid) ? $node->nid : false,
  112. 'language'=>$language->language,
  113. )), 'setting');
  114. $head_title_array = array();
  115. foreach ($vars['head_title_array'] as $key => $value){
  116. if($value){
  117. $head_title_array[] = $value;
  118. }
  119. }
  120. $vars['head_title'] = $vars['head_array']['title'] = strip_tags(implode(' | ', $head_title_array));