123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- <?php
- function mimemail_theme_theme() {
- $path = drupal_get_path('module', 'mimemail') . '/theme';
- return array(
- 'mimemail_message' => array(
- 'variables' => array('module' => NULL, 'key' => NULL, 'recipient' => NULL, 'subject' => NULL, 'body' => NULL),
- 'template' => 'mimemail-message',
- 'pattern' => 'mimemail_message__',
- 'file' => 'mimemail.theme.inc',
- 'mail theme' => TRUE,
- 'path' => $path,
- )
- );
- }
- function template_preprocess_mimemail_message(&$variables) {
- $theme = mailsystem_get_mail_theme();
- $themepath = drupal_get_path('theme', $theme);
- $sitestyle = variable_get('mimemail_sitestyle', 1);
- $mailstyles = file_scan_directory($themepath, '#^mail\.css*$#');
-
- if (!empty($mailstyles)) {
- foreach ($mailstyles as $mailstyle) {
- $styles = $mailstyle->uri;
- }
- }
-
-
- elseif ($sitestyle) {
-
- $local = $themepath . '/css/local.css';
- if (@file_exists($local)) {
- $css_all = drupal_add_css($local, array('group' => CSS_THEME));
- }
- else {
- $css_all = drupal_add_css();
- }
- $css_files = array();
- foreach ($css_all as $key => $options) {
- if ($options['group'] == CSS_THEME && $options['type'] == 'file' &&
- ($options['media'] == 'all' || $options['media'] == 'screen')) {
- $css_files[$key] = $options;
- }
- }
- if (variable_get('preprocess_css', FALSE)) {
- $pattern = '|<link.*href="' . $GLOBALS['base_url'] . '/([^"?]*)[?"].*|';
- $replacement = '\1';
- }
- else {
- $pattern = array(
- '/<([^<>]*)>/',
- '/@import\s+url\("([^"]+)"\);+/',
- '|' . $GLOBALS['base_url'] . '/([^"?]*)[?"].*|'
- );
- $replacement = array('', '\1', '\1');
- }
- $styles = preg_replace($pattern, $replacement, drupal_get_css($css_files));
- }
- $css = '';
- if (isset($styles)) {
-
- foreach (explode("\n", $styles) as $style) {
- if (!empty($style)) {
- $css .= drupal_load_stylesheet($style, TRUE);
- }
- }
-
- $css = wordwrap($css, 700);
- }
-
- $variables['css'] = $css;
-
- $variables['theme_hook_suggestions'][] = 'mimemail_message__' . str_replace('-', '_', $variables['key']);
-
- $variables['module'] = str_replace('_', '-', $variables['module']);
- $variables['key'] = str_replace('_', '-', $variables['key']);
- }
|