Browse Source

Remove hook call from template; fix all corresponding core plugins.

pdontthink 18 years ago
parent
commit
01db845df0

+ 3 - 10
functions/page_header.php

@@ -144,7 +144,7 @@ body {
 
 EOS;
 
-    $oTemplate->assign('header_tags', $header_tags);
+    $oTemplate->assign('header_tags', $header_tags, FALSE);
     $oTemplate->display('protocol_header.tpl');
 
     /* this is used to check elsewhere whether we should call this function */
@@ -178,14 +178,6 @@ function makeInternalLink($path, $text, $target='') {
     return create_hyperlink($base_uri . $path, $text, $target);
 }
 
-/**
- * Same as makeInternalLink, but echoes it too
- */
-function displayInternalLink($path, $text, $target='') {
-// FIXME: should let the template echo all these kinds of things
-    echo makeInternalLink($path, $text, $target);
-}
-
 /**
  * Outputs a complete SquirrelMail page header, starting with <!doctype> and
  * including the default menu bar. Uses displayHtmlHeader and takes
@@ -249,6 +241,7 @@ function displayPageHeader($color, $mailbox='', $sHeaderJs='', $sBodyTagJs = '')
      * this explains the imap_mailbox.php dependency. We should instead store
      * the selected mailbox in the session and fallback to the session var.
      */
+//FIXME: $shortBoxName will be sanitized when assigned to template, so remove htmlspecialchars on the following line?
     $shortBoxName = htmlspecialchars(imap_utf7_decode_local(
                 readShortMailboxName($mailbox, $delimiter)));
     if ( $shortBoxName == 'INBOX' ) {
@@ -262,7 +255,7 @@ function displayPageHeader($color, $mailbox='', $sHeaderJs='', $sBodyTagJs = '')
 
     $oTemplate->assign('body_tag_js', $sBodyTagJs);
     $oTemplate->assign('shortBoxName', $shortBoxName);
-    $oTemplate->assign('provider_link', $provider_link);
+    $oTemplate->assign('provider_link', $provider_link, FALSE);
     $oTemplate->assign('frame_top', $frame_top);
     $oTemplate->assign('urlMailbox', $urlMailbox);
     $oTemplate->assign('startMessage', $startMessage);

+ 6 - 3
plugins/bug_report/setup.php

@@ -17,7 +17,7 @@
 function squirrelmail_plugin_init_bug_report() {
     global $squirrelmail_plugin_hooks;
 
-    $squirrelmail_plugin_hooks['menuline']['bug_report'] = 'bug_report_button';
+    $squirrelmail_plugin_hooks['template_construct_page_header.tpl']['bug_report'] = 'bug_report_button';
     $squirrelmail_plugin_hooks['loading_prefs']['bug_report'] = 'bug_report_load';
     $squirrelmail_plugin_hooks['optpage_loadhook_display']['bug_report'] = 'bug_report_block';
 }
@@ -35,8 +35,11 @@ function bug_report_button() {
         return;
     }
 
-    displayInternalLink('plugins/bug_report/bug_report.php', _("Bug"), '');
-    echo "&nbsp;&nbsp;\n";
+    global $oTemplate;
+    $nbsp = $oTemplate->fetch('non_breaking_space.tpl');
+    $output = makeInternalLink('plugins/bug_report/bug_report.php', _("Bug"), '')
+            . $nbsp . $nbsp;
+    return array('menuline' => $output);
 }
 
 /**

+ 16 - 0
plugins/calendar/functions.php

@@ -10,6 +10,22 @@
  * @subpackage calendar
  */
 
+/**
+  * Add link to menu at top of content pane
+  *
+  * @return void
+  *
+  */
+function calendar_do() {
+
+    global $oTemplate;
+    $nbsp = $oTemplate->fetch('non_breaking_space.tpl');
+    $output = makeInternalLink('plugins/calendar/calendar.php',_("Calendar"),'right')
+            . $nbsp . $nbsp;
+    return array('menuline' => $output);
+
+}
+
 /**
  * Adds second layer of calendar links to upper menu
  * @return void

+ 22 - 9
plugins/calendar/setup.php

@@ -11,19 +11,32 @@
  */
 
 /**
- * Initialize the plugin
- * @return void
- */
+  * Register this plugin with SquirrelMail
+  * 
+  * @return void
+  *
+  */
 function squirrelmail_plugin_init_calendar() {
+
     global $squirrelmail_plugin_hooks;
-    $squirrelmail_plugin_hooks['menuline']['calendar'] = 'calendar';
+
+    $squirrelmail_plugin_hooks['template_construct_page_header.tpl']['calendar'] 
+        = 'calendar';
+
 }
 
+
 /**
- * Adds Calendar link to upper menu
- * @return void
- */
+  * Add link to menu at top of content pane
+  *
+  * @return void
+  *
+  */
 function calendar() {
-    displayInternalLink('plugins/calendar/calendar.php',_("Calendar"),'right');
-    echo "&nbsp;&nbsp;\n";
+
+    include_once(SM_PATH . 'plugins/calendar/functions.php');
+    return calendar_do();
+
 }
+
+

+ 2 - 1
plugins/mail_fetch/fetch.php

@@ -132,8 +132,9 @@ echo html_tag( 'table',
 
 /* there are no servers defined yet... */
 if($mailfetch['server_number'] == 0) {
+//FIXME: do not echo directly to browser -- use templates only
     echo '<p>' . _("No POP3 servers configured yet.") . '</p>';
-    displayInternalLink('plugins/mail_fetch/options.php',
+    echo makeInternalLink('plugins/mail_fetch/options.php',
                         _("Click here to go to the options page.") );
     $oTemplate->display('footer.tpl');
     exit();

+ 16 - 0
plugins/mail_fetch/functions.php

@@ -24,6 +24,22 @@ include_once (SM_PATH . 'plugins/mail_fetch/class.mail_fetch.php');
 /** declare plugin globals */
 global $mail_fetch_allow_unsubscribed;
 
+/**
+  * Add link to menu at top of content pane
+  *
+  * @return void
+  *
+  */
+function mail_fetch_link_do() {
+
+    global $oTemplate;
+    $nbsp = $oTemplate->fetch('non_breaking_space.tpl');
+    $output = makeInternalLink('plugins/mail_fetch/fetch.php', _("Fetch"), '')
+            . $nbsp . $nbsp;
+    return array('menuline' => $output);
+
+}
+
 /**
  * Controls use of unsubscribed folders in plugin
  * @global boolean $mail_fetch_allow_unsubscribed

+ 3 - 3
plugins/mail_fetch/setup.php

@@ -18,7 +18,7 @@
 function squirrelmail_plugin_init_mail_fetch() {
     global $squirrelmail_plugin_hooks;
 
-    $squirrelmail_plugin_hooks['menuline']['mail_fetch'] = 'mail_fetch_link';
+    $squirrelmail_plugin_hooks['template_construct_page_header.tpl']['mail_fetch'] = 'mail_fetch_link';
     $squirrelmail_plugin_hooks['login_verified']['mail_fetch'] = 'mail_fetch_setnew';
     $squirrelmail_plugin_hooks['left_main_before']['mail_fetch'] = 'mail_fetch_login';
     $squirrelmail_plugin_hooks['optpage_register_block']['mail_fetch'] = 'mailfetch_optpage_register_block';
@@ -30,8 +30,8 @@ function squirrelmail_plugin_init_mail_fetch() {
  * @private
  */
 function mail_fetch_link() {
-    displayInternalLink('plugins/mail_fetch/fetch.php', _("Fetch"), '');
-    echo '&nbsp;&nbsp;';
+    include_once (SM_PATH . 'plugins/mail_fetch/functions.php');
+    return mail_fetch_link_do();
 }
 
 /**

+ 1 - 1
templates/default/page_header.tpl

@@ -82,7 +82,7 @@ $help_link		= makeInternalLink ('src/help.php', $help_str);
    <?php echo $options_link; ?>&nbsp;&nbsp;
    <?php echo $search_link; ?>&nbsp;&nbsp;
    <?php echo $help_link; ?>&nbsp;&nbsp;
-   <?php /* FIXME: no hooks in templates!! */ global $null; do_hook('menuline', $null); ?>
+   <?php if (!empty($plugin_output['menuline'])) echo $plugin_output['menuline']; ?>
   </td>
   <td class="sqm_providerInfo">
    <?php 

+ 1 - 1
templates/default_advanced/page_header.tpl

@@ -102,7 +102,7 @@ $help_link		= makeInternalLink ('src/help.php', $help_str);
    <?php echo $options_link; ?>&nbsp;&nbsp;
    <?php echo $search_link; ?>&nbsp;&nbsp;
    <?php echo $help_link; ?>&nbsp;&nbsp;
-   <?php /* FIXME: no hooks in templates!! */ global $null; do_hook('menuline', $null); ?>
+   <?php if (!empty($plugin_output['menuline'])) echo $plugin_output['menuline']; ?>
   </td>
   <td class="sqm_providerInfo">
     <?php