| 1 |
<?php
|
| 2 |
|
| 3 |
/* Generates path to style; similar to path_to_theme() */
|
| 4 |
function admin_path_to_style() {
|
| 5 |
global $theme_key;
|
| 6 |
$themes = list_themes();
|
| 7 |
return dirname($themes[$theme_key]->filename);
|
| 8 |
}
|
| 9 |
|
| 10 |
/* generates a list of body classes for bad-ass per-page CSS hacking */
|
| 11 |
function phptemplate_body_class($sidebar_left, $sidebar_right) {
|
| 12 |
// Hack to add .admin as theme works if .admin is present.
|
| 13 |
$body_classes = array('admin');
|
| 14 |
|
| 15 |
if (strlen($sidebar_left) && strlen($sidebar_right)) {
|
| 16 |
$body_classes[] = 'three-column';
|
| 17 |
}
|
| 18 |
else if (strlen($sidebar_left)) {
|
| 19 |
$body_classes[] = 'two-column';
|
| 20 |
}
|
| 21 |
else if (strlen($sidebar_right)) {
|
| 22 |
$body_classes[] = 'two-column-right';
|
| 23 |
}
|
| 24 |
else {
|
| 25 |
$body_classes[] = 'one-column';
|
| 26 |
}
|
| 27 |
|
| 28 |
if ($_GET['q'] == variable_get('site_frontpage', 'node')) {
|
| 29 |
$body_classes[] = 'home';
|
| 30 |
}
|
| 31 |
|
| 32 |
if (arg(1)) {
|
| 33 |
$body_classes[] = check_plain(arg(0)) . '-' . check_plain(arg(1));
|
| 34 |
}
|
| 35 |
if ($node->type) {
|
| 36 |
$body_classes[] = $node->type;
|
| 37 |
}
|
| 38 |
$path_class = explode('/', drupal_get_path_alias(check_plain($_GET['q'])));
|
| 39 |
$body_classes[] = reset($path_class);
|
| 40 |
$body_classes[] = preg_replace('/-\d+/', '', str_replace('/', '-', check_plain($_GET['q'])));
|
| 41 |
$body_classes[] = 'page-' . str_replace('/', '-', check_plain($_GET['q']));
|
| 42 |
|
| 43 |
return ' class="'. join(' ', array_unique($body_classes)) .'"';
|
| 44 |
}
|
| 45 |
|
| 46 |
function phptemplate_stylesheet_import($stylesheet, $media = 'screen') {
|
| 47 |
if ($stylesheet == 'misc/print.css') {
|
| 48 |
// Return custom print stylesheet
|
| 49 |
return drupal_add_css(path_to_theme() .'/admin/print.css', 'theme', $media);
|
| 50 |
}
|
| 51 |
else { //if ($stylesheet != 'misc/drupal.css') {
|
| 52 |
// Gut drupal.css. Good riddance!
|
| 53 |
return drupal_add_css($stylesheet, 'theme', $media);
|
| 54 |
}
|
| 55 |
}
|
| 56 |
|
| 57 |
/*
|
| 58 |
we need a much more robust hyphenation algorithm
|
| 59 |
(i.e. to cut URLs off at the slashes)!
|
| 60 |
*/
|
| 61 |
function _admin_word_split($text, $max_char = 30) {
|
| 62 |
return preg_replace('/((?:[^ &]|&[^;]+;){' . $max_char . '})(?=[^ ])/u', '\1<wbr />', $text[0]);
|
| 63 |
}
|
| 64 |
|
| 65 |
function admin_word_split($text) {
|
| 66 |
return substr(preg_replace_callback('/>[^<]+</', '_admin_word_split', '>'. $text .'<'), 1, -1);
|
| 67 |
}
|