html.pre.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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. // this is not working anymore, node object don't shows up on vars
  61. $node = isset($vars['node']) ? $vars['node'] : false;
  62. # add body classes
  63. if($node){
  64. # from taxonomy
  65. foreach ($vars['node']->taxonomy as $tid => $term) {
  66. $vars['classes_array'][] = 'term-vid-'. $term->vid .' term-tid-'. $tid;
  67. }
  68. # from menu
  69. $mlid = db_result(db_query("SELECT mlid FROM {menu_links} WHERE link_path = '%s'", 'node/'. $vars['node']->nid));
  70. // Now get the menu related information.
  71. if (!empty($mlid) || !empty($node->menu['mlid']) || !empty($node->menu['plid'])) {
  72. $menu_link = menu_link_load($mlid);
  73. // krumo($menu_link);
  74. $vars['classes_array'][] = ' mlid-'. $menu_link['mlid'] .' plid-'. $menu_link['plid'];
  75. }
  76. }
  77. foreach ($vars['user']->roles as $key => $value) {
  78. $vars['classes_array'][] = "role-" . $key;
  79. }
  80. // dsm($vars);
  81. // if(){
  82. // $vars['classes_array'][] = "fixed-grid";
  83. // }
  84. /*
  85. if(isset($vars['page']['sidebar_first']) && isset($vars['page']['sidebar_second'])){
  86. $layout = 'two-sidebars';
  87. }else if(isset($vars['page']['sidebar_first']) || isset($vars['page']['sidebar_second'])){
  88. $layout = isset($vars['page']['sidebar_first']) ? 'sidebar-first' : 'sidebar-second';
  89. }else{
  90. $layout = 'no-sidebar';
  91. }
  92. $vars['classes_array'][] = $layout;
  93. */
  94. $currentpath = current_path();
  95. $menu_item = menu_get_item($currentpath);
  96. // $node = false;
  97. // if($menu_item['page_callback'] == 'node_page_view')
  98. // $node = $menu_item['page_arguments'][0];
  99. global $language;
  100. drupal_add_js(array('materiobasetheme' => array(
  101. 'strings'=>array(
  102. 'search'=>t('search'),
  103. // 'filter'=>t('filter'),
  104. 'site_name'=>t(variable_get('site_name', '')),
  105. 'site_slogan'=>t(variable_get('site_slogan', '')),
  106. ),
  107. 'themePath'=> drupal_get_path('theme', 'materiobasetheme'),
  108. // 'current_path' => $currentpath,
  109. // 'menu_item' => $menu_item,
  110. 'page_callback' => $menu_item['page_callback'],
  111. 'node_type' => isset($node->type) ? $node->type : false,
  112. 'node_nid' => isset($node->nid) ? $node->nid : false,
  113. 'language'=>$language->language,
  114. )), 'setting');
  115. $head_title_array = array();
  116. foreach ($vars['head_title_array'] as $key => $value){
  117. if($value){
  118. $head_title_array[] = $value;
  119. }
  120. }
  121. $vars['head_title'] = $vars['head_array']['title'] = strip_tags(implode(' | ', $head_title_array));