adding theming
This commit is contained in:
42
booking.MailSystemInterface.inc
Normal file
42
booking.MailSystemInterface.inc
Normal file
@@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Implements MailSystemInterface
|
||||
* Taken from http://www.ardoubleyou.com/blog/how-programmatically-send-e-mail-using-html-and-text-content-type-drupal-7
|
||||
*/
|
||||
class BookingMailSystem implements MailSystemInterface {
|
||||
/**
|
||||
* Concatenate and wrap the e-mail body for plain-text mails
|
||||
* @param $message
|
||||
* A message array, as described in hook_mail_alter().
|
||||
*
|
||||
* @return
|
||||
* The formatted $message
|
||||
*/
|
||||
public function format(array $message) {
|
||||
$message['body'] = implode("\n\n", $message['body']);
|
||||
return $message;
|
||||
}
|
||||
|
||||
/**
|
||||
* Send an e-mail message, using Drupal variables and default settings.
|
||||
* @see drupal_mail*()
|
||||
* @param $message
|
||||
* A message array, as described in hook_mail_alter()
|
||||
* @return
|
||||
* TRUE if the mail was successfully accepted, otherwise FALSE
|
||||
*/
|
||||
public function mail(array $message) {
|
||||
$mimeheaders = array();
|
||||
foreach($message['headers'] as $name => $value) {
|
||||
$mimeheaders[] = $name . ': ' . mime_header_encode($value);
|
||||
}
|
||||
$line_endings = variable_get('mail_line_endings', MAIL_LINE_ENDINGS);
|
||||
return mail(
|
||||
$message['to'],
|
||||
mime_header_encode($message['subject']),
|
||||
preg_replace('@\r?\n@', $line_endings, $message['body']),
|
||||
join("\n", $mimeheaders)
|
||||
);
|
||||
}
|
||||
}
|
@@ -690,6 +690,27 @@ function booking_uninstall() {
|
||||
//drupal_uninstall_schema('booking');
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement hook_enable()
|
||||
*/
|
||||
function booking_enable() {
|
||||
drupal_set_message($message = t('The Booking System module was successfully enabled.'), $type = 'status');
|
||||
//let MIME Mail know that we can send html emails
|
||||
mailsystem_set(array(
|
||||
'booking' => 'BookingMailSystem',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implement hook_disable()
|
||||
*/
|
||||
function booking_disable() {
|
||||
drupal_set_message($message = t('The Booking System module was successfully disabled.'), $type = 'status');
|
||||
//clean up our entry about mailsystems
|
||||
mailsystem_clear(array(
|
||||
'booking' => 'BookingMailSystem',
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* Implementation of hook_schema().
|
||||
|
@@ -822,11 +822,25 @@ function booking_node_access($node, $op, $account) {
|
||||
/**
|
||||
* Implementation of hook_theme().
|
||||
*/
|
||||
function booking_theme() {
|
||||
function booking_theme($existing, $type, $theme, $path) {
|
||||
if($type == 'module')
|
||||
{
|
||||
return array(
|
||||
'booking_details' => array('arguments' => array('node' => NULL)),
|
||||
'booking_htmlmail_template' => array(
|
||||
'variables' => array('module' => NULL, 'key' => NULL, 'recipient' => NULL, 'subject' => NULL, 'body' => NULL, 'message' => array()),
|
||||
'path' => drupal_get_path('module', 'booking'). '/theme',
|
||||
'template' => 'mimemail-message' // extension of .tpl.php automatically added
|
||||
),
|
||||
);
|
||||
}
|
||||
return array(); //will raise fatal error if void
|
||||
/*
|
||||
return array(
|
||||
'booking_details' => array('arguments' => array('node' => NULL)),
|
||||
//'booking_price_admin' => array('arguments' => array('form' => NULL))
|
||||
);
|
||||
*/
|
||||
}
|
||||
|
||||
/**
|
||||
|
40
theme/mimemail-message.tpl.php
Normal file
40
theme/mimemail-message.tpl.php
Normal file
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* @file
|
||||
* Default theme implementation to format an HTML mail.
|
||||
*
|
||||
* Copy this file in your default theme folder to create a custom themed mail.
|
||||
* Rename it to mimemail-message--[module]--[key].tpl.php to override it for a
|
||||
* specific mail.
|
||||
*
|
||||
* Available variables:
|
||||
* - $recipient: The recipient of the message
|
||||
* - $subject: The message subject
|
||||
* - $body: The message body
|
||||
* - $css: Internal style sheets
|
||||
* - $module: The sending module
|
||||
* - $key: The message identifier
|
||||
*
|
||||
* @see template_preprocess_mimemail_message()
|
||||
*/
|
||||
?>
|
||||
<html>
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||||
<?php if ($css): ?>
|
||||
<style type="text/css">
|
||||
<!--
|
||||
<?php print $css ?>
|
||||
-->
|
||||
</style>
|
||||
<?php endif; ?>
|
||||
</head>
|
||||
<body id="mimemail-body" <?php if ($module && $key): print 'class="'. $module .'-'. $key .'"'; endif; ?>>
|
||||
<div id="center">
|
||||
<div id="main">
|
||||
<?php print $body ?>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
Reference in New Issue
Block a user