From 09b143cceb5a99d0b94d8303d644ffeeef203d1f Mon Sep 17 00:00:00 2001 From: pdontthink Date: Thu, 30 Aug 2007 02:10:25 +0000 Subject: [PATCH] Remove hook call from template; fix all corresponding core plugins. git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@12631 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/page_header.php | 13 +++------ plugins/bug_report/setup.php | 9 ++++--- plugins/calendar/functions.php | 16 +++++++++++ plugins/calendar/setup.php | 31 +++++++++++++++------- plugins/mail_fetch/fetch.php | 3 ++- plugins/mail_fetch/functions.php | 16 +++++++++++ plugins/mail_fetch/setup.php | 6 ++--- templates/default/page_header.tpl | 2 +- templates/default_advanced/page_header.tpl | 2 +- 9 files changed, 70 insertions(+), 28 deletions(-) diff --git a/functions/page_header.php b/functions/page_header.php index 00b64032..6bf4d612 100644 --- a/functions/page_header.php +++ b/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 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); diff --git a/plugins/bug_report/setup.php b/plugins/bug_report/setup.php index 9c1d3dde..4c520f74 100644 --- a/plugins/bug_report/setup.php +++ b/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 "  \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); } /** diff --git a/plugins/calendar/functions.php b/plugins/calendar/functions.php index e29617ba..16d83720 100644 --- a/plugins/calendar/functions.php +++ b/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 diff --git a/plugins/calendar/setup.php b/plugins/calendar/setup.php index d4ecff5f..956dcd57 100644 --- a/plugins/calendar/setup.php +++ b/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 "  \n"; + + include_once(SM_PATH . 'plugins/calendar/functions.php'); + return calendar_do(); + } + + diff --git a/plugins/mail_fetch/fetch.php b/plugins/mail_fetch/fetch.php index 17711ec5..d7085276 100644 --- a/plugins/mail_fetch/fetch.php +++ b/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 '

' . _("No POP3 servers configured yet.") . '

'; - 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(); diff --git a/plugins/mail_fetch/functions.php b/plugins/mail_fetch/functions.php index 507fa387..565e867b 100644 --- a/plugins/mail_fetch/functions.php +++ b/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 diff --git a/plugins/mail_fetch/setup.php b/plugins/mail_fetch/setup.php index 67c81936..397fc083 100644 --- a/plugins/mail_fetch/setup.php +++ b/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 '  '; + include_once (SM_PATH . 'plugins/mail_fetch/functions.php'); + return mail_fetch_link_do(); } /** diff --git a/templates/default/page_header.tpl b/templates/default/page_header.tpl index 10acf65c..17486a46 100644 --- a/templates/default/page_header.tpl +++ b/templates/default/page_header.tpl @@ -82,7 +82,7 @@ $help_link = makeInternalLink ('src/help.php', $help_str);          - +          - +