You are here

function htmlmail_theme in HTML Mail 6.2

Same name and namespace in other branches
  1. 8.3 htmlmail.module \htmlmail_theme()
  2. 8 htmlmail.module \htmlmail_theme()
  3. 8.2 htmlmail.module \htmlmail_theme()
  4. 6 htmlmail.module \htmlmail_theme()
  5. 7.2 htmlmail.module \htmlmail_theme()
  6. 7 htmlmail.module \htmlmail_theme()

Implements hook_theme().

Auto-detects htmlmail template files in the selected theme and in the htmlmail module directory.

2 string references to 'htmlmail_theme'
htmlmail_admin_settings in ./htmlmail.admin.inc
Implements hook_admin_settings().
htmlmail_get_selected_theme in ./htmlmail.module
Returns the selected theme to use for outgoing emails.

File

./htmlmail.module, line 68
Sends system emails in HTML.

Code

function htmlmail_theme() {
  $items = array();
  $module_path = drupal_get_path('module', 'htmlmail');
  $pattern = '^htmlmail.*\\.tpl\\.php$';
  $files = file_scan_directory($module_path, $pattern, array(
    'key' => 'name',
  ));
  if ($theme = htmlmail_get_selected_theme()) {
    $theme_path = drupal_get_path('theme', $theme);
    $files = array_merge($files, file_scan_directory($theme_path, $pattern, array(
      'key' => 'name',
    )));
  }
  else {
    $theme_path = $module_path;
  }
  ksort($files);
  foreach ($files as $file) {
    $path = dirname($file->filename);
    $template = substr($file->name, 0, -4);
    $suggestion = str_replace('-', '_', $template);
    $items[$suggestion] = array(
      'arguments' => array(
        'message' => array(),
      ),
      'template' => $template,
      'path' => $path,
      'theme paths' => array(
        $theme_path,
      ),
    );
  }
  return $items;
}