htmlmail.tpl.php 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178
  1. <?php
  2. /**
  3. * @file
  4. * Default template for HTML Mail
  5. *
  6. * DO NOT EDIT THIS FILE. Copy it to your theme directory, and edit the copy.
  7. *
  8. * ========================================================= Begin instructions.
  9. *
  10. * When formatting an email message with a given $module and $key, [1]HTML
  11. * Mail will use the first template file it finds from the following list:
  12. * 1. htmlmail--$module--$key.tpl.php
  13. * 2. htmlmail--$module.tpl.php
  14. * 3. htmlmail.tpl.php
  15. *
  16. * For each filename, [2]HTML Mail looks first in the chosen Email theme
  17. * directory, then in its own module directory, before proceeding to the
  18. * next filename.
  19. *
  20. * For example, if example_module sends mail with:
  21. * drupal_mail("example_module", "outgoing_message" ...)
  22. *
  23. *
  24. * the possible template file names would be:
  25. * 1. htmlmail--example_module--outgoing_message.tpl.php
  26. * 2. htmlmail--example_module.tpl.php
  27. * 3. htmlmail.tpl.php
  28. *
  29. * Template files are cached, so remember to clear the cache by visiting
  30. * admin/config/development/performance after changing any .tpl.php files.
  31. *
  32. * The following variables available in this template:
  33. *
  34. * $body
  35. * The message body text.
  36. *
  37. * $module
  38. * The first argument to [3]drupal_mail(), which is, by convention,
  39. * the machine-readable name of the sending module.
  40. *
  41. * $key
  42. * The second argument to [4]drupal_mail(), which should give some
  43. * indication of why this email is being sent.
  44. *
  45. * $message_id
  46. * The email message id, which should be equal to
  47. * "{$module}_{$key}".
  48. *
  49. * $headers
  50. * An array of email (name => value) pairs.
  51. *
  52. * $from
  53. * The configured sender address.
  54. *
  55. * $to
  56. * The recipient email address.
  57. *
  58. * $subject
  59. * The message subject line.
  60. *
  61. * $body
  62. * The formatted message body.
  63. *
  64. * $language
  65. * The language object for this message.
  66. *
  67. * $params
  68. * Any module-specific parameters.
  69. *
  70. * $template_name
  71. * The basename of the active template.
  72. *
  73. * $template_path
  74. * The relative path to the template directory.
  75. *
  76. * $template_url
  77. * The absolute URL to the template directory.
  78. *
  79. * $theme
  80. * The name of the Email theme used to hold template files. If the
  81. * [5]Echo module is enabled this theme will also be used to
  82. * transform the message body into a fully-themed webpage.
  83. *
  84. * $theme_path
  85. * The relative path to the selected Email theme directory.
  86. *
  87. * $theme_url
  88. * The absolute URL to the selected Email theme directory.
  89. *
  90. * $debug
  91. * TRUE to add some useful debugging info to the bottom of the
  92. * message.
  93. *
  94. * Other modules may also add or modify theme variables by implementing a
  95. * MODULENAME_preprocess_htmlmail(&$variables) [6]hook function.
  96. *
  97. * References
  98. *
  99. * 1. http://drupal.org/project/htmlmail
  100. * 2. http://drupal.org/project/htmlmail
  101. * 3. http://api.drupal.org/api/drupal/includes--mail.inc/function/drupal_mail/7
  102. * 4. http://api.drupal.org/api/drupal/includes--mail.inc/function/drupal_mail/7
  103. * 5. http://drupal.org/project/echo
  104. * 6. http://api.drupal.org/api/drupal/modules--system--theme.api.php/function/hook_preprocess_HOOK/7
  105. *
  106. * =========================================================== End instructions.
  107. */
  108. $template_name = basename(__FILE__);
  109. $current_path = realpath(NULL);
  110. $current_len = strlen($current_path);
  111. $template_path = realpath(dirname(__FILE__));
  112. if (!strncmp($template_path, $current_path, $current_len)) {
  113. $template_path = substr($template_path, $current_len + 1);
  114. }
  115. $template_url = url($template_path, array('absolute' => TRUE));
  116. ?>
  117. <div class="htmlmail-body">
  118. <?php echo $body; ?>
  119. </div>
  120. <?php if ($debug):
  121. $module_template = "htmlmail--$module.tpl.php";
  122. $message_template = "htmlmail--$module--$key.tpl.php";
  123. ?>
  124. <hr />
  125. <div class="htmlmail-debug">
  126. <dl><dt><p>
  127. To customize this message:
  128. </p></dt><dd><ol><li><p><?php if (empty($theme)): ?>
  129. Visit <u>admin/config/system/htmlmail</u>
  130. and select a theme to hold your custom email template files.
  131. </p></li><li><p><?php elseif (empty($theme_path)): ?>
  132. Visit <u>admin/appearance</u>
  133. to enable your selected
  134. <u><?php echo drupal_ucfirst($theme); ?></u> theme.
  135. </p></li><li><?php endif;
  136. if ("$template_path/$template_name" == "$theme_path/$message_template"): ?><p>
  137. Edit your<br />
  138. <code><?php echo "$template_path/$template_name"; ?></code>
  139. <br />file.
  140. </p></li><li><?php
  141. else:
  142. if (!file_exists("$theme_path/htmlmail.tpl.php")): ?><p>
  143. Copy<br />
  144. <code><?php echo "$module_path/htmlmail.tpl.php"; ?></code>
  145. <br />to<br />
  146. <code><?php echo "$theme_path/htmlmail.tpl.php"; ?></code>
  147. </p></li><li><?php
  148. endif;
  149. if (!file_exists("$theme_path/$module_template")): ?><p>
  150. For module-specific customization, copy<br />
  151. <code><?php echo "$module_path/htmlmail.tpl.php"; ?></code>
  152. <br />to<br />
  153. <code><?php echo "$theme_path/$module_template"; ?></code>
  154. </p></li><li><?php
  155. endif;
  156. if (!file_exists("$theme_path/$message_template")): ?><p>
  157. For message-specific customization, copy<br />
  158. <code><?php echo "$module_path/htmlmail.tpl.php"; ?></code>
  159. <br />to<br />
  160. <code><?php echo "$theme_path/$message_template"; ?></code>
  161. </p></li><li><?php endif; ?><p>
  162. Edit the copied file.
  163. </p></li><li><?php
  164. endif; ?><p>
  165. Send a test message to make sure your customizations worked.
  166. </p></li><li><p>
  167. If you think your customizations would be of use to others,
  168. please contribute your file as a feature request in the
  169. <a href="http://drupal.org/node/add/project-issue/htmlmail">issue queue</a>.
  170. </p></li></ol></dd><?php if (!empty($params)): ?><dt><p>
  171. The <?php echo $module; ?> module sets the <u><code>$params</code></u>
  172. variable. For this message,
  173. </p></dt><dd><p><code><pre>
  174. $params = <?php echo check_plain(print_r($params, 1)); ?>
  175. </pre></code></p></dd><?php endif; ?></dl>
  176. </div>
  177. <?php endif;