4 * SquirrelMail Preview Pane Plugin
6 * @copyright © 1999-2007 The SquirrelMail Project Team
7 * @author Paul Lesneiwski <paul@squirrelmail.org>
8 * @license http://opensource.org/licenses/gpl-license.php GNU Public License
11 * @subpackage preview_pane
17 * Build user options for display on "Display Preferences" page
20 function preview_pane_show_options_do()
23 if (!checkForJavascript()) return;
25 global $data_dir, $username;
26 $use_previewPane = getPref($data_dir, $username, 'use_previewPane', 0);
27 $previewPane_vertical_split = getPref($data_dir, $username, 'previewPane_vertical_split', 0);
28 $previewPane_size = getPref($data_dir, $username, 'previewPane_size', 300);
29 $pp_refresh_message_list = getPref($data_dir, $username, 'pp_refresh_message_list', 1);
30 $previewPane_autohide = getPref($data_dir, $username, 'previewPane_autohide', 0);
34 $optpage_data['vals'][1][] = array(
35 'name' => 'use_previewPane',
36 'caption' => _("Show Message Preview Pane"),
37 'type' => SMOPT_TYPE_BOOLEAN
,
38 'initial_value' => $use_previewPane,
39 'refresh' => SMOPT_REFRESH_ALL
,
41 $optpage_data['vals'][1][] = array(
42 'name' => 'previewPane_vertical_split',
43 'caption' => _("Split Preview Pane Vertically"),
44 'type' => SMOPT_TYPE_BOOLEAN
,
45 'initial_value' => $previewPane_vertical_split,
46 'refresh' => SMOPT_REFRESH_ALL
,
48 $optpage_data['vals'][1][] = array(
49 'name' => 'previewPane_size',
50 'caption' => _("Message Preview Pane Size"),
51 'type' => SMOPT_TYPE_INTEGER
,
52 'initial_value' => $previewPane_size,
53 'refresh' => SMOPT_REFRESH_ALL
,
54 'size' => SMOPT_SIZE_TINY
,
56 $optpage_data['vals'][1][] = array(
57 'name' => 'pp_refresh_message_list',
58 'caption' => _("Always Refresh Message List<br />When Using Preview Pane"),
59 'type' => SMOPT_TYPE_BOOLEAN
,
60 'initial_value' => $pp_refresh_message_list,
61 'refresh' => SMOPT_REFRESH_NONE
,
63 $optpage_data['vals'][1][] = array(
64 'name' => 'previewPane_autohide',
65 'caption' => _("Automatically Hide Preview Pane<br />When Not Reading Messages"),
66 'type' => SMOPT_TYPE_BOOLEAN
,
67 'initial_value' => $previewPane_autohide,
68 'refresh' => SMOPT_REFRESH_ALL
,
75 * This function determines if the preview pane is in use
76 * (and JavaScript is available)
78 * @return boolean TRUE if the preview pane should be showing currently.
81 function show_preview_pane()
83 global $data_dir, $username;
84 $use_previewPane = getPref($data_dir, $username, 'use_previewPane', 0);
85 return (checkForJavascript() && $use_previewPane);
90 * Adds preview pane open/close (and clear) buttons next to
94 function preview_pane_open_close_buttons_do()
97 if (!show_preview_pane()) return;
99 global $data_dir, $username, $base_uri, $oTemplate;
100 $previewPane_vertical_split = getPref($data_dir, $username, 'previewPane_vertical_split', 0);
101 if ($previewPane_vertical_split)
103 $orientation = 'cols';
104 $up_arrow = '←';
105 $down_arrow = '→';
109 $orientation = 'rows';
110 $up_arrow = '↑';
111 $down_arrow = '↓';
115 $previewPane_size = getPref($data_dir, $username, 'previewPane_size', 300);
117 $oTemplate->assign('previewPane_size', $previewPane_size);
118 $oTemplate->assign('base_uri', $base_uri);
119 $oTemplate->assign('orientation', $orientation);
120 $oTemplate->assign('down_arrow', $down_arrow);
121 $oTemplate->assign('up_arrow', $up_arrow);
123 $output = $oTemplate->fetch('plugins/preview_pane/collapse_buttons.tpl');
125 return array('provider_link_before' => $output);
131 * Construct button that clears out any preview pane
132 * contents and inserts JavaScript function used by
133 * message subject link onclick handler. Also disallows
134 * the message list to be loaded into the bottom frame.
137 function preview_pane_message_list_do()
140 if (!checkForJavascript()) return;
142 // globalize $pp_refresh_top, $pp_forceTopURL and $pp_noPageHeader to synch
143 // with other plugins (sent_confirmation, for example)
145 global $plugins, $archive_mail_button_has_been_printed,
146 $username, $data_dir, $PHP_SELF, $base_uri, $pp_refresh_top,
147 $pp_forceTopURL, $pp_noPageHeader;
150 sqgetGlobalVar('pp_refresh_top', $pp_refresh_top, SQ_GET
);
152 $use_previewPane = getPref($data_dir, $username, 'use_previewPane', 0);
155 // add refresh function called from code built in function
156 // preview_pane_change_message_target_do()
158 if ($use_previewPane == 1)
159 // Bah, let's put this in anyway (even when the "always refresh thing is off),
160 // in case someone else wants to use it
161 // && getPref($data_dir, $username, 'pp_refresh_message_list', 1) == 1)
163 // sqgetGlobalVar('REQUEST_URI', $request_uri, SQ_SERVER);
164 $request_uri = $PHP_SELF;
165 $output .= "<script type=\"text/javascript\" language=\"JavaScript\">\n<!--\n function pp_refresh() { document.location = '$request_uri'; }\n// -->\n</script>\n";
169 if ($use_previewPane == 1)
171 // why isn't this already available?
172 include_once(SM_PATH
. 'functions/forms.php');
174 $output .= addButton(_("Clear Preview"), 'clear_preview',
175 array('onclick' => 'parent.bottom.document.location=\''
176 . $base_uri . 'plugins/preview_pane/empty_frame.php\'; '))
180 // don't let message list load into preview pane at all
182 . "\n<script language='JavaScript' type='text/javascript'>\n"
185 . " if (self.name == 'bottom')\n"
188 // NOTE: we can also force the top frame to the URL that was being
189 // loaded in the bottom, but this is usually overkill...
190 // unless another plugin told us to do so (such as sent_confirmation)
191 if ($pp_forceTopURL == 'yes')
193 // $output .= " parent.right.document.location = '" . $_SERVER['REQUEST_URI'] . "&pp=yes';\n";
194 $output .= " parent.right.document.location = '" . $PHP_SELF . "&pp=yes';\n";
198 // if someone else asks for it, force the message list to reload
200 else if ($pp_refresh_top)
201 $output.= " if (typeof(parent.right.pp_refresh) != 'undefined')\n"
202 . " parent.right.pp_refresh()\n\n";
205 $output .= " document.location = '" . $base_uri . "plugins/preview_pane/empty_frame.php'\n"
211 return array('mailbox_index_after' => $output);
217 * Points message targets to open in the preview pane
218 * (and possibly refresh message list as well)
221 function preview_pane_change_message_target_do($args)
224 if (!checkForJavascript()) return;
226 global $data_dir, $username, $target, $onclick, $PHP_SELF;
227 // sqgetGlobalVar('REQUEST_URI', $request_uri, SQ_SERVER);
228 $request_uri = $PHP_SELF;
231 if (getPref($data_dir, $username, 'use_previewPane', 0) == 1)
233 $pp_refresh_message_list = getPref($data_dir, $username, 'pp_refresh_message_list', 1);
239 // introduce a delay so read messages actually
240 // refresh after they are read, but only if they
241 // have not already been seen
243 if ($pp_refresh_message_list && empty($aMsg['FLAGS']['\seen']))
244 // old code without refresh delay
245 // $onclick .= ' onclick="document.location=\'' . $request_uri . '\'; " ';
246 $onclick .= ' setTimeout(\'pp_refresh()\', 500); ';