t12n of fortune output
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 31 Dec 2006 06:28:19 +0000 (06:28 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Sun, 31 Dec 2006 06:28:19 +0000 (06:28 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12035 7612ce4b-ef26-0410-bec9-ea0150e637f0

plugins/fortune/functions.php
plugins/fortune/setup.php
templates/default/plugins/fortune/mailbox_index_before.tpl [new file with mode: 0644]

index dddfdabdb5c2f0cc1dbc8aa09a59d3c91907a54b..dbf066d8dccab6b746e51aed0d93726cceb89b10 100644 (file)
@@ -31,17 +31,12 @@ if (file_exists(SM_PATH . 'config/fortune_config.php')) {
  * @since 1.5.1
  */
 function fortune_function() {
-    global $fortune_visible, $color, $fortune_command;
+    global $oTemplate, $fortune_visible, $color, $fortune_command;
 
     if (!$fortune_visible) {
         return;
     }
 
-    echo "<table cellpadding=\"0\" cellspacing=\"0\" border=\"0\" bgcolor=\"$color[10]\" align=\"center\">\n".
-        "<tr><td><table width=\"100%\" cellpadding=\"2\" cellspacing=\"1\" border=\"0\" bgcolor=\"$color[5]\">\n".
-        "<tr><td align=\"center\">\n";
-    echo '<table><tr><td>';
-
     /* open handle and get all command output*/
     $handle = popen($fortune_command,'r');
     $fortune = '';
@@ -53,11 +48,12 @@ function fortune_function() {
         // %s shows executed fortune cookie command.
         $fortune = sprintf(_("Unable to execute \"%s\"."),$fortune_command);
     }
-    echo "<div style=\"text-align: center;\"><em>" . _("Today's Fortune") . "</em></div><pre>\n" .
-            htmlspecialchars($fortune) .
-            "</pre>\n";
 
-    echo '</td></tr></table></td></tr></table></td></tr></table>';
+    $oTemplate->assign('color', $color);
+    $oTemplate->assign('fortune', htmlspecialchars($fortune));
+    $output = $oTemplate->fetch('plugins/fortune/mailbox_index_before.tpl');
+    return array('mailbox_index_before' => $output);
+
 }
 
 /**
index e85813510d45078ee132ec677a5c405fe4706672..94f2551c6adfbf1c9e5e058e1ceb7fd67276f17c 100644 (file)
@@ -17,7 +17,7 @@
 function squirrelmail_plugin_init_fortune() {
     global $squirrelmail_plugin_hooks;
 
-    $squirrelmail_plugin_hooks['mailbox_index_before']['fortune'] = 'fortune';
+    $squirrelmail_plugin_hooks['template_construct_message_list.tpl']['fortune'] = 'fortune';
     $squirrelmail_plugin_hooks['loading_prefs']['fortune'] = 'fortune_load';
     $squirrelmail_plugin_hooks['optpage_loadhook_display']['fortune'] = 'fortune_options';
 }
@@ -28,7 +28,7 @@ function squirrelmail_plugin_init_fortune() {
  */
 function fortune() {
     include_once(SM_PATH . 'plugins/fortune/functions.php');
-    fortune_function();
+    return fortune_function();
 }
 
 /**
diff --git a/templates/default/plugins/fortune/mailbox_index_before.tpl b/templates/default/plugins/fortune/mailbox_index_before.tpl
new file mode 100644 (file)
index 0000000..dc76ffd
--- /dev/null
@@ -0,0 +1,47 @@
+<?php
+
+/**
+  * mailbox_index_before.tpl
+  *
+  * Template for outputting a fortune above the message 
+  * list for the fortune plugin.
+  *
+  * The following variables are available in this template:
+  *      + $color   - SquirrelMail colors array
+  *      + $fortune - The fortune string to be displayed
+  *
+  * @copyright &copy; 1999-2006 The SquirrelMail Project Team
+  * @license http://opensource.org/licenses/gpl-license.php GNU Public License
+  * @version $Id$
+  * @package squirrelmail
+  * @subpackage plugins
+  */
+
+
+// retrieve the template vars
+//
+extract($t);
+
+
+?>
+<table cellpadding="0" cellspacing="0" border="0" bgcolor="<?php echo $color[10]; ?>" align="center">
+  <tr>
+    <td>
+      <table width="100%" cellpadding="2" cellspacing="1" border="0" bgcolor="$color[5]">
+        <tr>
+          <td align="center">
+            <table>
+              <tr>
+                <td>
+                  <div style="text-align: center;"><em><?php echo _("Today's Fortune"); ?></em></div>
+                  <pre>
+$fortune</pre>
+                </td>
+              </tr>
+            </table>
+          </td>
+        </tr>
+      </table>
+    </td>
+  </tr>
+</table>