Merge mail-handling into index.php for later splitting.

This commit is contained in:
Markus Birth 2016-07-10 01:31:45 +02:00
parent 85329deae2
commit e14010cf60
2 changed files with 12 additions and 26 deletions

View File

@ -2,6 +2,8 @@
require_once __DIR__ . '/vendor' . '/autoload.php';
use \Frs\FieldDefinition;
$m = new Mustache_Engine(array(
'loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__) . '/templates'),
'partials_loader' => new Mustache_Loader_FilesystemLoader(dirname(__FILE__) . '/templates/partials'),
@ -101,9 +103,18 @@ if (!$tpl_done && isset($_SESSION['access_token']) && $_SESSION['access_token'])
echo "This would send the mail...";
$mtpl = $m->loadTemplate('mail_' . $form_type);
$action = $form_type;
$skey = 'form_' . $action;
$data['action'] = $action;
$data['action_uc'] = ucwords($action);
require 'prep_mail.php';
$fd = new FieldDefinition($action);
$fd->addFieldValues($_SESSION[$skey]);
$fieldData = $fd->getFieldData();
$fields = $fieldData['fields'];
$data['email_date'] = date('r');
$data = array_merge($data, $fields);
$mail_html = $mtpl->render($data);
list($headers, $mailbody) = preg_split('/\r?\n\r?\n/', $mail_html, 2);
echo '<hr/>'.$headers.'<hr/>'.$mailbody;

View File

@ -1,25 +0,0 @@
<?php
use \Frs\FieldDefinition;
// FOR TESTING:
if (!isset($action)) {
$action = 'hotel';
$debug = true;
}
$skey = 'form_' . $action;
$fd = new FieldDefinition($action);
$fd->addFieldValues($_SESSION[$skey]);
$fieldData = $fd->getFieldData();
$fields = $fieldData['fields'];
if ($debug) {
print_r($fields);
}
$data['email_date'] = date('r');
$data = array_merge($data, $fields);