1 |
d7f58da2
|
Florent Torregrosa
|
<?php
|
2 |
|
|
|
3 |
|
|
/**
|
4 |
|
|
* @file
|
5 |
|
|
* Provides frequently used functions that get theme info, settings and
|
6 |
|
|
* other data.
|
7 |
|
|
*/
|
8 |
|
|
|
9 |
|
|
/**
|
10 |
|
|
* Return the info file array for a particular theme, usually the active theme.
|
11 |
|
|
* Simple wrapper function for list_themes().
|
12 |
|
|
*
|
13 |
|
|
* @param $theme_name
|
14 |
|
|
*/
|
15 |
|
|
function mayo_get_info($theme_name) {
|
16 |
|
|
$info = drupal_static(__FUNCTION__, array());
|
17 |
|
|
if (empty($info)) {
|
18 |
|
|
$lt = list_themes();
|
19 |
|
|
foreach ($lt as $key => $value) {
|
20 |
|
|
if ($theme_name == $key) {
|
21 |
|
|
$info = $lt[$theme_name]->info;
|
22 |
|
|
}
|
23 |
|
|
}
|
24 |
|
|
}
|
25 |
|
|
|
26 |
|
|
return $info;
|
27 |
|
|
}
|
28 |
|
|
|
29 |
|
|
/**
|
30 |
|
|
* Returns an array keyed by theme name.
|
31 |
|
|
*
|
32 |
|
|
* Return all the info file data for a particular theme including base
|
33 |
|
|
* themes. Parts of this function are shamelessly ripped from Drupal core's
|
34 |
|
|
* _drupal_theme_initialize().
|
35 |
|
|
*
|
36 |
|
|
* @param $theme_name, usually the active theme.
|
37 |
|
|
*/
|
38 |
|
|
function mayo_get_info_trail($theme_name) {
|
39 |
|
|
$info_trail = drupal_static(__FUNCTION__, array());
|
40 |
|
|
if (empty($info_trail)) {
|
41 |
|
|
$lt = list_themes();
|
42 |
|
|
|
43 |
|
|
// First check for base themes and get info
|
44 |
|
|
$base_theme = array();
|
45 |
|
|
$ancestor = $theme_name;
|
46 |
|
|
while ($ancestor && isset($lt[$ancestor]->base_theme)) {
|
47 |
|
|
$ancestor = $lt[$ancestor]->base_theme;
|
48 |
|
|
$base_theme[] = $lt[$ancestor];
|
49 |
|
|
}
|
50 |
|
|
foreach ($base_theme as $base) {
|
51 |
|
|
$info_trail[$base->name]['info'] = $base->info;
|
52 |
|
|
}
|
53 |
|
|
|
54 |
|
|
// Now the active theme
|
55 |
|
|
$info_trail[$theme_name]['info'] = $lt[$theme_name]->info;
|
56 |
|
|
}
|
57 |
|
|
|
58 |
|
|
return $info_trail;
|
59 |
|
|
} |