Fix for Body classes

  1.  /*************  Start Body Classes von Basic ****************/
  2.   /************************************************************/
  3.  
  4.   // Check if the theme is using Twitter.
  5.   $use_twitter = theme_get_setting('use_twitter');
  6.   if (is_null($use_twitter)) {
  7.     $use_twitter = 1;
  8.   }
  9.  
  10.   // If the theme uses Twitter pull it in and display it in the slogan.
  11.   if ($use_twitter) {
  12.     if ($cache = cache_get('ninesixtyrobots_tweets')) {
  13.       $data = $cache->data;
  14.     }
  15.     else {
  16.       $query = theme_get_setting('twitter_search_term');
  17.       if (is_null($query)) {
  18.         $query = 'lullabot';
  19.       }
  20.       $query = drupal_urlencode($query);
  21.  
  22.       $response = drupal_http_request('http://search.twitter.com/search.json?q=' . $query);
  23.       if ($response->code == 200) {
  24.         $data = json_decode($response->data);
  25.         // Set a 5 minute cache on retrieving tweets.
  26.         // Note if this isn't updating on your site *run cron*.
  27.         cache_set('ninesixtyrobots_tweets', $data, 'cache', 300);
  28.       }
  29.     }
  30.     $tweet = $data->results[array_rand($data->results)];
  31.     // Create the actual variable finally.
  32.     $vars['site_slogan'] = check_plain(html_entity_decode($tweet->text));
  33.   }
  34.   // Don't display empty help from node_help().
  35.   if ($vars['help'] == "<div class=\"help\"><p></p>\n</div>") {
  36.     $vars['help'] = '';
  37.   }
  38.  
  39.   // Classes for body element. Allows advanced theming based on context
  40.   // (home page, node of certain type, etc.)
  41.   $body_classes = array($vars['body_classes']);
  42.   if (user_access('administer blocks')) {
  43.           $body_classes[] = 'admin';
  44.         }
  45.         if (!empty($vars['primary_links']) or !empty($vars['secondary_links'])) {
  46.     $body_classes[] = 'with-navigation';
  47.   }
  48.   if (!empty($vars['secondary_links'])) {
  49.     $body_classes[] = 'with-secondary';
  50.   }
  51.   if (module_exists('taxonomy') && $vars['node']->nid) {
  52.     foreach (taxonomy_node_get_terms($vars['node']) as $term) {
  53.     $body_classes[] = 'tax-' . eregi_replace('[^a-z0-9]', '-', $term->name);
  54.     }
  55.   }
  56.   if (!$vars['is_front']) {
  57.     // Add unique classes for each page and website section
  58.     $path = drupal_get_path_alias($_GET['q']);
  59.     list($section, ) = explode('/', $path, 2);
  60.     $body_classes[] = basic_id_safe('page-'. $path);
  61.     $body_classes[] = basic_id_safe('section-'. $section);
  62.  
  63.     if (arg(0) == 'node') {
  64.       if (arg(1) == 'add') {
  65.         if ($section == 'node') {
  66.           array_pop($body_classes); // Remove 'section-node'
  67.         }
  68.         $body_classes[] = 'section-node-add'; // Add 'section-node-add'
  69.       }
  70.       elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
  71.         if ($section == 'node') {
  72.           array_pop($body_classes); // Remove 'section-node'
  73.         }
  74.         $body_classes[] = 'section-node-'. arg(2); // Add 'section-node-edit' or 'section-node-delete'
  75.       }
  76.     }
  77.   }
  78.   /*  // Check what the user's browser is and add it as a body class
  79.       // DEACTIVATED - Only works if page cache is deactivated
  80.       $user_agent = $_SERVER['HTTP_USER_AGENT'];
  81.       if($user_agent) {
  82.         if (strpos($user_agent, 'MSIE')) {
  83.           $body_classes[] = 'browser-ie';
  84.         } else if (strpos($user_agent, 'MSIE 6.0')) {
  85.           $body_classes[] = 'browser-ie6';
  86.         } else if (strpos($user_agent, 'MSIE 7.0')) {
  87.           $body_classes[] = 'browser-ie7';
  88.         } else if (strpos($user_agent, 'MSIE 8.0')) {
  89.           $body_classes[] = 'browser-ie8';
  90.         } else if (strpos($user_agent, 'Firefox/2')) {
  91.           $body_classes[] = 'browser-firefox2';
  92.         } else if (strpos($user_agent, 'Firefox/3')) {
  93.           $body_classes[] = 'browser-firefox3';
  94.         }else if (strpos($user_agent, 'Safari')) {
  95.           $body_classes[] = 'browser-safari';
  96.         } else if (strpos($user_agent, 'Opera')) {
  97.           $body_classes[] = 'browser-opera';
  98.         }
  99.       }
  100.  
  101.   /* Add template suggestions based on content type
  102.    * You can use a different page template depending on the
  103.    * content type or the node ID
  104.    * For example, if you wish to have a different page template
  105.    * for the story content type, just create a page template called
  106.    * page-type-story.tpl.php
  107.    * For a specific node, use the node ID in the name of the page template
  108.    * like this : page-node-22.tpl.php (if the node ID is 22)
  109.    */
  110.  
  111.   if ($vars['node']->type != "") {
  112.       $vars['template_files'][] = "page-type-" . $vars['node']->type;
  113.     }
  114.   if ($vars['node']->nid != "") {
  115.       $vars['template_files'][] = "page-node-" . $vars['node']->nid;
  116.     }
  117.   $vars['body_classes'] = implode(' ', $body_classes);
  118.  
  119.   /*************************  Ende Body Classes von Basic *******************/

Submit Fix

Any tags you'd like to associate with your code, delimitered by commas (example: Views, CCK, Module, etc).
Select the syntax highlighting mode to use.