Ejemplo n.º 1
0
function templateName_preprocess_html(&$variables)
{
    $node = node_load(arg(1));
    $results = taxonomy_node_get_terms($node);
    if (is_array($results)) {
        foreach ($results as $item) {
            $variables['classes_array'][] = "taxonomy-" . strtolower(drupal_clean_css_identifier($item->name));
        }
    }
}
Ejemplo n.º 2
0
/**
 * // Adds classes to the body tag.
 */
function scholar_base_preprocess_page(&$vars, $hook)
{
    $vars['styles'] .= $vars['conditional_styles'] = variable_get('conditional_styles_' . $GLOBALS['theme'], '');
    //dpm($vars['conditional_styles']);
    $body_classes = array($vars['body_classes']);
    //Replace left and right with first and second
    $original = array('left', 'right');
    $new = array('first', 'second');
    $body_classes = str_replace($original, $new, $body_classes);
    if (!$vars['is_front']) {
        // Add unique classes for each page/site section
        // (This snippet comes from Zen but is modified.)
        //$path = drupal_get_path_alias($_GET['q']);
        list($section, ) = explode('/', $_GET['q'], 2);
        $body_classes[] = scholar_base_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'
            }
        }
    }
    if (module_exists('taxonomy') && $vars['node']->nid) {
        foreach (taxonomy_node_get_terms($vars['node']) as $term) {
            $body_classes[] = 'category-' . str_replace(' ', '-', scholar_base_id_safe($term->name));
        }
    }
    //Adds OpenScholar header region awareness to body classes
    $regions = array('left' => $vars['header_left'], 'main' => $vars['header_main'], 'right' => $vars['header_right']);
    $non_empty_regions = array_filter($regions, "__scholar_base_is_empty");
    $header_classes = 'header-';
    if (count($non_empty_regions)) {
        $header_classes .= implode('-', array_keys($non_empty_regions));
    } else {
        $header_classes .= 'none';
    }
    $body_classes[] = $header_classes;
    $vars['body_classes'] = implode(' ', $body_classes);
}
Ejemplo n.º 3
0
?>
" class="node<?php 
if ($sticky) {
    print ' sticky';
}
if (!$status) {
    print ' node-unpublished';
}
?>
 clear-block">	
	 <hr>
<div class="type clearfix">
	<?php 
