Remove hook call from template; fix all corresponding core plugins.
authorpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 30 Aug 2007 02:10:25 +0000 (02:10 +0000)
committerpdontthink <pdontthink@7612ce4b-ef26-0410-bec9-ea0150e637f0>
Thu, 30 Aug 2007 02:10:25 +0000 (02:10 +0000)
git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12631 7612ce4b-ef26-0410-bec9-ea0150e637f0

functions/page_header.php
plugins/bug_report/setup.php
plugins/calendar/functions.php
plugins/calendar/setup.php
plugins/mail_fetch/fetch.php
plugins/mail_fetch/functions.php
plugins/mail_fetch/setup.php
templates/default/page_header.tpl
templates/default_advanced/page_header.tpl

index 00b6403237550efafe42328554ca4f72e2ef8949..6bf4d61222f51d37307607d1f00ee80acd572102 100644 (file)
@@ -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);
index 9c1d3ddec2a0dfea6161e19d69743bc93decfe04..4c520f74f16f1dc71f40070488c4875b50e9e000 100644 (file)
@@ -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);
 }
 
 /**
index e29617bad9b3dec9f48ba147f042fc778ce48b0a..16d83720c5cd39dc41268c0608a8bb7ff958d8fe 100644 (file)
  * @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
index d4ecff5fc8a1316d94c94358869da1d29077bb24..956dcd5792c437502208ce383bd943456d34c420 100644 (file)
  */
 
 /**
- * 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();
+
 }
+
+
index 17711ec507340cf5d3f3c282acd60d722c395a6d..d7085276eeef8f50480e853729715190dffbb269 100644 (file)
@@ -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();
index 507fa3879f78ccaffa56ccea2adec1a09fda9b7f..565e867b127abe869a600e05efacaaa1ccb65483 100644 (file)
@@ -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
index 67c81936e29fa25f9cfe0c8e59fdfcfe2df4a9ef..397fc0834eb8d2ba5e13123a42e9a469ba7257dc 100644 (file)
@@ -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();
 }
 
 /**
index 10acf65cc941c6e2ce92ea7273904fa27d68d246..17486a46bff30b5444729e7993ddf75b336f8e20 100644 (file)
@@ -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 
index d85ef9b9c7bf81bb83fb370b11f45d4c2892f9cd..364d1dcd34d9478b0ab17ae3051a9c402e974b28 100644 (file)
@@ -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