html.pre.php 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  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. /*
  80. if(isset($vars['page']['sidebar_first']) && isset($vars['page']['sidebar_second'])){
  81. $layout = 'two-sidebars';
  82. }else if(isset($vars['page']['sidebar_first']) || isset($vars['page']['sidebar_second'])){
  83. $layout = isset($vars['page']['sidebar_first']) ? 'sidebar-first' : 'sidebar-second';
  84. }else{
  85. $layout = 'no-sidebar';
  86. }
  87. $vars['classes_array'][] = $layout;
  88. */
  89. $currentpath = current_path();
  90. $menu_item = menu_get_item($currentpath);
  91. // $node = false;
  92. // if($menu_item['page_callback'] == 'node_page_view')
  93. // $node = $menu_item['page_arguments'][0];
  94. global $language;
  95. drupal_add_js(array('materiobasetheme' => array(
  96. 'strings'=>array(
  97. 'search'=>t('search'),
  98. // 'filter'=>t('filter'),
  99. 'site_name'=>t(variable_get('site_name', '')),
  100. 'site_slogan'=>t(variable_get('site_slogan', '')),
  101. ),
  102. 'themePath'=> drupal_get_path('theme', 'materiobasetheme'),
  103. // 'current_path' => $currentpath,
  104. // 'menu_item' => $menu_item,
  105. 'page_callback' => $menu_item['page_callback'],
  106. 'node_type' => isset($node->type) ? $node->type : false,
  107. 'node_nid' => isset($node->nid) ? $node->nid : false,
  108. 'language'=>$language->language,
  109. )), 'setting');
  110. $head_title_array = array();
  111. foreach ($vars['head_title_array'] as $key => $value){
  112. if($value){
  113. $head_title_array[] = $value;
  114. }
  115. }
  116. $vars['head_title'] = $vars['head_array']['title'] = strip_tags(implode(' | ', $head_title_array));