| 1 |
<?php
|
| 2 |
|
| 3 |
/**
|
| 4 |
* @file
|
| 5 |
* File which contains theme overrides for the Deco theme.
|
| 6 |
*/
|
| 7 |
|
| 8 |
|
| 9 |
/**
|
| 10 |
* Override or insert PHPTemplate variables into the templates.
|
| 11 |
*/
|
| 12 |
function phptemplate_preprocess_page(&$vars) {
|
| 13 |
$vars['body_classes'] = isset($vars['body_classes']) ? $vars['body_classes'] : '';
|
| 14 |
|
| 15 |
// variable to see if we have a triple sidebars and are not on block admin page
|
| 16 |
$vars['sidebar_triple'] = FALSE;
|
| 17 |
|
| 18 |
// add variable for block admin page
|
| 19 |
$vars['block_admin'] = FALSE;
|
| 20 |
|
| 21 |
if (arg(2) == 'block' && arg(3) == FALSE) {
|
| 22 |
$vars['block_admin'] = TRUE;
|
| 23 |
_deco_alert_layout($vars);
|
| 24 |
$vars['body_classes'] .= ' block-admin';
|
| 25 |
}
|
| 26 |
|
| 27 |
else {
|
| 28 |
|
| 29 |
// convert secondary right sidebar to right sidebar if there's no right sidebar
|
| 30 |
if ($vars['sidebar_right_sec'] && empty($vars['sidebar_right'])) {
|
| 31 |
$vars['sidebar_right'] = $vars['sidebar_right_sec'];
|
| 32 |
$vars['sidebar_right_sec'] = '';
|
| 33 |
}
|
| 34 |
|
| 35 |
// set a class on the body to allow easier css themeing based on the layout type
|
| 36 |
if ($vars['sidebar_right'] && $vars['sidebar_right_sec'] && $vars['sidebar_left']) {
|
| 37 |
$vars['body_classes'] .= ' sidebar-triple';
|
| 38 |
$vars['sidebar_triple'] = TRUE;
|
| 39 |
}
|
| 40 |
elseif ($vars['sidebar_left'] && $vars['sidebar_right']) {
|
| 41 |
$vars['body_classes'] .= ' sidebar-double';
|
| 42 |
}
|
| 43 |
elseif ($vars['sidebar_right'] && $vars['sidebar_right_sec']) {
|
| 44 |
$vars['body_classes'] .= ' sidebar-right-double';
|
| 45 |
}
|
| 46 |
elseif ($vars['sidebar_left']) {
|
| 47 |
$vars['body_classes'] .= ' sidebar-left';
|
| 48 |
}
|
| 49 |
elseif ($vars['sidebar_right'] || $vars['sidebar_right_sec']) {
|
| 50 |
$vars['body_classes'] .= ' sidebar-right';
|
| 51 |
}
|
| 52 |
|
| 53 |
// add additional rightbar body class to reduce css to refer to right sidebars
|
| 54 |
if ($vars['sidebar_right']) {
|
| 55 |
$vars['body_classes'] .= ' rightbar';
|
| 56 |
}
|
| 57 |
}
|
| 58 |
|
| 59 |
// set variables for the logo and slogan
|
| 60 |
$site_fields = array();
|
| 61 |
if ($vars['site_name']) {
|
| 62 |
$site_fields[] = check_plain($vars['site_name']);
|
| 63 |
}
|
| 64 |
if ($vars['site_slogan']) {
|
| 65 |
$site_fields[] = '- '.check_plain($vars['site_slogan']);
|
| 66 |
}
|
| 67 |
|
| 68 |
$vars['site_title'] = implode(' ', $site_fields);
|
| 69 |
|
| 70 |
if (isset($site_fields[0])) {
|
| 71 |
$site_fields[0] = '<span class="site-name">'. $site_fields[0] .'</span>';
|
| 72 |
}
|
| 73 |
if (isset($site_fields[1])) {
|
| 74 |
$site_fields[1] = '<span class="site-slogan">'. $site_fields[1] .'</span>';
|
| 75 |
}
|
| 76 |
|
| 77 |
$vars['site_title_html'] = implode(' ', $site_fields);
|
| 78 |
|
| 79 |
// convert primary links to lowercase and secondary links to uppercase
|
| 80 |
if ($vars['primary_links']) {
|
| 81 |
foreach ($vars['primary_links'] as $key => $link) {
|
| 82 |
$vars['primary_links'][$key]['title'] = strtolower($link['title']);
|
| 83 |
}
|
| 84 |
}
|
| 85 |
if ($vars['secondary_links']) {
|
| 86 |
foreach ($vars['secondary_links'] as $key => $link) {
|
| 87 |
$vars['secondary_links'][$key]['title'] = strtoupper($link['title']);
|
| 88 |
}
|
| 89 |
}
|
| 90 |
}
|
| 91 |
|
| 92 |
/**
|
| 93 |
* Alert the user when the layout is changed based on the used regions.
|
| 94 |
*
|
| 95 |
* @param $regions
|
| 96 |
* An associative array containing the regions.
|
| 97 |
*/
|
| 98 |
function _deco_alert_layout($regions) {
|
| 99 |
if (user_access('administer blocks')) {
|
| 100 |
// remove the block indicators first
|
| 101 |
$sidebars = array(
|
| 102 |
'sidebar_right_sec' => $regions['sidebar_right_sec'],
|
| 103 |
'sidebar_right' => $regions['sidebar_right'],
|
| 104 |
'sidebar_left' => $regions['sidebar_left']
|
| 105 |
);
|
| 106 |
|
| 107 |
foreach ($sidebars as $k => $v) {
|
| 108 |
$sidebars[$k] = preg_replace('/(\<div class="block-region"\>)(.*)(\<\/div\>)/', '', $v);
|
| 109 |
}
|
| 110 |
|
| 111 |
// warn the user that the secondary right sidebar will look like a regular right sidebar
|
| 112 |
if ($sidebars['sidebar_right_sec'] && empty($sidebars['sidebar_right'])) {
|
| 113 |
drupal_set_message(t('Warning: if you add blocks to the <em>secondary right sidebar</em> and leave the <em>right sidebar</em> empty, the <em>secondary right
|
| 114 |
sidebar</em> will be rendered as a regular <em>right sidebar</em>.'));
|
| 115 |
}
|
| 116 |
// warn the user that the three sidebars will look like three equal columns
|
| 117 |
elseif ($sidebars['sidebar_right'] && $sidebars['sidebar_right_sec'] && $sidebars['sidebar_left']) {
|
| 118 |
drupal_set_message(t('Warning: if you add blocks to all three sidebars they will be rendered as three equal columns above the content.'));
|
| 119 |
}
|
| 120 |
}
|
| 121 |
}
|
| 122 |
|
| 123 |
/**
|
| 124 |
* Generates the html to be rendered in the content area. Prevents duplication in the page template file
|
| 125 |
*/
|
| 126 |
function phptemplate_render_content($content, $tabs, $title, $help, $show_messages, $messages, $feed_icons, $body_classes) {
|
| 127 |
|
| 128 |
$in_node = (strstr($body_classes, 'page-node') ? TRUE : FALSE);
|
| 129 |
|
| 130 |
$output = '';
|
| 131 |
$output .= ((!empty($title)) ? '<h2 class="content-title">'.$title.'</h2>' : '');
|
| 132 |
$tabs = menu_primary_local_tasks();
|
| 133 |
|
| 134 |
$output .= ($tabs ? phptemplate_menu_local_tasks('<ul class="tabs primary">'.$tabs.'</ul>') : '');
|
| 135 |
|
| 136 |
$secondary_tabs = menu_secondary_local_tasks();
|
| 137 |
|
| 138 |
$output .= ($secondary_tabs ? phptemplate_menu_secondary_local_tasks('<ul class="tabs secondary">'.$secondary_tabs.'</ul>') : '');
|
| 139 |
$output .= ($help ? '<div class="help">'.$help.'</div>' : '');
|
| 140 |
$output .= (($show_messages && $messages) ? $messages : '');
|
| 141 |
$output .= $content;
|
| 142 |
$output .= ($feed_icons ? $feed_icons : '');
|
| 143 |
|
| 144 |
return $output;
|
| 145 |
}
|
| 146 |
|
| 147 |
/**
|
| 148 |
* Format a group of form items.
|
| 149 |
* Add HTML hooks for advanced styling
|
| 150 |
*
|
| 151 |
* @param $element
|
| 152 |
* An associative array containing the properties of the element.
|
| 153 |
* Properties used: attributes, title, value, description, children, collapsible, collapsed
|
| 154 |
* @return
|
| 155 |
* A themed HTML string representing the form item group.
|
| 156 |
*/
|
| 157 |
function phptemplate_fieldset($element) {
|
| 158 |
if ($element['#collapsible']) {
|
| 159 |
drupal_add_js('misc/collapse.js');
|
| 160 |
|
| 161 |
if (!isset($element['#attributes']['class'])) {
|
| 162 |
$element['#attributes']['class'] = '';
|
| 163 |
}
|
| 164 |
|
| 165 |
$element['#attributes']['class'] .= ' collapsible';
|
| 166 |
if ($element['#collapsed']) {
|
| 167 |
$element['#attributes']['class'] .= ' collapsed';
|
| 168 |
}
|
| 169 |
}
|
| 170 |
|
| 171 |
return '<fieldset'. drupal_attributes($element['#attributes']) .'>'. ($element['#title'] ? '<legend>'. $element['#title'] .'</legend>' : '') .'<div class="top"><div class="bottom"><div class="bottom-ornament">'. (isset($element['#description']) && $element['#description'] ? '<div class="description">'. $element['#description'] .'</div>' : '') . (!empty($element['#children']) ? $element['#children'] : '') . $element['#value'] ."</div></div></div></fieldset>\n";
|
| 172 |
}
|
| 173 |
|
| 174 |
/**
|
| 175 |
* Returns the rendered local tasks. The default implementation renders
|
| 176 |
* them as tabs.
|
| 177 |
*
|
| 178 |
* @ingroup themeable
|
| 179 |
*/
|
| 180 |
function phptemplate_menu_local_tasks($tasks = '') {
|
| 181 |
$output = '';
|
| 182 |
|
| 183 |
if (!empty($tasks)) {
|
| 184 |
$output = "\n<div class=\"content-bar clear-block\"><div class=\"left\">\n". $tasks ."\n</div></div>\n";
|
| 185 |
}
|
| 186 |
|
| 187 |
return $output;
|
| 188 |
}
|
| 189 |
|
| 190 |
/**
|
| 191 |
* Returns the rendered local tasks. The default implementation renders
|
| 192 |
* them as tabs.
|
| 193 |
*
|
| 194 |
* @ingroup themeable
|
| 195 |
*/
|
| 196 |
function phptemplate_menu_secondary_local_tasks($tasks = '') {
|
| 197 |
$output = '';
|
| 198 |
|
| 199 |
if (!empty($tasks)) {
|
| 200 |
$output = "\n<div class=\"content-bar-indented\"><div class=\"content-bar clear-block\"><div class=\"left\">\n". $tasks ."\n</div></div></div>\n";
|
| 201 |
}
|
| 202 |
|
| 203 |
return $output;
|
| 204 |
}
|
| 205 |
|
| 206 |
/**
|
| 207 |
* Return a themed breadcrumb trail.
|
| 208 |
*
|
| 209 |
* @param $breadcrumb
|
| 210 |
* An array containing the breadcrumb links.
|
| 211 |
* @return a string containing the breadcrumb output.
|
| 212 |
*/
|
| 213 |
function phptemplate_breadcrumb($breadcrumb) {
|
| 214 |
if (!empty($breadcrumb)) {
|
| 215 |
return '<div class="breadcrumb">'. implode(' › ', $breadcrumb) .'</div>';
|
| 216 |
}
|
| 217 |
}
|
| 218 |
|
| 219 |
/**
|
| 220 |
* Format a query pager.
|
| 221 |
*
|
| 222 |
* Menu callbacks that display paged query results should call theme('pager') to retrieve a pager control so that users can view
|
| 223 |
* other results. Format a list of nearby pages with additional query results.
|
| 224 |
*
|
| 225 |
* Adds HTML hooks for making the pager appear in a horizontal bar
|
| 226 |
*/
|
| 227 |
function phptemplate_pager($tags = array(), $limit = 10, $element = 0, $parameters = array(), $quantity = 9) {
|
| 228 |
$output = theme_pager($tags, $limit, $element, $parameters, $quantity);
|
| 229 |
|
| 230 |
if (!empty($output)) {
|
| 231 |
$output = '<div class="content-bar"><div class="left">'.$output.'</div></div>';
|
| 232 |
}
|
| 233 |
return $output;
|
| 234 |
}
|
| 235 |
|
| 236 |
|
| 237 |
function phptemplate_comment_submitted($comment) {
|
| 238 |
return t('!username — !datetime',
|
| 239 |
array(
|
| 240 |
'!username' => theme('username', $comment),
|
| 241 |
'!datetime' => '<span class="date">'.format_date($comment->timestamp).'</span>'
|
| 242 |
));
|
| 243 |
}
|
| 244 |
|
| 245 |
function phptemplate_node_submitted($node) {
|
| 246 |
return t('!username — !datetime',
|
| 247 |
array(
|
| 248 |
'!username' => theme('username', $node),
|
| 249 |
'!datetime' => '<span class="date">'.format_date($node->created).'</span>'
|
| 250 |
));
|
| 251 |
}
|
| 252 |
?>
|