$filepage = $field_pdf_upload[0]['filepath'];
$fileurl = $field_url[0]['value'];
$terms = taxonomy_node_get_terms($node, $key = 'tid');
foreach ($terms as $term) {
    switch ($term->tid) {
        case 103:
            if (!empty($filepage)) {
                $filepath = "/{$filepage}";
                // Articles/Reports
            } else {
                $filepath = $fileurl;
            }
            $classtax = "articles";
            $termname = $term->name;
            break;
        case 197:
            if (!empty($filepage)) {
                $filepath = "/{$filepage}";
Ejemplo n.º 4
0
/**
 * Implementation of template_preprocess_page().
 */
function csa_base_preprocess_page(&$variables)
{
    $conditional = array();
    $query_string = '?' . substr(variable_get('css_js_query_string', '0'), 0, 1);
    $conditional['IE'] = array();
    // Target all IE versions
    $conditional['IE 6'] = array();
    // Target Internet Explorer 6 only
    $conditional['IE 7'] = array();
    // Target Internet Explorer 7 only
    $conditional['IE 8'] = array();
    // Target Internet Explorer 8 only
    $conditional['IE 6'][] .= '<script type="text/javascript">var blankImgIE="' . theme('theme_path', '/images/blank.gif') . '";</script>';
    $conditional['IE 6'][] .= '<style type="text/css" media="all">@import "' . theme('theme_path', '/css/fix-ie-6.css') . $query_string . '";</style>';
    $conditional['IE 6'][] .= '<style type="text/css">img { behavior: url(' . theme('theme_path', '/script/iepngfix.htc') . $query_string . ') }</style>';
    $conditional['IE 7'][] .= '<style type="text/css" media="all">@import "' . theme('theme_path', '/css/fix-ie-7.css') . $query_string . '";</style>';
    $conditional_output = '';
    foreach ($conditional as $version => $rules) {
        if (count($rules)) {
            $conditional_output .= '<!--[if ' . $version . "]>\n";
            foreach ($rules as $rule) {
                $conditional_output .= $rule . "\n";
            }
            $conditional_output .= "<![endif]-->\n";
        }
    }
    // Rebuild the $scripts output
    $js = drupal_add_js();
    // remove sticky table headers, we use our own modified version for this
    unset($js['module']['misc/tableheader.js']);
    $variables['scripts'] = drupal_get_js('header', $js) . $conditional_output;
    // Rebuild the $styles output
    $css = drupal_add_css();
    $variables['styles'] = drupal_get_css($css);
    $http = empty($_SERVER['HTTPS']) ? 'http' : 'https';
    $variables['styles'] .= "<link href='" . $http . "://fonts.googleapis.com/css?family=Molengo' rel='stylesheet' type='text/css'>\n";
    $variables['styles'] .= "<link href='" . $http . "://fonts.googleapis.com/css?family=Droid+Sans' rel='stylesheet' type='text/css'>\n";
    // add a var $admin_section to see if we are in the admin section of the site
    $variables['admin_section'] = FALSE;
    if (arg(0) == 'admin' || arg(2) == 'edit' || arg(2) == 'webform-results') {
        $variables['body_classes'] .= ' admin-section';
        $variables['admin_section'] = TRUE;
    }
    // Move second sidebar to first if this option is enabled in the theme settings and the user is viewing an admin page
    if (theme_get_setting('csa_base_move_sidebar') && $variables['admin_section']) {
        if (!empty($variables['sidebar_1']) && !empty($variables['sidebar_2'])) {
            $variables['sidebar_1'] .= $variables['sidebar_2'];
            unset($variables['sidebar_2']);
        } elseif (!empty($variables['sidebar_2'])) {
            $variables['sidebar_1'] = $variables['sidebar_2'];
            unset($variables['sidebar_2']);
        }
    }
    // Set up layout variable
    $variables['layout'] = 'none';
    if (!empty($variables['sidebar_1'])) {
        $variables['layout'] = 'sidebar-1';
    }
    if (!empty($variables['sidebar_2'])) {
        $variables['layout'] = $variables['layout'] == 'sidebar-1' ? 'both' : 'sidebar-2';
    }
    // Strip sidebar classes from the body
    $variables['body_classes'] = str_replace(array('both', 'no-sidebars', 'two-sidebars', 'one-sidebar', 'sidebar-left', 'sidebar-right'), '', $variables['body_classes']);
    // Remove excess spaces
    $variables['body_classes'] = str_replace('  ', ' ', trim($variables['body_classes']));
    // Add information about the number of sidebars
    if ($variables['layout'] == 'both') {
        $variables['body_classes'] .= ' two-sidebars';
    } elseif ($variables['layout'] == 'none') {
        $variables['body_classes'] .= ' no-sidebars';
    } else {
        $variables['body_classes'] .= ' one-sidebar ' . $variables['layout'];
    }
    // add the taxonomy terms to the body_classes
    if (module_exists('taxonomy') && !empty($variables['node_terms'])) {
        $terms = array();
        foreach (taxonomy_node_get_terms($variables['node']) as $term) {
            $terms[] = $variables['node_terms'] . csa_base_safe_css_name($term->name);
        }
        if (count($terms)) {
            $variables['body_classes'] .= ' ' . implode(' ', $terms);
        }
    }
    if (!empty($variables['logo'])) {
        $logo_img = theme('image', substr($variables['logo'], strlen(base_path()), strlen($variables['logo'])), $variables['site_name'], $variables['site_name']);
        $variables['logo'] = l($logo_img, "<front>", array('html' => 'true', 'attributes' => array('title' => $variables['site_name'])));
    }
    // Display mission statement on all pages?
    if (theme_get_setting('mission_statement_pages') == 'all') {
        $variables['mission'] = theme_get_setting('mission', FALSE);
    }
    // Show the title in the breadcrumb?
    if (!theme_get_setting('breadcrumb_display_admin') && $variables['admin_section'] || theme_get_setting('breadcrumb_display') == 0 && !$variables['admin_section']) {
        //Hide breadcrumb on all pages?
        unset($variables['breadcrumb']);
    } elseif (theme_get_setting('breadcrumb_with_title')) {
        $variables['breadcrumb'] = theme('breadcrumb', drupal_get_breadcrumb(), $variables['title']);
    }
    $title = t(variable_get('site_name', ''));
    $slogan = t(variable_get('site_slogan', ''));
    $mission = t(variable_get('site_mission', ''));
    $page_title = t(drupal_get_title());
    $title_separator = theme_get_setting('configurable_separator');
    // Front page title settings
    if (drupal_is_front_page()) {
        switch (theme_get_setting('front_page_title_display')) {
            case 'title_slogan':
                $variables['head_title'] = drupal_set_title($title . $title_separator . $slogan);
                break;
            case 'slogan_title':
                $variables['head_title'] = drupal_set_title($slogan . $title_separator . $title);
                break;
            case 'title_mission':
                $variables['head_title'] = drupal_set_title($title . $title_separator . $mission);
                break;
            case 'custom':
                if (theme_get_setting('page_title_display_custom') !== '') {
                    $variabless['head_title'] = drupal_set_title(t(theme_get_setting('page_title_display_custom')));
                }
        }
    } else {
        // Non-front page title settings
        switch (theme_get_setting('other_page_title_display')) {
            case 'ptitle_slogan':
                $variables['head_title'] = drupal_set_title($page_title . $title_separator . $slogan);
                break;
            case 'ptitle_stitle':
                $variables['head_title'] = drupal_set_title($page_title . $title_separator . $title);
                break;
            case 'ptitle_smission':
                $variables['head_title'] = drupal_set_title($page_title . $title_separator . $mission);
                break;
            case 'ptitle_custom':
                if (theme_get_setting('other_page_title_display_custom') !== '') {
                    $variables['head_title'] = drupal_set_title($page_title . $title_separator . t(theme_get_setting('other_page_title_display_custom')));
                }
                break;
            case 'custom':
                if (theme_get_setting('other_page_title_display_custom') !== '') {
                    $variables['head_title'] = drupal_set_title(t(theme_get_setting('other_page_title_display_custom')));
                }
        }
    }
    // Set variables for the primary and secondary links
    if (!empty($variables['primary_links'])) {
        if (theme_get_setting('primary_links_allow_tree')) {
            $variables['primary_menu'] = menu_tree(variable_get('menu_primary_links_source', 'primary-links'));
        } else {
            $variables['primary_menu'] = theme('links', $variables['primary_links'], array('class' => 'menu primary-links'));
        }
    }
    if (!empty($variables['secondary_links'])) {
        if (theme_get_setting('secondary_links_allow_tree')) {
            $variables['secondary_menu'] = menu_tree(variable_get('menu_secondary_links_source', 'secondary-links'));
        } else {
            $variables['secondary_menu'] = theme('links', $variables['secondary_links'], array('class' => 'menu secondary-links'));
        }
    }
    if (theme_get_setting('hide_front_page_title') && drupal_is_front_page()) {
        $variables['title'] = NULL;
    } else {
        // Remove any potential html tags
        $variables['head_title'] = strip_tags($variables['head_title']);
    }
}
Ejemplo n.º 5
0
function scholar_preprocess_page(&$vars, $hook)
{
    // 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 (theme_get_setting('scholar_wireframe')) {
        $body_classes[] = 'with-wireframes';
        // Optionally add the wireframes style.
    }
    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[] = scholar_id_safe('page-' . $path);
        $body_classes[] = scholar_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'
            }
        }
    }
    /* 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);
    // Concatenate with spaces
}
Ejemplo n.º 6
0
/**
 * Override or insert variables into the node templates.
 *
 * @param $vars
 *   An array of variables to pass to the theme template.
 * @param $hook
 *   The name of the template being rendered ("node" in this case.)
 */
