diff --git a/src/controller.php b/src/controller.php index 377258b..aedbcd9 100644 --- a/src/controller.php +++ b/src/controller.php @@ -27,8 +27,8 @@ class DisplayEmailsController { } public static function render($emails, $config, $user) { - // variables that have to be defined here for frontend template: $emails, $config - require "frontend.template.php"; + // variables that have to be defined here for frontend template: $emails, $config, $user + require "templates/inbox.php"; } } diff --git a/src/frontend.template.php b/src/frontend.template.php deleted file mode 100644 index 6a2f970..0000000 --- a/src/frontend.template.php +++ /dev/null @@ -1,366 +0,0 @@ -set('HTML.Nofollow', true); -$purifier_config->set('HTML.ForbiddenElements', array("img")); -$purifier = new HTMLPurifier($purifier_config); - -\Moment\Moment::setLocale($config['locale']); - -$mailIds = array_map(function ($mail) { - return $mail->id; -}, $emails); -$mailIdsJoinedString = filter_var(join('|', $mailIds), FILTER_SANITIZE_SPECIAL_CHARS); - -// define bigger renderings here to keep the php sections within the html short. -function niceDate($date) { - $m = new \Moment\Moment($date, date_default_timezone_get()); - return $m->calendar(); -} - -function printMessageBody($email, $purifier) { - global $config; - - // To avoid showing empty mails, first purify the html and plaintext - // before checking if they are empty. - $safeHtml = $purifier->purify($email->textHtml); - - $safeText = htmlspecialchars($email->textPlain); - $safeText = nl2br($safeText); - $safeText = \AutoLinkExtension::auto_link_text($safeText); - - $hasHtml = strlen(trim($safeHtml)) > 0; - $hasText = strlen(trim($safeText)) > 0; - - if ($config['prefer_plaintext']) { - if ($hasText) { - echo $safeText; - } else { - echo $safeHtml; - } - } else { - if ($hasHtml) { - echo $safeHtml; - } else { - echo $safeText; - } - } -} - -?> - - - - - - - - - - - - <?php - echo $emails ? "(" . count($emails) . ") " : ""; - echo $user->address ?> - - - - - - - - - -
- - -
 
-
- -
-
-

- Your disposable mailbox is ready. -

-
- -
- address ?>  -
- - -
- -
-
- - -
-
-
-

- - - Open random mailbox - -

- - - or create your own address: -
-
- - -
-
- -
-
-
@
-
- - - - -
-
-
- -
-
- -
-
-
-
-
- -
-
- -
- - id, FILTER_VALIDATE_INT); ?> - - - - - - - - -
-

The mailbox is empty. Checking for new emails automatically.

-
-
-
-
-
-
-
-
- -
-
-
- - - - - - - - - - - - - - diff --git a/src/templates/base_layout.php b/src/templates/base_layout.php new file mode 100644 index 0000000..9b16315 --- /dev/null +++ b/src/templates/base_layout.php @@ -0,0 +1,128 @@ + + + + + + + + + + + + + <?php $titleRenderer() ?> + + + + + + + + + + +
+
+ +
+
+ +
+
+ +
+
+ + + + + + + + + + + + + diff --git a/src/templates/inbox.php b/src/templates/inbox.php new file mode 100644 index 0000000..d159e0c --- /dev/null +++ b/src/templates/inbox.php @@ -0,0 +1,271 @@ +set('HTML.Nofollow', true); +$purifier_config->set('HTML.ForbiddenElements', array("img")); +global $purifier; +$purifier = new HTMLPurifier($purifier_config); + +\Moment\Moment::setLocale($config['locale']); + +// Helper methods + +function niceDate($date) { + $m = new \Moment\Moment($date, date_default_timezone_get()); + return $m->calendar(); +} + +function printMessageBody($email) { + global $config, $purifier; + + // To avoid showing empty mails, first purify the html and plaintext + // before checking if they are empty. + $safeHtml = $purifier->purify($email->textHtml); + + $safeText = htmlspecialchars($email->textPlain); + $safeText = nl2br($safeText); + $safeText = \AutoLinkExtension::auto_link_text($safeText); + + $hasHtml = strlen(trim($safeHtml)) > 0; + $hasText = strlen(trim($safeText)) > 0; + + if ($config['prefer_plaintext']) { + if ($hasText) { + echo $safeText; + } else { + echo $safeHtml; + } + } else { + if ($hasHtml) { + echo $safeHtml; + } else { + echo $safeText; + } + } +} + +// Template sections: + +$titleRenderer = function () use ($emails, $user) { + echo $emails ? "(" . count($emails) . ") " : ""; + echo $user->address; +}; + + + +$preHeaderRenderer= function () use ($emails, $user) { + $mailIds = array_map(function ($mail) { + return $mail->id; + }, $emails); + $mailIdsJoinedString = filter_var(join('|', $mailIds), FILTER_SANITIZE_SPECIAL_CHARS); + + ?> + +
+ + +
 
+
+ + + +
+
+
+

+ + + Open random mailbox + +

+ + + or create your own address: +
+
+ + +
+
+ +
+
+
@
+
+ + + + +
+
+
+ +
+
+ +
+
+
+ + + +
+ + +
+

The mailbox is empty. Checking for new emails automatically.

+
+
+
+
+
+
+
+
+ +
+id, FILTER_VALIDATE_INT); ?> + + + + +
+
+ +
+
+