12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182 |
- <?php
- function mailsystem_theme_theme_registry_alter(&$theme_registry) {
- global $theme_key;
- static $recursion_prevention = FALSE;
-
- if ($recursion_prevention) {
- return;
- }
- $recursion_prevention = TRUE;
- $mailsystem_theme = mailsystem_get_mail_theme();
-
- if ($mailsystem_theme != $theme_key) {
- $themes = list_themes();
-
- if (isset($themes[$mailsystem_theme])) {
- $theme = clone $themes[$mailsystem_theme];
- if (isset($theme)) {
-
- $base_theme = array();
- if (isset($theme->base_themes)) {
- foreach (array_keys($theme->base_themes) as $base) {
- $base_theme[$base] = clone $themes[$base];
- }
- }
- if (isset($theme->base_theme) && !isset($base_theme[$theme->base_theme])) {
- $base_theme[$theme->base_theme] = clone $themes[$theme->base_theme];
- }
- if (isset($theme->engine)) {
- $theme_engine = $theme->engine;
- }
-
-
- include_once(drupal_get_path('theme', $theme->name) . '/template.php');
- foreach ($base_theme as $base) {
- include_once(drupal_get_path('theme', $base->name) . '/template.php');
- }
-
- $cache = _theme_load_registry($theme, $base_theme, $theme_engine);
-
- foreach ($theme_registry as $name => $hook) {
- if (!empty($hook['mail theme'])) {
- if (isset($cache[$name])) {
- $cache[$name]['includes'][] = drupal_get_path('theme', $theme->name) . '/template.php';
- foreach ($base_theme as $base) {
- $cache[$name]['includes'][] = drupal_get_path('theme', $base->name) . '/template.php';
- }
-
- $theme_registry[$name] = $cache[$name];
- }
-
- foreach ($cache as $cache_name => $cache_hook) {
- if (strpos($cache_name, $name . '__') !== FALSE) {
- $cache_hook['includes'][] = drupal_get_path('theme', $theme->name) . '/template.php';
- foreach ($base_theme as $base) {
- $cache_hook['includes'][] = drupal_get_path('theme', $base->name) . '/template.php';
- }
-
- $theme_registry[$cache_name] = $cache_hook;
- }
- }
- }
- }
- }
- }
- }
- $recursion_prevention = FALSE;
- }
|