function quilted_custom_preprocess_node(&$vars, $hook)
{
    // Optionally, run node-type-specific preprocess functions, like
    // quilted_custom_preprocess_node_page() or quilted_custom_preprocess_node_story().
    $function = __FUNCTION__ . '_' . $vars['node']->type;
    if (function_exists($function)) {
        $function($vars, $hook);
    }
    // Class hacking
    // $classes = explode(' ', $vars['classes']); // Explode with spaces
    // $classes[] = 'activity-type-' . $activity_type;
    // $vars['classes'] = implode(' ', $classes); // Concatenate with spaces
    // This is LIFO (Last In First Out) so put them in reverse order, i.e. most important last.
    if ($vars['page']) {
        $vars['template_files'] = array('node-' . $vars['node']->type, 'node-default-page', 'node-' . $vars['node']->type . '-page', 'node-' . $vars['node']->nid, 'node-' . $vars['node']->nid . '-page');
    } else {
        $vars['template_files'] = array('node-default', 'node-' . $vars['node']->type, 'node-' . $vars['node']->nid);
    }
    // Set up items in taxonomies
    if ($terms = taxonomy_node_get_terms($vars['node'], $key = 'tid')) {
        foreach ($terms as $tid => $term) {
            $terms_by_vid[$term->vid][$tid] = $term;
        }
    }
    // set up $taxo1
    if (is_array($terms_by_vid[1])) {
        $terms = array();
        foreach ($terms_by_vid[1] as $term_single) {
            $terms[] = l($term_single->name, 'taxonomy/term/' . $term_single->tid, array('title' => $term_single->description));
        }
        $vars['taxo1'] = implode(', ', $terms);
    }
    // add access check here
    if (node_access('update', $vars['node'])) {
        $vars['edit_link'] = l(t('[Edit]'), 'node/' . $vars['node']->nid . '/edit');
    }
    // Set up read more link
    $read_more_link_options = array('html' => TRUE, 'attributes' => array('class' => 'read-more'));
    //$url = $vars['user_url']; // for user link
    $url = 'node/' . $vars['node']->nid;
    // regular node_link
    $vars['more_link'] = l(t("Read more&nbsp;&raquo;"), $url, $read_more_link_options);
    // EXAMPLES OF COMMON FIELDS
    // To-do: These should all be modified so that they each allow for multiple values in the field.
    /* Set up taxonomy terms list */
    // if ($vars['node']->taxo_vocab_language) {
    //   $vars['languages'] = $vars['node']->taxo_vocab_language;
    // }
    /* Set up field type text field */
    // if ($vars['node']->field_event_title[0]['value']) {
    //   $vars['event_title'] = check_markup($vars['node']->field_event_title[0]['value'], $vars['node']->field_event_title[0]['format']);
    // }
    /* Set up field type textarea */
    // // Set up description
    //   if ($vars['node']->field_event_description[0]['value']) {
    //     $vars['event_description'] = check_markup($vars['node']->field_event_description[0]['value'], $vars['node']->field_event_description[0]['format']);
    //   }
    /* Set up field type node reference */
    // // Set up $event_organization
    //   if (is_numeric($vars['node']->field_event_organization[0]['nid'])) {
    //     $org_node = node_load($vars['node']->field_event_organization[0]['nid']);
    //     $vars['event_organization'] = l($org_node->title, 'node/' . $org_node->nid);
    //   }
    /* Set up field type user reference */
    /* Set up field type location */
    // // Set up $location
    //   if ($vars['node']->field_event_locations[0]) {
    //     $vars['event_location'] = theme('location', $vars['node']->field_event_locations[0]);
    //   }
    /* Set up field type image */
    // This is a relatively complicated example
    // if ($vars['page'] == 0) {
    //   // if we are looking at a teaser, define a default image if no images have been uploaded
    //   if ($vars['node']->field_housing_group_image[0]['filepath']) {
    //     $image_filepath = $vars['node']->field_housing_group_image[0]['filepath'];
    //   } else {
    //     $image_filepath = path_to_theme() . '/images/default-home-icon.png';
    //   }
    //
    //   $link_options = array(
    //     'html' => TRUE,
    //   );
    //
    //   if ($image_filepath) {
    //     $vars['housing_group_images'] = l(theme('imagecache', 'home_teaser', $image_filepath, $alt, $title, $attributes), 'node/' . $vars['node']->nid, $link_options);
    //   }
    //
    // } elseif ($vars['node']->field_housing_group_image[0]['filepath']) {
    //   // Add image pager here when ready
    //   $image_filepath = $vars['node']->field_housing_group_image[0]['filepath'];
    //   $vars['housing_group_images'] = theme('imagecache', 'home_page', $image_filepath, $alt, $title, $attributes);
    // }
    /* Set up field type link */
    // // Set up $event_registration_link
    //   if ($vars['node']->field_event_registration_link[0]['url']) {
    //     if (check_plain($vars['node']->field_event_registration_link[0]['title'])) {
    //       $title = $vars['node']->field_event_registration_link[0]['title'];
    //     } else {
    //       $title = $vars['node']->field_event_registration_link[0]['url'];
    //     }
    //     $url = check_plain($vars['node']->field_event_registration_link[0]['url']);
    //     $link_options = array('html' => FALSE,);
    //     $vars['event_registration_link'] = l($title, $url, $link_options);
    //   }
    /* Set up field type datetime with no timezone conversion */
    // if ($vars['node']->field_housing_group_available[0]['value']) {
    //   $date = date_convert($vars['node']->field_housing_group_available[0]['value'], DATE_ISO, DATE_UNIX);
    //   $timezone = 0;
    //   $vars['housing_group_availability_date'] = format_date($date,'custom','F j, Y', $timezone);
    // }
    /* Set up field type datetime with site default timezone conversion */
    // if ($vars['node']->field_housing_group_available[0]['value']) {
    //   $date = date_convert($vars['node']->field_housing_group_available[0]['value'], DATE_ISO, DATE_UNIX);
    //   $timezone = variable_get('date_default_timezone', 0);
    //   $vars['housing_group_availability_date'] = format_date($date,'custom','F j, Y', $timezone);
    // }
    /* Set up field type datetime with user timezone conversion */
    // if ($vars['node']->field_housing_group_available[0]['value']) {
    //   $date = date_convert($vars['node']->field_housing_group_available[0]['value'], DATE_ISO, DATE_UNIX);
    //   if ($vars['user']->timezone) {
    //     $timezone = $vars['user']->timezone;
    //   } else {
    //     $timezone = variable_get('date_default_timezone', 0); // fall back to site default
    //   }
    //
    //   $vars['housing_group_availability_date'] = format_date($date,'custom','F j, Y', $timezone);
    // }
    // // Set up $date for start and end dates
    // // Set up $date
    //   if ($vars['node']->field_event_date[0]['value']) {
    //
    //     // Set timezone conversion setting
    //     $timezone = 0;
    //
    //     $date_begin = date_convert($vars['node']->field_event_date[0]['value'], DATE_ISO, DATE_UNIX);
    //
    //     if ($vars['node']->field_event_date[0]['value2']) {
    //       $date_end = date_convert($vars['node']->field_event_date[0]['value2'], DATE_ISO, DATE_UNIX);
    //     }
    //
    //     $event_begin_formatted_full = format_date($date_begin,'custom','M j, Y g:ia', $timezone);
    //     $event_begin_formatted_short_month = format_date($date_begin,'custom','M', $timezone);
    //     $event_begin_formatted_day = format_date($date_begin,'custom','j', $timezone);
    //     $event_end_just_time = format_date($date_end,'custom','g:ia', $timezone);
    //     $event_end_formatted_full = format_date($date_end,'custom','M j, Y g:ia', $timezone);
    //
    //     if (format_date($date_begin,'custom','M j, Y') == format_date($date_end,'custom','M j, Y')) {
    //       $vars['event_date'] = theme_date_display_range($event_begin_formatted_full, $event_end_just_time);
    //     } else {
    //       $vars['event_date'] = theme_date_display_range($event_begin_formatted_full, $event_end_formatted_full);
    //     }
    //
    //     $vars['event_date_icon'] = '<div class="month">' . $event_begin_formatted_short_month . '</div><div class="day">' . $event_begin_formatted_day . '</div>';
    //   }
    /* Set up field type phone / fax */
    // // Set up $event_phone
    //   if ($vars['node']->field_event_registration_phone[0]['value']) {
    //     $vars['event_phone'] = check_plain($vars['node']->field_event_registration_phone[0]['value']);
    //   }
    /* Set up number field (formatted as 12,893) */
    // if (is_numeric($vars['node']->field_housing_group_estimated[0]['value'])) {
    //   $vars['housing_group_estimated'] =  number_format(check_plain($vars['node']->field_housing_group_estimated[0]['value']));
    // }
    /* Set up number field (formatted as dollars - $123,763) */
    // To-do: figure out a number field format that accomodates cents
    // if (is_numeric($vars['node']->field_housing_group_estimated[0]['value'])) {
    //   $vars['housing_group_estimated'] = "\$" . number_format(check_plain($vars['node']->field_housing_group_estimated[0]['value']));
    // }
}
Ejemplo n.º 7
0
function regency_preprocess_page(&$vars, $hook) {
  
  // Hack to fix admin_menu title problem. http://drupal.org/node/376237
  if (stripos($vars['head_title'],'icon_users.png')) {
    $vars['head_title'] = 'User account | ' . variable_get('site_name', '');
  }
  if (stripos($vars['title'],'icon_users.png')) {
    $vars['title'] = 'User account';
  }

  // 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 (theme_get_setting('regency_wireframe')) {
    $body_classes[] = 'with-wireframes'; // Optionally add the wireframes style.
  }
  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[] = regency_id_safe('page-'. $path);
    $body_classes[] = regency_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); // Concatenate with spaces

}
Ejemplo n.º 8
0
function _mark_active_trail(&$tree)
{
    $path = $_GET['q'];
    $query = db_query('SELECT vid FROM node WHERE nid = %d LIMIT 1', arg(1));
    $node = db_fetch_object($query);
    //$node=node_load(arg(1));
    $terms = taxonomy_node_get_terms($node);
    $first_term = array_pop($terms);
    if ($first_term->vid == 2) {
        $tid = $first_term->tid;
    }
    foreach ($tree as $item => &$menu_item) {
        $menu_item['link']['localized_options']['attributes']['title'] = $menu_item['link']['link_title'];
        //$menu_item['link']['localized_options']['attributes']['class']='active';
        $link_path = explode('/', $menu_item['link']['link_path']);
        //print_r($menu_item);
        if ($link_path[0] == 'node' && is_numeric($link_path[1])) {
            $link_nid = $link_path[1];
            $sub_query = db_query('SELECT vid FROM node WHERE nid = %d LIMIT 1', $link_nid);
            $link_node = db_fetch_object($sub_query);
            $link_terms = taxonomy_node_get_terms($link_node);
            //print_R($link_terms);
            $first_link_term = array_pop($link_terms);
            // drupal_set_message("arg1: ".arg(1)." tid: ".$tid." linktitle: ".$menu_item['link']['link_title']);
            $barnehager = array(3, 9, 55, 4, 11, 10, 12, 60);
            if ((in_array($tid, $barnehager) || arg(1) == 6482) && ($menu_item['link']['link_title'] == 'Barnehage' || $menu_item['link']['link_title'] == 'Søknad' || $menu_item['link']['link_title'] == 'priser')) {
                $menu_item['link']['localized_options']['attributes']['class'] = 'active';
            }
            $idrett = array(7, 37, 48, 35, 33, 59, 34, 32, 36);
            if ((in_array($tid, $idrett) || arg(1) == 6484) && ($menu_item['link']['link_title'] == 'Trening' || $menu_item['link']['link_title'] == 'Kraft' || $menu_item['link']['link_title'] == 'booking' || $menu_item['link']['link_title'] == 'timeplan')) {
                $menu_item['link']['localized_options']['attributes']['class'] = 'active';
            }
            $bolig = array(6, 62, 13, 15, 56, 16, 17, 14, 19, 20, 18, 21, 38, 22);
            if ((in_array($tid, $bolig) || arg(1) == 1057) && ($menu_item['link']['link_title'] == 'Bolig' || $menu_item['link']['link_title'] == 'Hybler' || $menu_item['link']['link_title'] == 'leiligheter')) {
                $menu_item['link']['localized_options']['attributes']['class'] = 'active';
            }
            if ($first_link_term->tid == $tid && !is_null($tid)) {
                //drupal_set_message($menu_item['link']['link_title'].' local nid: '.$link_nid.' local_vid:'.$link_node->vid.' tid:'.$tid.' local tid:'.$first_link_term->tid);
                $menu_item['link']['localized_options']['attributes']['class'] = 'active';
            }
        }
        if (is_array($menu_item['below']) > 0) {
            _mark_active_trail($menu_item['below']);
        }
    }
}
Ejemplo n.º 9
0
/**
* Theme the forums to look like phpBB
*/
function _phptemplate_variables($hook, $vars)
{
    static $is_forum;
    $variables = array();
    if (!isset($is_forum)) {
        if (arg(0) == 'node' && is_numeric(arg(1)) && arg(2) == '') {
            $nid = arg(1);
        }
        if (arg(0) == 'comment' && arg(1) == 'reply' && is_numeric(arg(2))) {
            $nid = arg(2);
        }
        if ($nid) {
            $node = node_load(array('nid' => $nid));
        }
        $is_forum = $node && $node->type == 'forum';
        _is_forum($is_forum);
    }
    if ($is_forum) {
        switch ($hook) {
            case 'comment':
                $variables['template_file'] = 'node-forum';
                $variables['row_class'] = _row_class();
                $variables['name'] = $vars['author'];
                $variables['userid'] = $vars['comment']->uid;
                $joined = module_invoke('flatforum', 'get_created', $vars['comment']->uid);
                $variables['joined'] = $joined ? format_date($joined, 'custom', 'Y-m-d') : '';
                $posts = module_invoke('flatforum', 'get', $vars['comment']->uid);
                $variables['posts'] = $posts ? $posts : 0;
                $variables['submitted'] = format_date($vars['comment']->timestamp);
                $subject = $vars['comment']->subject;
                $variables['title'] = empty($subject) ? '&nbsp' : $subject;
                $variables['content'] = $vars['comment']->comment;
                $variables['links'] = empty($vars['links']) ? '&nbsp' : $vars['links'];
                break;
            case 'node':
                $variables['row_class'] = _row_class();
                $variables['userid'] = $vars['node']->uid;
                $joined = module_invoke('flatforum', 'get_created', $vars['node']->uid);
                $variables['joined'] = $joined ? format_date($joined, 'custom', 'Y-m-d') : '';
                $posts = module_invoke('flatforum', 'get', $vars['node']->uid);
                $variables['posts'] = $posts ? $posts : 0;
                $variables['title'] = empty($vars['title']) ? '&nbsp' : $vars['title'];
                $variables['content'] = $vars['node']->body;
                $variables['links'] = empty($vars['links']) ? '&nbsp' : $vars['links'];
                break;
        }
    }
    if ($hook == 'node') {
        if (module_exists("taxonomy_image")) {
            foreach (taxonomy_node_get_terms($vars['node']->nid) as $term) {
                $variables['taxonomy_images'][] = taxonomy_image_display($term->tid);
            }
        }
        if (module_exists("taxonomy_text")) {
            foreach (taxonomy_node_get_terms($vars['node']->nid) as $term) {
                $variables['taxonomy_text'][] = taxonomy_text_display($term->tid);
            }
        }
    }
    return $variables;
}
Ejemplo n.º 10
0
          </ul> 
          

      </div>
  </div>
  
  
  <div id="container">
    <?php 
