| 1 |
<?php
|
| 2 |
|
| 3 |
function phptemplate_preprocess_page(&$vars) {
|
| 4 |
|
| 5 |
$themepath = path_to_theme();
|
| 6 |
$basepath = base_path();
|
| 7 |
|
| 8 |
// look for a navigation, content, search links etc
|
| 9 |
foreach ($vars as $key=>$value) {
|
| 10 |
if (is_string($value) && strpos($value, 'navigation-link')) {
|
| 11 |
$vars['navigation_link'] = true;
|
| 12 |
}
|
| 13 |
if (is_string($value) && strpos($value, 'search-link')) {
|
| 14 |
$vars['search_link'] = true;
|
| 15 |
}
|
| 16 |
}
|
| 17 |
|
| 18 |
// is there an accessibility guide?
|
| 19 |
$access_guide = theme_get_setting('accessibility_guide_url');
|
| 20 |
if ($access_guide && $access_guide != '') {
|
| 21 |
$access_guide = l(t('Accessibility guide'), $access_guide);
|
| 22 |
} else {
|
| 23 |
$access_guide = false;
|
| 24 |
}
|
| 25 |
$vars['access_guide'] = $access_guide;
|
| 26 |
|
| 27 |
// are there additional stylesheets
|
| 28 |
$css_sheets = theme_get_setting('css_sheets');
|
| 29 |
if ($css_sheets) {
|
| 30 |
$css_sheets = explode("\n", $css_sheets);
|
| 31 |
foreach ($css_sheets as $sheet) {
|
| 32 |
drupal_add_css($themepath.'/'.$sheet, 'theme');
|
| 33 |
}
|
| 34 |
$vars['styles'] = drupal_get_css();
|
| 35 |
}
|
| 36 |
|
| 37 |
// is the validator option on?
|
| 38 |
if (theme_get_setting('validators')) {
|
| 39 |
$vars['validators'] = true;
|
| 40 |
}
|
| 41 |
|
| 42 |
|
| 43 |
// build the accessibility modes block
|
| 44 |
$modes = theme_get_setting('accessibility_modes');
|
| 45 |
if ($modes) {
|
| 46 |
$modes = explode("\r\n", $modes);
|
| 47 |
foreach ($modes as $mode) {
|
| 48 |
if ($mode != '') {
|
| 49 |
$mode = explode(':', $mode);
|
| 50 |
$option = $mode[1];
|
| 51 |
$rule = $mode[2];
|
| 52 |
$mode = $mode[0];
|
| 53 |
$op = substr($rule, 0, 1);
|
| 54 |
switch ($op) {
|
| 55 |
case '+':
|
| 56 |
$rules[$mode][$option]['add'][] = substr($rule, 1);
|
| 57 |
break;
|
| 58 |
case '-':
|
| 59 |
$rules[$mode][$option]['remove'][] = substr($rule, 1);
|
| 60 |
break;
|
| 61 |
case '@':
|
| 62 |
$rules[$mode][$option]['image'] = substr($rule, 1);
|
| 63 |
break;
|
| 64 |
default:
|
| 65 |
$rules[$mode][$option]['description'] = $rule;
|
| 66 |
break;
|
| 67 |
}
|
| 68 |
}
|
| 69 |
}
|
| 70 |
// process the modes - building the output and handling any cookies
|
| 71 |
// local copy of the cookies
|
| 72 |
$cookie = $_COOKIE;
|
| 73 |
// array of css - for possible modification
|
| 74 |
$styles = drupal_add_css();
|
| 75 |
// index the styles for easy removal
|
| 76 |
foreach ($styles as $k0=>$v0) {
|
| 77 |
foreach ($v0 as $k1=>$v1) {
|
| 78 |
foreach ($v1 as $k2=>$v2) {
|
| 79 |
$styles1[$k2][0] = $k0;
|
| 80 |
$styles1[$k2][1] = $k1;
|
| 81 |
}
|
| 82 |
}
|
| 83 |
}
|
| 84 |
// start to output the mode settings block
|
| 85 |
$modes = '<em>'.t('Settings').':</em>';
|
| 86 |
$modes1 = '';
|
| 87 |
$here = request_uri();
|
| 88 |
if (strpos($here, '?q=') === false) {
|
| 89 |
$here = '?';
|
| 90 |
} else {
|
| 91 |
$here = '?q='.$_REQUEST['q'].'&';
|
| 92 |
}
|
| 93 |
foreach ($rules as $mode=>$options) {
|
| 94 |
// any changes to the cookies?
|
| 95 |
if (isset($_REQUEST['set_'.$mode])) {
|
| 96 |
$cookie[$mode] = $_REQUEST['set_'.$mode];
|
| 97 |
$modes1 .= 'Mode changed: '.$mode.'='.$cookie[$mode]."\r";
|
| 98 |
setcookie($mode, $cookie[$mode], time() + 86400*365, '/');
|
| 99 |
}
|
| 100 |
// output the mode options
|
| 101 |
$modes .= ' <div class="mode">'.t($mode).'';
|
| 102 |
foreach ($options as $option=>$optiondata) {
|
| 103 |
$modes .=' <div class="option"><a href="'.$here.'set_'.$mode.'='.$option.'&rand='.rand().'"><img src="'.$basepath.$themepath.'/'.$optiondata['image'].'" alt="'.$optiondata['description'].'" title="'.$optiondata['description'].'" /></a></div>';
|
| 104 |
}
|
| 105 |
|
| 106 |
// if the cookie is set for this mode, process the rules
|
| 107 |
if (isset($cookie[$mode]) && $cookie[$mode] != '') {
|
| 108 |
$option = $cookie[$mode];
|
| 109 |
$modes1 .= 'Mode: '.$mode.'='.$option."\r";
|
| 110 |
// add any stylesheets
|
| 111 |
if (isset($rules[$mode][$option]['add'])) {
|
| 112 |
foreach ($rules[$mode][$option]['add'] as $sheet) {
|
| 113 |
$styles['all']['theme'][$themepath.'/'.$sheet] = 1;
|
| 114 |
$modes1 .= 'added: '.$mode.'='.$option.' '.$sheet."\r";
|
| 115 |
}
|
| 116 |
}
|
| 117 |
// remove any stylesheets
|
| 118 |
if (isset($rules[$mode][$option]['remove'])) {
|
| 119 |
foreach ($rules[$mode][$option]['remove'] as $sheet) {
|
| 120 |
$k0 = $styles1[$sheet][0];
|
| 121 |
$k1 = $styles1[$sheet][1];
|
| 122 |
unset($styles['all']['theme'][$sheet]);
|
| 123 |
$modes1 .= 'removed: '.$mode.'='.$option.' '.$sheet."\r";
|
| 124 |
}
|
| 125 |
}
|
| 126 |
}
|
| 127 |
$modes .= '</div>';
|
| 128 |
}
|
| 129 |
// update the page output for the mode block and the changed styles
|
| 130 |
$vars['modes'] = $modes."<!-- \r".$modes1.' -->';
|
| 131 |
$vars['styles'] = drupal_get_css($styles);
|
| 132 |
$vars['modelocation'] = theme_get_setting('accessibility_modelocation');
|
| 133 |
|
| 134 |
}
|
| 135 |
}
|
| 136 |
|
| 137 |
function phptemplate_preprocess_block(&$vars) {
|
| 138 |
|
| 139 |
}
|
| 140 |
|
| 141 |
function phptemplate_preprocess_node(&$vars) {
|
| 142 |
}
|