From e883b46ee74c1f2d5ea382bded08a3e728cc47d5 Mon Sep 17 00:00:00 2001 From: pdontthink Date: Wed, 9 Jul 2008 08:46:36 +0000 Subject: [PATCH] Bring the left_main_after_each_folder hook to life git-svn-id: https://svn.code.sf.net/p/squirrelmail/code/trunk/squirrelmail@13222 7612ce4b-ef26-0410-bec9-ea0150e637f0 --- functions/template/folder_list_util.php | 12 ++++++++++++ templates/default/left_main.tpl | 21 +++++---------------- templates/default_advanced/js/dtree.js | 1 + templates/default_advanced/left_main.tpl | 10 +++++----- 4 files changed, 23 insertions(+), 21 deletions(-) diff --git a/functions/template/folder_list_util.php b/functions/template/folder_list_util.php index 42a29ee..61c4322 100644 --- a/functions/template/folder_list_util.php +++ b/functions/template/folder_list_util.php @@ -47,6 +47,7 @@ function getMessageCount ($boxes, $type='total') { /** * Recursively iterates a mailboxes object to build a data structure that is * easy for template authors to work with. +FIXME: well.... why not document that data structure here? * * @param object $boxes Object of the class mailboxes * @author Steve Brown @@ -115,5 +116,16 @@ function getBoxStructure ($boxes) { $box['ChildBoxes'][] = getBoxStructure($boxes->mbxs[$i]); } + // if plugins want to add some text or link after the folder name in + // the folder list, they should add to the "ExtraOutput" array element + // in $box (remember, it's passed through the hook by reference) -- making + // sure to play nice with other plugins by *concatenating* to "ExtraOutput" + // and NOT by overwriting it + // + // known users of this hook: + // empty_folders + // + do_hook('left_main_after_each_folder', $box); + return $box; } diff --git a/templates/default/left_main.tpl b/templates/default/left_main.tpl index 27fada3..6d9169c 100644 --- a/templates/default/left_main.tpl +++ b/templates/default/left_main.tpl @@ -209,6 +209,11 @@ function buildMailboxTree ($box, $settings, $icon_theme_path, $indent_factor=0) } } + // Add any extra output that may have been added by plugins, etc + // + if (!empty($box['ExtraOutput'])) + $end .= $box['ExtraOutput']; + $span = ''; $spanend = ''; if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) { @@ -219,22 +224,6 @@ function buildMailboxTree ($box, $settings, $icon_theme_path, $indent_factor=0) $spanend = ''; } -/******** - * Pulling imapConnection due to segfaults that cannot be tracked down. Best - * we can determine, it's some combination of this var and >= 4 plugins enabled. - * No further clue from anyone. - ******** - * Update: syntax of this hook call changed a bit, so if the error is so anomalous, - * it might be worth trying this again to see if it is still segfaulting - ******** - - // let plugins fiddle with end of line -// FIXME: no hooks in templates! Although note that I'm not sure we can avoid it here because the context of which folder we are displaying is important to the hook, unless we preemptively iterate through all folders and collect the output from the hook call for that and give that to the template.... seems like overkill; I say this hook remains - $end .= concat_hook_function('left_main_after_each_folder', - $temp=array(isset($numMessages) ? &$numMessages : '', - &$box['MailboxFullName'], &$settings['imapConnection'])); -*/ - $end .= ''; $out = ''; diff --git a/templates/default_advanced/js/dtree.js b/templates/default_advanced/js/dtree.js index 37f8f0e..245b497 100644 --- a/templates/default_advanced/js/dtree.js +++ b/templates/default_advanced/js/dtree.js @@ -141,6 +141,7 @@ dTree.prototype.node = function(node, nodeId) { else if ((!this.config.folderLinks || !node.url) && node._hc && node.pid != this.root.id) str += ''; str += node.name; +//FIXME: if node.name contains a hyperlink, either the plugin that put it there should be responsible for adding the for the main folder link or the line below should be changed to detect inner links and close the main one before any; for now, it seems to work anyway although I think the resultant HTML is invalid (hyperlink within a hyperlink and extra, out of place closing at the end) if (node.url || ((!this.config.folderLinks || !node.url) && node._hc)) str += ''; str += ''; if (node._hc) { diff --git a/templates/default_advanced/left_main.tpl b/templates/default_advanced/left_main.tpl index 2deb4aa..47005ea 100644 --- a/templates/default_advanced/left_main.tpl +++ b/templates/default_advanced/left_main.tpl @@ -195,6 +195,11 @@ function buildMailboxTree ($box, $settings, $icon_theme_path, $parent_node=-1) { } } + // Add any extra output that may have been added by plugins, etc + // + if (!empty($box['ExtraOutput'])) + $end .= $box['ExtraOutput']; + $span = ''; $spanend = ''; if ($settings['useSpecialFolderColor'] && $box['IsSpecial']) { @@ -205,11 +210,6 @@ function buildMailboxTree ($box, $settings, $icon_theme_path, $parent_node=-1) { $spanend = ''; } - /** - * NOTE: Plugins would horribly break this advanced tree, so we are - * going to skip that part altogether. - */ - $name = str_replace( array(' ','<','>'), array(' ','<','>'), -- 1.9.1