template.php in Hostmaster (Aegir) 6
File
themes/eldir/template.php
View source
<?php
function _phptemplate_variables($hook, $vars) {
global $theme;
$function = "{$theme}_preprocess_{$hook}";
if (function_exists($function)) {
$function($vars);
}
return $vars;
}
function eldir_preprocess_page(&$vars) {
$vars['logo'] = l($vars['site_name'], '<front>');
if ($primary = menu_primary_local_tasks()) {
$vars['tabs'] = "<ul class='links tabs clear-block'>{$primary}</ul>";
}
if ($secondary = menu_secondary_local_tasks()) {
$vars['tabs2'] = "<ul class='links tabs clear-block'>{$secondary}</ul>";
}
if (!empty($vars['node'])) {
$types = node_get_types();
$type = $vars['node']->type;
if (!empty($types[$type])) {
$vars['title'] = "<span class='label'>{$types[$type]->name}</span> {$vars['title']}";
}
$vars['body_classes'] .= " node-page";
$vars['body_classes'] .= " ntype-{$type}";
}
$vars['sidebar_left'] = trim($vars['left']);
$vars['sidebar_right'] = trim($vars['right']);
$vars['body_classes'] .= empty($vars['left']) && empty($vars['right']) ? ' wide' : '';
if (!empty($_GET['q'])) {
$vars['body_classes'] .= ' path-' . drupal_html_class($_GET['q']);
}
$vars['styles_ie6'] = base_path() . path_to_theme() . '/ie6.css';
}
function eldir_preprocess_node(&$vars) {
if (!empty($vars['node'])) {
$types = node_get_types();
$type = $vars['node']->type;
if (!empty($types[$type])) {
$vars['title'] = "<span class='label'>{$types[$type]->name}</span> {$vars['title']}";
}
}
}
function eldir_form_element($element, $value) {
$output = '';
$attr = array(
'class' => '',
);
$attr['id'] = !empty($element['#id']) ? "{$element['#id']}-wrapper" : NULL;
$label_attr = array();
$label_attr['for'] = !empty($element['#id']) ? $element['#id'] : '';
if (!empty($element['#type']) && in_array($element['#type'], array(
'checkbox',
'radio',
))) {
$label_type = 'label';
$attr['class'] .= ' form-item form-option';
}
else {
$label_type = 'label';
$attr['class'] .= ' form-item';
}
$required_title = t('This field is required.');
$required = !empty($element['#required']) ? "<span class='form-required' title='{$required_title}'>*</span>" : '';
if (!empty($element['#title'])) {
$title = t('!title: !required', array(
'!title' => filter_xss_admin($element['#title']),
'!required' => $required,
));
$label_attr = drupal_attributes($label_attr);
$output .= "<{$label_type} {$label_attr}>{$title}</{$label_type}>";
$attr['class'] .= ' form-item-labeled';
}
$output .= "{$value}";
$output .= !empty($element['#description']) ? "<div class='description'>{$element['#description']}</div>" : '';
$attr = drupal_attributes($attr);
$output = "<div {$attr}>{$output}</div>";
return $output;
}
if (!function_exists('drupal_html_class')) {
function drupal_html_class($class) {
$class = strtr(drupal_strtolower($class), array(
' ' => '-',
'_' => '-',
'/' => '-',
'[' => '-',
']' => '',
));
$class = preg_replace('/[^\\x{002D}\\x{0030}-\\x{0039}\\x{0041}-\\x{005A}\\x{005F}\\x{0061}-\\x{007A}\\x{00A1}-\\x{FFFF}]/u', '', $class);
return $class;
}
}