| 1 |
<?php
|
| 2 |
/**
|
| 3 |
* Sets the body-tag class attribute.
|
| 4 |
*
|
| 5 |
* Adds 'sidebar-left', 'sidebar-right' or 'sidebars' classes as needed.
|
| 6 |
*/
|
| 7 |
function phptemplate_body_class($sidebar_left, $sidebar_right) {
|
| 8 |
if ($sidebar_left != '' && $sidebar_right != '') {
|
| 9 |
$class = 'sidebars';
|
| 10 |
}
|
| 11 |
else {
|
| 12 |
if ($sidebar_left != '') {
|
| 13 |
$class = 'sidebar-left';
|
| 14 |
}
|
| 15 |
if ($sidebar_right != '') {
|
| 16 |
$class = 'sidebar-right';
|
| 17 |
}
|
| 18 |
}
|
| 19 |
|
| 20 |
if (isset($class)) {
|
| 21 |
print ' class="'. $class .'"';
|
| 22 |
}
|
| 23 |
}
|
| 24 |
|
| 25 |
/**
|
| 26 |
* Return a themed breadcrumb trail.
|
| 27 |
*
|
| 28 |
* @param $breadcrumb
|
| 29 |
* An array containing the breadcrumb links.
|
| 30 |
* @return a string containing the breadcrumb output.
|
| 31 |
*/
|
| 32 |
function phptemplate_breadcrumb($breadcrumb) {
|
| 33 |
if (!empty($breadcrumb)) {
|
| 34 |
return '<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>';
|
| 35 |
}
|
| 36 |
}
|
| 37 |
|
| 38 |
/**
|
| 39 |
* Allow themable wrapping of all comments.
|
| 40 |
*/
|
| 41 |
function phptemplate_comment_wrapper($content, $type = null) {
|
| 42 |
static $node_type;
|
| 43 |
if (isset($type)) $node_type = $type;
|
| 44 |
|
| 45 |
if (!$content || $node_type == 'forum') {
|
| 46 |
return '<div id="comments">'. $content . '</div>';
|
| 47 |
}
|
| 48 |
else {
|
| 49 |
return '<div id="comments"><h2 class="comments">'. t('Comments') .'</h2>'. $content .'</div>';
|
| 50 |
}
|
| 51 |
}
|
| 52 |
|
| 53 |
/**
|
| 54 |
* Override or insert PHPTemplate variables into the templates.
|
| 55 |
*/
|
| 56 |
function _phptemplate_variables($hook, $vars) {
|
| 57 |
if ($hook == 'page') {
|
| 58 |
|
| 59 |
if ($secondary = menu_secondary_local_tasks()) {
|
| 60 |
$output = '<span class="clear"></span>';
|
| 61 |
$output .= "<ul class=\"tabs secondary\">\n". $secondary ."</ul>\n";
|
| 62 |
$vars['tabs2'] = $output;
|
| 63 |
}
|
| 64 |
|
| 65 |
// Hook into color.module
|
| 66 |
if (module_exists('color')) {
|
| 67 |
_color_page_alter($vars);
|
| 68 |
}
|
| 69 |
return $vars;
|
| 70 |
}
|
| 71 |
return array();
|
| 72 |
}
|
| 73 |
|
| 74 |
/**
|
| 75 |
* Returns the rendered local tasks. The default implementation renders
|
| 76 |
* them as tabs.
|
| 77 |
*
|
| 78 |
* @ingroup themeable
|
| 79 |
*/
|
| 80 |
function phptemplate_menu_local_tasks() {
|
| 81 |
$output = '';
|
| 82 |
|
| 83 |
if ($primary = menu_primary_local_tasks()) {
|
| 84 |
$output .= "<ul class=\"tabs primary\">\n". $primary ."</ul>\n";
|
| 85 |
}
|
| 86 |
|
| 87 |
return $output;
|
| 88 |
}
|
| 89 |
|
| 90 |
/**
|
| 91 |
* Override theme_links to include <span> in list.
|
| 92 |
*/
|
| 93 |
function phptemplate_linksnew($links, $attributes = array('class' => 'links')) {
|
| 94 |
$output = '';
|
| 95 |
|
| 96 |
if (count($links) > 0) {
|
| 97 |
$output = '<ul'. drupal_attributes($attributes) .'>';
|
| 98 |
|
| 99 |
$num_links = count($links);
|
| 100 |
$i = 1;
|
| 101 |
|
| 102 |
foreach ($links as $key => $link) {
|
| 103 |
$class = '';
|
| 104 |
|
| 105 |
// Automatically add a class to each link and also to each LI
|
| 106 |
if (isset($link['attributes']) && isset($link['attributes']['class'])) {
|
| 107 |
$link['attributes']['class'] .= ' ' . $key;
|
| 108 |
$class = $key;
|
| 109 |
}
|
| 110 |
else {
|
| 111 |
$link['attributes']['class'] = $key;
|
| 112 |
$class = $key;
|
| 113 |
}
|
| 114 |
|
| 115 |
// Add first and last classes to the list of links to help out themers.
|
| 116 |
$extra_class = '';
|
| 117 |
if ($i == 1) {
|
| 118 |
$extra_class .= 'first ';
|
| 119 |
}
|
| 120 |
if ($i == $num_links) {
|
| 121 |
$extra_class .= 'last ';
|
| 122 |
}
|
| 123 |
|
| 124 |
|
| 125 |
// Add class active to active li
|
| 126 |
$current = '';
|
| 127 |
if (strstr($class, 'active')) {
|
| 128 |
$current = ' active';
|
| 129 |
}
|
| 130 |
|
| 131 |
$output .= '<li class="'. $extra_class . $class . $current .'"><span>';
|
| 132 |
|
| 133 |
// Is the title HTML?
|
| 134 |
$html = isset($link['html']) && $link['html'];
|
| 135 |
|
| 136 |
// Initialize fragment and query variables.
|
| 137 |
$link['query'] = isset($link['query']) ? $link['query'] : NULL;
|
| 138 |
$link['fragment'] = isset($link['fragment']) ? $link['fragment'] : NULL;
|
| 139 |
|
| 140 |
if (isset($link['href'])) {
|
| 141 |
$output .= l($link['title'], $link['href'], $link['attributes'], $link['query'], $link['fragment'], FALSE, $html);
|
| 142 |
}
|
| 143 |
else if ($link['title']) {
|
| 144 |
//Some links are actually not links, but we wrap these in <span> for adding title and class attributes
|
| 145 |
if (!$html) {
|
| 146 |
$link['title'] = check_plain($link['title']);
|
| 147 |
}
|
| 148 |
$output .= '<span'. drupal_attributes($link['attributes']) .'>'. $link['title'] .'</span>';
|
| 149 |
}
|
| 150 |
|
| 151 |
$i++;
|
| 152 |
$output .= "</span></li>\n";
|
| 153 |
}
|
| 154 |
|
| 155 |
$output .= '</ul>';
|
| 156 |
}
|
| 157 |
|
| 158 |
return $output;
|
| 159 |
}
|
| 160 |
|
| 161 |
?>
|