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 $use_previewPane = getPref($data_dir, $username, 'use_previewPane', 0);
76 return (checkForJavascript() && $use_previewPane);
81 * Construct button that clears out any preview pane
82 * contents and inserts JavaScript function used by
83 * message subject link onclick handler. Also disallows
84 * the message list to be loaded into the bottom frame.
87 function preview_pane_message_list_do()
90 if (!checkForJavascript()) return;
92 // globalize $pp_forceTopURL and $pp_noPageHeader to synch
93 // with other plugins (sent_confirmation, for example)
95 global $plugins, $archive_mail_button_has_been_printed,
96 $username, $data_dir, $PHP_SELF, $base_uri,
97 $pp_forceTopURL, $pp_noPageHeader;
101 $use_previewPane = getPref($data_dir, $username, 'use_previewPane', 0);
104 // add refresh function called from code built in function
105 // preview_pane_change_message_target_do()
107 if ($use_previewPane == 1
108 && getPref($data_dir, $username, 'pp_refresh_message_list', 1) == 1)
110 // sqgetGlobalVar('REQUEST_URI', $request_uri, SQ_SERVER);
111 $request_uri = $PHP_SELF;
112 $output .= "<script type=\"text/javascript\">\n<!--\n function pp_refresh() { document.location = '$request_uri'; }\n// -->\n</script>\n";
116 if ($use_previewPane == 1)
118 // why isn't this already available?
119 include_once(SM_PATH
. 'functions/forms.php');
121 $output .= addButton(_("Clear Preview"), 'clear_preview',
122 array('onclick' => 'parent.bottom.document.location=\''
123 . $base_uri . 'plugins/preview_pane/empty_frame.php\'; '))
127 // don't let message list load into preview pane at all
129 . "\n<script language='javascript' type='text/javascript'>\n"
132 . " if (self.name == 'bottom')\n"
135 // NOTE: we can also force the top frame to the URL that was being
136 // loaded in the bottom, but this is usually overkill...
137 // unless another plugin told us to do so (such as sent_confirmation)
138 if ($pp_forceTopURL == 'yes')
140 // $output .= " parent.right.document.location = '" . $_SERVER['REQUEST_URI'] . "&pp=yes';\n";
141 $output .= " parent.right.document.location = '" . $PHP_SELF . "&pp=yes';\n";
145 $output .= " document.location = '" . $base_uri . "plugins/preview_pane/empty_frame.php'\n"
151 return array('mailbox_index_after' => $output);
157 * Points message targets to open in the preview pane
158 * (and possibly refresh message list as well)
161 function preview_pane_change_message_target_do()
164 if (!checkForJavascript()) return;
166 global $data_dir, $username, $target, $onclick, $PHP_SELF;
167 // sqgetGlobalVar('REQUEST_URI', $request_uri, SQ_SERVER);
168 $request_uri = $PHP_SELF;
171 if (getPref($data_dir, $username, 'use_previewPane', 0) == 1)
173 $pp_refresh_message_list = getPref($data_dir, $username, 'pp_refresh_message_list', 1);
176 if ($pp_refresh_message_list)
177 // introduce a delay so read messages actually refresh after they are read
178 // $onclick .= ' onclick="document.location=\'' . $request_uri . '\'; " ';
179 $onclick .= ' setTimeout(\'pp_refresh()\', 500); ';