if ($help_toggler) {
    print $help_toggler;
}
?>
       <?php 
$node = menu_get_object();
$tax = taxonomy_node_get_terms($node->nid);
?>
 
       
        
    <?php 
if (!$is_front) {
    ?>
    <div id="section-title-wrap">
        <div id="section-title">
        <h1 class='page-title <?php 
    print $page_icon_class;
    ?>
'>
             <?php 
    # var_dump($variables['search_box']);
Ejemplo n.º 11
0
function html5_base_preprocess_page(&$vars, $hook)
{
    // charrset
    // Set charset to html5 method
    $vars['head'] = str_replace('<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />', '<meta charset="utf-8" />', $vars['head']);
    // Modernizr
    // Add "no-js" class to <html> if Modernizr is included
    if (theme_get_setting('html5_base_modernizr')) {
        $vars['modernizr_head'] = 'class="no-js"';
    }
    // Always force latest IE rendering engine (even in intranet) & Chrome Frame
    if (theme_get_setting('html5_base_include_chrome_frame')) {
        $vars['head'] = drupal_set_html_head('<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">');
    }
    // dsm($vars);
    // Mobile Viewport Fix
    if (theme_get_setting('html5_base_use_mobile_viewport') && strlen(theme_get_setting('html5_base_mobile_viewport')) > 1) {
        $vars['head'] = drupal_set_html_head('<meta name="viewport" content="' . theme_get_setting('html5_base_mobile_viewport') . '">');
    }
    // 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 = explode(' ', $vars['body_classes']);
    if (user_access('administer blocks')) {
        $body_classes[] = 'admin';
    }
    if (theme_get_setting('html5_base_wireframe')) {
        $body_classes[] = 'with-wireframes';
        // Optionally add the wireframes style.
    }
    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') && isset($vars['node']) && $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[] = html5_base_id_safe('page-' . $path);
        $body_classes[] = html5_base_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'
            }
        }
    }
    $vars['layout'] = 'none';
    if (!empty($vars['sidebar_first'])) {
        $vars['layout'] = 'first';
    }
    if (!empty($vars['sidebar_second'])) {
        $vars['layout'] = $vars['layout'] == 'first' ? 'both' : 'second';
    }
    // If the layout is 'none', then template_preprocess_page() will already have
    // set a 'no-sidebars' class since it won't find a 'left' or 'right' sidebar.
    if ($vars['layout'] != 'none') {
        // Remove the incorrect 'no-sidebars' class.
        if ($index = array_search('no-sidebars', $body_classes)) {
            unset($body_classes[$index]);
        }
        // Set the proper layout body classes.
        if ($vars['layout'] == 'both') {
            $body_classes[] = 'two-sidebars';
        } else {
            $body_classes[] = 'one-sidebar';
            $body_classes[] = 'sidebar-' . $vars['layout'];
        }
    }
    /*  // 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 (isset($vars['node']) && $vars['node']->type != "") {
        $vars['template_files'][] = "page-type-" . $vars['node']->type;
    }
    $vars['body_classes'] = implode(' ', $body_classes);
    // Concatenate with spaces
}
/**
 * Intercept template variables
 *
 * @param $hook
 *   The name of the theme function being executed
 * @param $vars
 *   A sequential array of variables passed to the theme function.
 */
