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);
33 $optpage_data['vals'][1][] = array(
34 'name' => 'use_previewPane',
35 'caption' => _("Show Message Preview Pane"),
36 'type' => SMOPT_TYPE_BOOLEAN
,
37 'initial_value' => $use_previewPane,
38 'refresh' => SMOPT_REFRESH_ALL
,
40 $optpage_data['vals'][1][] = array(
41 'name' => 'previewPane_vertical_split',
42 'caption' => _("Split Preview Pane Vertically"),
43 'type' => SMOPT_TYPE_BOOLEAN
,
44 'initial_value' => $previewPane_vertical_split,
45 'refresh' => SMOPT_REFRESH_ALL
,
47 $optpage_data['vals'][1][] = array(
48 'name' => 'previewPane_size',
49 'caption' => _("Message Preview Pane Size"),
50 'type' => SMOPT_TYPE_INTEGER
,
51 'initial_value' => $previewPane_size,
52 'refresh' => SMOPT_REFRESH_ALL
,
53 'size' => SMOPT_SIZE_TINY
,
55 $optpage_data['vals'][1][] = array(
56 'name' => 'pp_refresh_message_list',
57 'caption' => _("Always Refresh Message List<br />When Using Preview Pane"),
58 'type' => SMOPT_TYPE_BOOLEAN
,
59 'initial_value' => $pp_refresh_message_list,
60 'refresh' => SMOPT_REFRESH_ALL
,
67 * This function determines if the preview pane is in use
68 * (and JavaScript is available)
70 * @return boolean TRUE if the preview pane should be showing currently.
73 function show_preview_pane()
75 global $data_dir, $username;
76 $use_previewPane = getPref($data_dir, $username, 'use_previewPane', 0);
77 return (checkForJavascript() && $use_previewPane);
82 * Adds preview pane open/close (and clear) buttons next to
86 function preview_pane_open_close_buttons_do()
89 if (!show_preview_pane()) return;
91 global $data_dir, $username, $base_uri;
92 $previewPane_vertical_split = getPref($data_dir, $username, 'previewPane_vertical_split', 0);
93 if ($previewPane_vertical_split)
97 $down_arrow = '→';
102 $up_arrow = '↑';
103 $down_arrow = '↓';
107 $previewPane_size = getPref($data_dir, $username, 'previewPane_size', 300);
110 $output = "\n<script type=\"text/javascript\">\n"
112 . " function set_preview_pane_size(new_size)\n"
114 . " if (document.all)\n"
116 . " parent.document.all[\"fs2\"].$split = \"*, \" + new_size;\n"
118 . " else if (this.document.getElementById)\n"
120 . " parent.document.getElementById(\"fs2\").$split = \"*, \" + new_size;\n"
123 . "// -->\n</script>\n"
124 . '<form style="margin:0">'
125 . '<input type="button" value="' . $down_arrow . '" onclick="set_preview_pane_size(0)" />'
126 . '<input type="button" value="X" onclick="parent.bottom.document.location=\'' . $base_uri . 'plugins/preview_pane/empty_frame.php\'" />'
127 . '<input type="button" value="' . $up_arrow . '" onclick="set_preview_pane_size(' . $previewPane_size . ')" />'
130 return array('provider_link_before' => $output);
136 * Construct button that clears out any preview pane
137 * contents and inserts JavaScript function used by
138 * message subject link onclick handler. Also disallows
139 * the message list to be loaded into the bottom frame.
142 function preview_pane_message_list_do()
145 if (!checkForJavascript()) return;
147 // globalize $pp_refresh_top, $pp_forceTopURL and $pp_noPageHeader to synch
148 // with other plugins (sent_confirmation, for example)
150 global $plugins, $archive_mail_button_has_been_printed,
151 $username, $data_dir, $PHP_SELF, $base_uri, $pp_refresh_top,
152 $pp_forceTopURL, $pp_noPageHeader;
155 sqgetGlobalVar('pp_refresh_top', $pp_refresh_top, SQ_GET
);
157 $use_previewPane = getPref($data_dir, $username, 'use_previewPane', 0);
160 // add refresh function called from code built in function
161 // preview_pane_change_message_target_do()
163 if ($use_previewPane == 1)
164 // Bah, let's put this in anyway (even when the "always refresh thing is off),
165 // in case someone else wants to use it
166 // && getPref($data_dir, $username, 'pp_refresh_message_list', 1) == 1)
168 // sqgetGlobalVar('REQUEST_URI', $request_uri, SQ_SERVER);
169 $request_uri = $PHP_SELF;
170 $output .= "<script type=\"text/javascript\">\n<!--\n function pp_refresh() { document.location = '$request_uri'; }\n// -->\n</script>\n";
174 if ($use_previewPane == 1)
176 // why isn't this already available?
177 include_once(SM_PATH
. 'functions/forms.php');
179 $output .= addButton(_("Clear Preview"), 'clear_preview',
180 array('onclick' => 'parent.bottom.document.location=\''
181 . $base_uri . 'plugins/preview_pane/empty_frame.php\'; '))
185 // don't let message list load into preview pane at all
187 . "\n<script language='javascript' type='text/javascript'>\n"
190 . " if (self.name == 'bottom')\n"
193 // NOTE: we can also force the top frame to the URL that was being
194 // loaded in the bottom, but this is usually overkill...
195 // unless another plugin told us to do so (such as sent_confirmation)
196 if ($pp_forceTopURL == 'yes')
198 // $output .= " parent.right.document.location = '" . $_SERVER['REQUEST_URI'] . "&pp=yes';\n";
199 $output .= " parent.right.document.location = '" . $PHP_SELF . "&pp=yes';\n";
203 // if someone else asks for it, force the message list to reload
205 else if ($pp_refresh_top)
206 $output.= " if (typeof(parent.right.pp_refresh) != 'undefined')\n"
207 . " parent.right.pp_refresh()\n\n";
210 $output .= " document.location = '" . $base_uri . "plugins/preview_pane/empty_frame.php'\n"
216 return array('mailbox_index_after' => $output);
222 * Points message targets to open in the preview pane
223 * (and possibly refresh message list as well)
226 function preview_pane_change_message_target_do()
229 if (!checkForJavascript()) return;
231 global $data_dir, $username, $target, $onclick, $PHP_SELF;
232 // sqgetGlobalVar('REQUEST_URI', $request_uri, SQ_SERVER);
233 $request_uri = $PHP_SELF;
236 if (getPref($data_dir, $username, 'use_previewPane', 0) == 1)
238 $pp_refresh_message_list = getPref($data_dir, $username, 'pp_refresh_message_list', 1);
241 if ($pp_refresh_message_list)
242 // introduce a delay so read messages actually refresh after they are read
243 // $onclick .= ' onclick="document.location=\'' . $request_uri . '\'; " ';
244 $onclick .= ' setTimeout(\'pp_refresh()\', 500); ';