/************* Start Body Classes von Basic ****************/
/************************************************************/
// Check if the theme is using Twitter.
$use_twitter = theme_get_setting('use_twitter');
if (is_null($use_twitter)) {
$use_twitter = 1;
}
// If the theme uses Twitter pull it in and display it in the slogan.
if ($use_twitter) {
if ($cache = cache_get('ninesixtyrobots_tweets')) {
$data = $cache->data;
}
else {
$query = theme_get_setting('twitter_search_term');
if (is_null($query)) {
$query = 'lullabot';
}
$query = drupal_urlencode($query);
$response = drupal_http_request('http://search.twitter.com/search.json?q=' . $query);
if ($response->code == 200) {
$data = json_decode($response->data);
// Set a 5 minute cache on retrieving tweets.
// Note if this isn't updating on your site *run cron*.
cache_set('ninesixtyrobots_tweets', $data, 'cache', 300);
}
}
$tweet = $data->results[array_rand($data->results)];
// Create the actual variable finally.
$vars['site_slogan'] = check_plain(html_entity_decode($tweet->text));
}
// Don't display empty help from node_help().
if ($vars['help'] == "<div class=\"help\"><p></p>\n</div>") {
$vars['help'] = '';
}
// Classes for body element. Allows advanced theming based on context
// (home page, node of certain type, etc.)
$body_classes = array($vars['body_classes']);
if (user_access('administer blocks')) {
$body_classes[] = 'admin';
}
if (!empty($vars['primary_links']) or !empty($vars['secondary_links'])) {
$body_classes[] = 'with-navigation';
}
if (!empty($vars['secondary_links'])) {
$body_classes[] = 'with-secondary';
}
if (module_exists('taxonomy') && $vars['node']->nid) {
foreach (taxonomy_node_get_terms($vars['node']) as $term) {
$body_classes[] = 'tax-' . eregi_replace('[^a-z0-9]', '-', $term->name);
}
}
if (!$vars['is_front']) {
// Add unique classes for each page and website section
$path = drupal_get_path_alias($_GET['q']);
list($section, ) = explode('/', $path, 2);
$body_classes[] = basic_id_safe('page-'. $path);
$body_classes[] = basic_id_safe('section-'. $section);
if (arg(0) == 'node') {
if (arg(1) == 'add') {
if ($section == 'node') {
array_pop($body_classes); // Remove 'section-node'
}
$body_classes[] = 'section-node-add'; // Add 'section-node-add'
}
elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
if ($section == 'node') {
array_pop($body_classes); // Remove 'section-node'
}
$body_classes[] = 'section-node-'. arg(2); // Add 'section-node-edit' or 'section-node-delete'
}
}
}
/* // Check what the user's browser is and add it as a body class
// DEACTIVATED - Only works if page cache is deactivated
$user_agent = $_SERVER['HTTP_USER_AGENT'];
if($user_agent) {
if (strpos($user_agent, 'MSIE')) {
$body_classes[] = 'browser-ie';
} else if (strpos($user_agent, 'MSIE 6.0')) {
$body_classes[] = 'browser-ie6';
} else if (strpos($user_agent, 'MSIE 7.0')) {
$body_classes[] = 'browser-ie7';
} else if (strpos($user_agent, 'MSIE 8.0')) {
$body_classes[] = 'browser-ie8';
} else if (strpos($user_agent, 'Firefox/2')) {
$body_classes[] = 'browser-firefox2';
} else if (strpos($user_agent, 'Firefox/3')) {
$body_classes[] = 'browser-firefox3';
}else if (strpos($user_agent, 'Safari')) {
$body_classes[] = 'browser-safari';
} else if (strpos($user_agent, 'Opera')) {
$body_classes[] = 'browser-opera';
}
}
/* Add template suggestions based on content type
* You can use a different page template depending on the
* content type or the node ID
* For example, if you wish to have a different page template
* for the story content type, just create a page template called
* page-type-story.tpl.php
* For a specific node, use the node ID in the name of the page template
* like this : page-node-22.tpl.php (if the node ID is 22)
*/
if ($vars['node']->type != "") {
$vars['template_files'][] = "page-type-" . $vars['node']->type;
}
if ($vars['node']->nid != "") {
$vars['template_files'][] = "page-node-" . $vars['node']->nid;
}
$vars['body_classes'] = implode(' ', $body_classes);
/************************* Ende Body Classes von Basic *******************/