function _phptemplate_variables($hook, $vars = array())
{
    switch ($hook) {
        // Send a new variable, $has_terms, to see wether the current node has any terms
        case 'node':
            if (count(taxonomy_node_get_terms($vars['node']->nid))) {
                $vars['has_terms'] = TRUE;
            } else {
                $vars['has_terms'] = FALSE;
            }
    }
    return $vars;
}
Ejemplo n.º 13
0
function jadu_preprocess_page(&$vars, $hook)
{
    // 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 (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);
        }
    }
    global $user;
    foreach ($user->roles as $role) {
        $body_classes[] = jadu_id_safe($role);
    }
    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[] = jadu_id_safe('page-' . $path);
        $body_classes[] = jadu_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);
    // Concatenate with spaces
}
Ejemplo n.º 14
0
function mnts_preprocess_html(&$vars)
{
    global $user;
    drupal_add_css('http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700|Open+Sans+Condensed:300,700|Raleway:400,300,600,700', array('type' => 'external'));
    drupal_add_css('http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.min.css', array('type' => 'external'));
    drupal_add_js('http://code.jquery.com/ui/1.10.3/jquery-ui.min.js', 'external');
    //agregar jquery
    // drupal_add_js('http://code.jquery.com/jquery-1.11.0.js');
    // Add role name classes (to allow css based show for admin/hidden from user)
    foreach ($user->roles as $role) {
        $vars['classes_array'][] = 'role-' . mnts_id_safe($role);
    }
    // HTML Attributes
    // Use a proper attributes array for the html attributes.
    $vars['html_attributes'] = array();
    //$vars['html_attributes']['lang'][] = $language->language;
    //$vars['html_attributes']['dir'][] = $language->dir;
    // Convert RDF Namespaces into structured data using drupal_attributes.
    $vars['rdf_namespaces'] = array();
    if (function_exists('rdf_get_namespaces')) {
        foreach (rdf_get_namespaces() as $prefix => $uri) {
            $prefixes[] = $prefix . ': ' . $uri;
        }
        $vars['rdf_namespaces']['prefix'] = implode(' ', $prefixes);
    }
    // Flatten the HTML attributes and RDF namespaces arrays.
    $vars['html_attributes'] = drupal_attributes($vars['html_attributes']);
    $vars['rdf_namespaces'] = drupal_attributes($vars['rdf_namespaces']);
    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);
        $vars['classes_array'][] = 'with-subnav';
        $vars['classes_array'][] = mnts_id_safe('page-' . $path);
        $vars['classes_array'][] = mnts_id_safe('section-' . $section);
        if (arg(0) == 'node') {
            if (arg(1) == 'add') {
                if ($section == 'node') {
                    // Remove 'section-node'
                    array_pop($vars['classes_array']);
                }
                // Add 'section-node-add'
                $vars['classes_array'][] = 'section-node-add';
            } elseif (is_numeric(arg(1)) && (arg(2) == 'edit' || arg(2) == 'delete')) {
                if ($section == 'node') {
                    // Remove 'section-node'
                    array_pop($vars['classes_array']);
                }
                // Add 'section-node-edit' or 'section-node-delete'
                $vars['classes_array'][] = 'section-node-' . arg(2);
            }
        }
    }
    //for normal un-themed edit pages
    if (arg(0) == 'node' && arg(2) == 'edit') {
        $vars['template_files'][] = 'page';
    }
    // Add IE classes.
    if (theme_get_setting('mnts_ie_enabled')) {
        $mnts_ie_enabled_versions = theme_get_setting('mnts_ie_enabled_versions');
        if (in_array('ie8', $mnts_ie_enabled_versions, TRUE)) {
            drupal_add_css(path_to_theme() . '/css/ie8.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 8', '!IE' => FALSE), 'preprocess' => FALSE));
            drupal_add_js(path_to_theme() . '/js/selectivizr-min.js');
        }
        if (in_array('ie9', $mnts_ie_enabled_versions, TRUE)) {
            drupal_add_css(path_to_theme() . '/css/ie9.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 9', '!IE' => FALSE), 'preprocess' => FALSE));
        }
        if (in_array('ie10', $mnts_ie_enabled_versions, TRUE)) {
            drupal_add_css(path_to_theme() . '/css/ie10.css', array('group' => CSS_THEME, 'browsers' => array('IE' => 'IE 10', '!IE' => FALSE), 'preprocess' => FALSE));
        }
    }
    $node = node_load(arg(1));
    $results = taxonomy_node_get_terms($node);
    if (is_array($results)) {
        foreach ($results as $item) {
            $vars['classes_array'][] = "taxonomy-" . replace_specials_characters(strtolower(drupal_clean_css_identifier($item->name)));
        }
    }
    if (arg(0) == 'taxonomy' && arg(1) == 'term') {
        $term = taxonomy_term_load(arg(2));
        $vars['classes_array'][] = 'vocabulary-' . strtolower($term->vocabulary_machine_name);
    }
}