| 1 |
<?php
|
| 2 |
|
| 3 |
/**
|
| 4 |
* [EN] Force refresh of theme registry.
|
| 5 |
* DEVELOPMENT USE ONLY - COMMENT OUT FOR PRODUCTION
|
| 6 |
*/
|
| 7 |
// drupal_rebuild_theme_registry();
|
| 8 |
|
| 9 |
|
| 10 |
defined('NX_C_LINK_NAME') or define('NX_C_LINK_NAME', 'c_link');
|
| 11 |
defined('NX_C_ITEM_NAME') or define('NX_C_ITEM_NAME', 'c_item');
|
| 12 |
|
| 13 |
|
| 14 |
global $full_system_path;
|
| 15 |
$full_system_path = check_url(url('', array('absolute' => TRUE, 'language' => language_default())));
|
| 16 |
// -------------------------------------------------------------------------------
|
| 17 |
global $full_theme_path;
|
| 18 |
$full_theme_path = check_url(url(path_to_theme().'/', array('absolute' => TRUE, 'language' => language_default())));
|
| 19 |
$full_theme_path = str_replace('?q=', '', $full_theme_path); // [EN] if not clear_url mode
|
| 20 |
// -------------------------------------------------------------------------------
|
| 21 |
global $nx_theme_registration_pool;
|
| 22 |
$nx_theme_registration_pool = array();
|
| 23 |
|
| 24 |
|
| 25 |
require_once 'forms/search-block-form-functions.inc.php';
|
| 26 |
require_once 'forms/user-login-block-functions.tpl.php';
|
| 27 |
|
| 28 |
|
| 29 |
function activesite_theme() {
|
| 30 |
global $nx_theme_registration_pool;
|
| 31 |
// ----------
|
| 32 |
$nx_theme_registration_pool['nx-fieldset-template'] = array(
|
| 33 |
'template' => 'nx-fieldset',
|
| 34 |
'arguments' => array(
|
| 35 |
'attributes' => '',
|
| 36 |
'title' => 'title',
|
| 37 |
'description' => 'description',
|
| 38 |
'children' => 'children',
|
| 39 |
'value' => 'value')
|
| 40 |
);
|
| 41 |
// ----------
|
| 42 |
return $nx_theme_registration_pool;
|
| 43 |
}
|
| 44 |
|
| 45 |
|
| 46 |
/**
|
| 47 |
* ------------------------
|
| 48 |
* [EN] Override or insert PHPTemplate variables into the templates
|
| 49 |
* ------------------------
|
| 50 |
*/
|
| 51 |
|
| 52 |
|
| 53 |
function phptemplate_preprocess(&$vars) {
|
| 54 |
global $full_system_path;
|
| 55 |
global $full_theme_path;
|
| 56 |
$vars['full_system_path'] = $full_system_path;
|
| 57 |
$vars['full_theme_path'] = $full_theme_path;
|
| 58 |
}
|
| 59 |
|
| 60 |
|
| 61 |
function phptemplate_preprocess_page(&$vars) {
|
| 62 |
$tabs_pri = nx_prepare_tabs_c_items(menu_primary_local_tasks());
|
| 63 |
$tabs_sec = nx_prepare_tabs_c_items(menu_secondary_local_tasks());
|
| 64 |
$vars['tabs_pri'] = $tabs_pri ? '<div class="tabs tabs_pri"><div class="c_clear"> </div><ul>' . $tabs_pri . '</ul><div class="c_clear"> </div></div>' . "\n" : '';
|
| 65 |
$vars['tabs_sec'] = $tabs_sec ? '<div class="tabs tabs_sec"><div class="c_clear"> </div><ul>' . $tabs_sec . '</ul><div class="c_clear"> </div></div>' . "\n" : '';
|
| 66 |
|
| 67 |
$nx_body_classes = array();
|
| 68 |
$nx_body_classes[] = $vars['is_admin'] ? 'user-admin' : 'user-not_admin';
|
| 69 |
$nx_body_classes[] = $vars['logged_in'] ? 'logged_in-yes' : 'logged_in-no';
|
| 70 |
$nx_body_classes[] = $vars['is_front'] ? 'page-front' : 'page-not_front';
|
| 71 |
$nx_body_classes[] = 'layout-' . $vars['layout'];
|
| 72 |
$nx_body_classes[] = nx_get_destination2();
|
| 73 |
$nx_body_classes[] = 'universal_' . nx_get_destination2(TRUE);
|
| 74 |
$vars['nx_body_classes'] = implode(' ', $nx_body_classes);
|
| 75 |
}
|
| 76 |
|
| 77 |
|
| 78 |
function nx_prepare_tabs_c_items($c_item_html){
|
| 79 |
$c_item = split('<li ', $c_item_html);
|
| 80 |
for($i = 1; $i < count($c_item); $i++){
|
| 81 |
if($i == 1) {$c_item[$i] = str_replace(NX_C_ITEM_NAME, NX_C_ITEM_NAME . ' first', $c_item[$i]);}
|
| 82 |
if($i == count($c_item)-1) {$c_item[$i] = str_replace(NX_C_ITEM_NAME, NX_C_ITEM_NAME . ' last', $c_item[$i]);}
|
| 83 |
}
|
| 84 |
return join('<li ', $c_item);
|
| 85 |
}
|
| 86 |
|
| 87 |
|
| 88 |
function nx_get_destination2($with_mask = FALSE){
|
| 89 |
$destination = strip_tags((string)$_GET['q']);
|
| 90 |
$args = explode('/', $destination);
|
| 91 |
foreach ($args as &$arg) {
|
| 92 |
$arg = str_replace(array('-',' '), '_', $arg);
|
| 93 |
if ($with_mask && is_numeric($arg)) {$arg = 'n';}
|
| 94 |
}
|
| 95 |
return 'destination-'. implode('-', $args);
|
| 96 |
}
|
| 97 |
|
| 98 |
|
| 99 |
/**
|
| 100 |
* ------------------------
|
| 101 |
* [EN] Generate the HTML output for a single local task link
|
| 102 |
* ------------------------
|
| 103 |
*/
|
| 104 |
|
| 105 |
|
| 106 |
function phptemplate_menu_local_task($link, $active = FALSE) {
|
| 107 |
return '<li class="'. NX_C_ITEM_NAME . ($active ? ' active' : '') .'">'. $link ."</li>\n";
|
| 108 |
}
|
| 109 |
|
| 110 |
|
| 111 |
/**
|
| 112 |
* ------------------------
|
| 113 |
* [EN] Return a themed set of links
|
| 114 |
* ------------------------
|
| 115 |
*/
|
| 116 |
|
| 117 |
|
| 118 |
function phptemplate_links($links, $attributes = array('class' => 'links'), $cover = array(
|
| 119 |
'outer_prefix' => '',
|
| 120 |
'inner_prefix' => '',
|
| 121 |
'inner_suffix' => '',
|
| 122 |
'outer_suffix' => '<span class="c_bounder"> </span>')) {
|
| 123 |
global $language;
|
| 124 |
$output = '';
|
| 125 |
if (count($links) > 0) {
|
| 126 |
$output = '<ul'. drupal_attributes($attributes) .'>';
|
| 127 |
$num_links = count($links);
|
| 128 |
$i = 1;
|
| 129 |
foreach ($links as $key => $link) {
|
| 130 |
$class = $key;
|
| 131 |
// [EN] Add first, last and active classes to the list of links to help out themers.
|
| 132 |
if ($i == 1) {$class .= ' first';}
|
| 133 |
if ($i == $num_links) {$class .= ' last';}
|
| 134 |
if (isset($link['href']) && ($link['href'] == $_GET['q'] || ($link['href'] == '<front>' && drupal_is_front_page())) && (empty($link['language']) || $link['language']->language == $language->language)) {$class .= ' active';}
|
| 135 |
$output .= '<li'. drupal_attributes(array('class' => $class)) .'>';
|
| 136 |
if (isset($link['href'])) {
|
| 137 |
// [EN] Pass in $link as $options, they share the same keys.
|
| 138 |
// -------------------------------------------------------
|
| 139 |
$link['title'] = $cover['inner_prefix'] . ($link['html'] ? $link['title'] : check_plain($link['title'])) . $cover['inner_suffix'];
|
| 140 |
$link['html'] = TRUE;
|
| 141 |
$output .= $cover['outer_prefix'];
|
| 142 |
$output .= l($link['title'], $link['href'], $link);
|
| 143 |
$output .= $cover['outer_suffix'];
|
| 144 |
// -------------------------------------------------------
|
| 145 |
}
|
| 146 |
else if (!empty($link['title'])) {
|
| 147 |
// [EN] Some links are actually not links, but we wrap these in <span> for adding title and class attributes
|
| 148 |
if (empty($link['html'])) {$link['title'] = check_plain($link['title']);}
|
| 149 |
$span_attributes = '';
|
| 150 |
if (isset($link['attributes'])) {$span_attributes = drupal_attributes($link['attributes']);}
|
| 151 |
// -------------------------------------------------------
|
| 152 |
$output .= $cover['outer_prefix'].'<span'. $span_attributes .'>'.$cover['inner_prefix'].$link['title'].$cover['inner_suffix'].'</span>'.$cover['outer_suffix'];
|
| 153 |
// -------------------------------------------------------
|
| 154 |
}
|
| 155 |
$i++;
|
| 156 |
$output .= "</li>\n";}
|
| 157 |
$output .= '</ul>';}
|
| 158 |
return $output;
|
| 159 |
}
|
| 160 |
|
| 161 |
|
| 162 |
/**
|
| 163 |
* ------------------------
|
| 164 |
* [EN] Return a themed set of status and/or error messages. The messages are grouped by type
|
| 165 |
* ------------------------
|
| 166 |
*/
|
| 167 |
|
| 168 |
|
| 169 |
function phptemplate_status_messages($display = NULL) {
|
| 170 |
$output = '';
|
| 171 |
foreach (drupal_get_messages($display) as $type => $messages) {
|
| 172 |
$output .= "<div class=\"messages message-$type\">\n";
|
| 173 |
if (count($messages) > 1) {
|
| 174 |
$output .= " <ul>\n";
|
| 175 |
foreach ($messages as $message) {
|
| 176 |
$output .= ' <li>'. $message ."</li>\n";}
|
| 177 |
$output .= " </ul>\n";}
|
| 178 |
else {
|
| 179 |
$output .= $messages[0];}
|
| 180 |
$output .= "</div>\n";}
|
| 181 |
return $output;
|
| 182 |
}
|
| 183 |
|
| 184 |
|
| 185 |
/**
|
| 186 |
* ------------------------
|
| 187 |
* [EN] Return a themed help message
|
| 188 |
* ------------------------
|
| 189 |
*/
|
| 190 |
|
| 191 |
|
| 192 |
function phptemplate_help() {
|
| 193 |
if ($help = menu_get_active_help()) {
|
| 194 |
if (strlen($help) > 10) {return '<div class="help">'. $help .'</div>';}
|
| 195 |
}
|
| 196 |
}
|
| 197 |
|
| 198 |
|
| 199 |
/**
|
| 200 |
* ------------------------
|
| 201 |
* [EN] Return a themed breadcrumb trail
|
| 202 |
* ------------------------
|
| 203 |
*/
|
| 204 |
|
| 205 |
|
| 206 |
function phptemplate_breadcrumb($breadcrumb) {
|
| 207 |
if (!empty($breadcrumb)) {
|
| 208 |
$last_item = &$breadcrumb[count($breadcrumb)-1];
|
| 209 |
$last_item = str_replace('<a ', '<a class="last" ', $last_item);
|
| 210 |
return '<div class="breadcrumb">' . implode('<span class="gt">></span>', $breadcrumb) . '</div>';
|
| 211 |
}
|
| 212 |
}
|
| 213 |
|
| 214 |
|
| 215 |
/**
|
| 216 |
* ------------------------
|
| 217 |
* [EN] Format a group of form items
|
| 218 |
* ------------------------
|
| 219 |
*/
|
| 220 |
|
| 221 |
|
| 222 |
function phptemplate_fieldset($element) {
|
| 223 |
if (!empty($element['#collapsible'])) {
|
| 224 |
if (!isset($element['#attributes']['class'])) {
|
| 225 |
$element['#attributes']['class'] = '';
|
| 226 |
}
|
| 227 |
$element['#attributes']['class'] .= ' collapsible';
|
| 228 |
if (!empty($element['#collapsed'])) {
|
| 229 |
$element['#attributes']['class'] .= ' collapsed';
|
| 230 |
}
|
| 231 |
}
|
| 232 |
return theme('nx-fieldset-template',
|
| 233 |
drupal_attributes($element['#attributes']),
|
| 234 |
($element['#title'] ? $element['#title'] : ''),
|
| 235 |
(isset($element['#description']) && $element['#description'] ? $element['#description'] : ''),
|
| 236 |
(!empty($element['#children']) ? $element['#children'] : ''),
|
| 237 |
(isset($element['#value']) ? $element['#value'] : ''));
|
| 238 |
}
|
| 239 |
|
| 240 |
|
| 241 |
/**
|
| 242 |
* ------------------------
|
| 243 |
* [EN] Allow themable wrapping of all comments
|
| 244 |
* ------------------------
|
| 245 |
*/
|
| 246 |
|
| 247 |
|
| 248 |
function phptemplate_comment_wrapper($content, $node) {
|
| 249 |
if (strlen($content) == 0) {return;}
|
| 250 |
if ($node->type == 'forum') {return '<div id="comments" class="c_all_comments">'. $content .'</div>';}
|
| 251 |
else {return '<div id="comments" class="c_all_comments"><h2 class="c_all_comments_title">'. t('Comments') .'</h2>'. $content .'</div>';}
|
| 252 |
}
|
| 253 |
|
| 254 |
|
| 255 |
/**
|
| 256 |
* ------------------------
|
| 257 |
* [EN] Return a set of blocks available for the current user
|
| 258 |
* ------------------------
|
| 259 |
*/
|
| 260 |
|
| 261 |
global $nx_left_column_title;
|
| 262 |
|
| 263 |
|
| 264 |
function phptemplate_blocks($region) {
|
| 265 |
$output = '';
|
| 266 |
if ($list = block_list($region)) {
|
| 267 |
$blocks_num = count($list);
|
| 268 |
$i = 1;
|
| 269 |
foreach ($list as $key => $block) {
|
| 270 |
// -----------------------
|
| 271 |
if ($block->module == 'user' && $block->delta == 1) {$block->subject = t('navigation');}
|
| 272 |
if ($region == 'left' && $i == 1) {
|
| 273 |
global $nx_left_column_title;
|
| 274 |
$nx_left_column_title = $block->subject;
|
| 275 |
$block->subject = '';}
|
| 276 |
// -----------------------
|
| 277 |
if ($blocks_num == 1) {$block->nx_block_extra_class = 'single';}
|
| 278 |
else {
|
| 279 |
if ($i == 1) {$block->nx_block_extra_class = 'first';}
|
| 280 |
if ($i == $blocks_num) {$block->nx_block_extra_class = 'last';}}
|
| 281 |
$block->nx_block_num = $i++;
|
| 282 |
$output .= theme('block', $block);
|
| 283 |
}
|
| 284 |
}
|
| 285 |
// [EN] Add any content assigned to this region through drupal_set_content() calls.
|
| 286 |
$output .= drupal_get_content($region);
|
| 287 |
return $output;
|
| 288 |
}
|
| 289 |
|
| 290 |
|
| 291 |
/**
|
| 292 |
* ------------------------
|
| 293 |
* [EN] Return a themed table
|
| 294 |
* ------------------------
|
| 295 |
*/
|
| 296 |
|
| 297 |
|
| 298 |
function nx_set_column_number(&$cell, $num){
|
| 299 |
if (!is_array($cell)) {$cell = array('class' => '','data' => $cell);}
|
| 300 |
if (!isset($cell['class'])) {$cell['class'] = '';}
|
| 301 |
$cell['class'].= ' tc-'.$num;
|
| 302 |
}
|
| 303 |
|
| 304 |
|
| 305 |
function phptemplate_table($header, $rows, $attributes = array(), $caption = NULL) {
|
| 306 |
|
| 307 |
// [EN] Add sticky headers, if applicable.
|
| 308 |
if (count($header)) {
|
| 309 |
drupal_add_js('misc/tableheader.js');
|
| 310 |
// [EN] Add 'sticky-enabled' class to the table to identify it for JS. This is needed to target tables constructed by this function.
|
| 311 |
$attributes['class'] = empty($attributes['class']) ? 'sticky-enabled' : ($attributes['class'] .' sticky-enabled');
|
| 312 |
// -----------------------------------------------
|
| 313 |
$attributes['class'].= ' table';
|
| 314 |
// -----------------------------------------------
|
| 315 |
}
|
| 316 |
$output = '<table'. drupal_attributes($attributes) .">\n";
|
| 317 |
if (isset($caption)) {
|
| 318 |
$output .= '<caption>'. $caption ."</caption>\n";
|
| 319 |
}
|
| 320 |
|
| 321 |
// [EN] Format the table header:
|
| 322 |
if (count($header)) {
|
| 323 |
$ts = tablesort_init($header);
|
| 324 |
$output .= (count($rows) ? ' <thead><tr>' : ' <tr>');
|
| 325 |
$i = 0;
|
| 326 |
foreach ($header as $cell) {
|
| 327 |
$cell = tablesort_header($cell, $header, $ts);
|
| 328 |
// -----------------------------------------------
|
| 329 |
nx_set_column_number(&$cell, ++$i);
|
| 330 |
// -----------------------------------------------
|
| 331 |
$output .= _theme_table_cell($cell, TRUE);}
|
| 332 |
$output .= (count($rows) ? " </tr></thead>\n" : "</tr>\n");
|
| 333 |
}
|
| 334 |
else {$ts = array();}
|
| 335 |
|
| 336 |
// [EN] Format the table rows:
|
| 337 |
if (count($rows)) {
|
| 338 |
$output .= "<tbody>\n";
|
| 339 |
$flip = array('even' => 'odd', 'odd' => 'even');
|
| 340 |
$class = 'even';
|
| 341 |
foreach ($rows as $number => $row) {
|
| 342 |
$attributes = array();
|
| 343 |
// [EN] Check if we're dealing with a simple or complex row
|
| 344 |
if (isset($row['data'])) {
|
| 345 |
foreach ($row as $key => $value) {
|
| 346 |
if ($key == 'data') {$cells = $value;}
|
| 347 |
else {$attributes[$key] = $value;}}}
|
| 348 |
else {$cells = $row;}
|
| 349 |
|
| 350 |
if (count($cells)) {
|
| 351 |
// [EN] Add odd/even class
|
| 352 |
$class = $flip[$class];
|
| 353 |
if (isset($attributes['class'])) {$attributes['class'] .= ' '. $class;}
|
| 354 |
else {$attributes['class'] = $class;}
|
| 355 |
|
| 356 |
// [EN] Build row
|
| 357 |
$output .= ' <tr'. drupal_attributes($attributes) .'>';
|
| 358 |
$i = 0;
|
| 359 |
foreach ($cells as $cell) {
|
| 360 |
$cell = tablesort_cell($cell, $header, $ts, $i++);
|
| 361 |
// -----------------------------------------------
|
| 362 |
nx_set_column_number(&$cell,$i);
|
| 363 |
// -----------------------------------------------
|
| 364 |
$output .= _theme_table_cell($cell);}
|
| 365 |
$output .= " </tr>\n";}}
|
| 366 |
$output .= "</tbody>\n";
|
| 367 |
}
|
| 368 |
$output .= "</table>\n";
|
| 369 |
return '<div class="table_cover">'.$output.'</div>';
|
| 370 |
}
|
| 371 |
|
| 372 |
|
| 373 |
/**
|
| 374 |
* ------------------------
|
| 375 |
* [EN] Generate the HTML output for a menu
|
| 376 |
* theme_menu_tree - [EN] Generate the HTML output for a menu tree
|
| 377 |
* theme_menu_item - [EN] Generate the HTML output for a menu item and submenu
|
| 378 |
* theme_menu_item_link - [EN] Generate the HTML output for a single menu link
|
| 379 |
* ------------------------
|
| 380 |
*/
|
| 381 |
|
| 382 |
|
| 383 |
global $NX_MENU_ITEMS_POOL;
|
| 384 |
global $NX_MENU_C_ITEM;
|
| 385 |
$NX_MENU_ITEMS_POOL = array();
|
| 386 |
$NX_MENU_C_ITEM = NULL;
|
| 387 |
|
| 388 |
|
| 389 |
function phptemplate_menu_tree($tree) {
|
| 390 |
$class = 'c_menu';
|
| 391 |
global $NX_MENU_C_ITEM;
|
| 392 |
if(isset($NX_MENU_C_ITEM['depth']) && $NX_MENU_C_ITEM['depth'] == 1){
|
| 393 |
$class.= ($NX_MENU_C_ITEM['menu_name'] ? ' menu-' . $NX_MENU_C_ITEM['menu_name'] : '');
|
| 394 |
}
|
| 395 |
return '<ul class="' . $class . '">'. $tree .'</ul>';
|
| 396 |
}
|
| 397 |
|
| 398 |
|
| 399 |
function phptemplate_menu_item($link, $has_children, $menu = '', $in_active_trail = FALSE, $extra_class = NULL) {
|
| 400 |
$is_collapsed = ($menu ? 'expanded' : ($has_children ? 'collapsed' : 'leaf'));
|
| 401 |
$class = NX_C_ITEM_NAME . ' ' . $is_collapsed;
|
| 402 |
if (!empty($extra_class)) {$class .= ' '. $extra_class;} // [EN] .first and .last in extra_class
|
| 403 |
if ($in_active_trail) {$class .= ' active-trail';}
|
| 404 |
// -------------------------------------------------------------
|
| 405 |
global $NX_MENU_ITEMS_POOL;
|
| 406 |
$last_item = array_pop(&$NX_MENU_ITEMS_POOL);
|
| 407 |
$class .= ($last_item['depth'] ? ' depth_' . $last_item['depth'] : '');
|
| 408 |
$class .= ($last_item['depth'] ? ' ' . $is_collapsed . '-depth_' . $last_item['depth'] : '');
|
| 409 |
// -------------------------------------------------------------
|
| 410 |
return '<li class="'. $class .'">'. $link . $menu ."</li>\n";
|
| 411 |
}
|
| 412 |
|
| 413 |
|
| 414 |
function phptemplate_menu_item_link($link, $cover = array(
|
| 415 |
'outer_prefix' => '',
|
| 416 |
'inner_prefix' => '<span><span>',
|
| 417 |
'inner_suffix' => '</span></span>',
|
| 418 |
'outer_suffix' => '<span class="c_bounder"> </span>')) {
|
| 419 |
if (empty($link['localized_options'])) {$link['localized_options'] = array();}
|
| 420 |
// -------------------------------------------------------------
|
| 421 |
$options = $link['localized_options'];
|
| 422 |
$options['attributes']['class'] = NX_C_LINK_NAME . ' ' . ($link['depth'] ? 'depth_' . $link['depth'] : '');
|
| 423 |
// -----
|
| 424 |
$link['title'] = $cover['inner_prefix'] . ($options['html'] ? $link['title'] : check_plain($link['title'])) . $cover['inner_suffix'];
|
| 425 |
$options['html'] = TRUE;
|
| 426 |
// -----
|
| 427 |
global $NX_MENU_ITEMS_POOL, $NX_MENU_C_ITEM;
|
| 428 |
array_push($NX_MENU_ITEMS_POOL, $link);
|
| 429 |
$NX_MENU_C_ITEM = $link;
|
| 430 |
return $cover['outer_prefix'] . l($link['title'], $link['href'], $options) . $cover['outer_suffix'];
|
| 431 |
}
|
| 432 |
|