From f7ff14c920be92809d72c7298bba4aabbea15c22 Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 21 Jan 2010 14:57:14 -0700 Subject: [PATCH] Remove global IMP print links and replace with part printing Resolves Ticket #8708. --- framework/Core/lib/Horde.php | 16 +++++++++----- horde/js/popup.js | 6 ++++++ imp/config/conf.xml | 6 ------ imp/js/DimpCore.js | 4 ---- imp/js/imp.js | 6 ++++++ imp/js/message.js | 2 -- imp/lib/Contents.php | 15 +++++++++++-- imp/lib/Views/ShowMessage.php | 5 +++-- imp/message-dimp.php | 3 ++- imp/message.php | 16 +++----------- imp/templates/chunks/message.php | 6 ------ imp/templates/index/index-dimp.inc | 6 ------ imp/templates/message/navbar_actions.html | 1 - imp/themes/screen-dimp.css | 34 ----------------------------- imp/themes/screen.css | 36 ++++--------------------------- imp/themes/silver/screen-dimp.css | 3 --- imp/themes/silver/screen.css | 4 ++++ 17 files changed, 52 insertions(+), 117 deletions(-) diff --git a/framework/Core/lib/Horde.php b/framework/Core/lib/Horde.php index 851c1cf8b..cab34ce3f 100644 --- a/framework/Core/lib/Horde.php +++ b/framework/Core/lib/Horde.php @@ -2247,9 +2247,12 @@ HTML; * DEFAULT: 650 px * 'menu' - (boolean) Show the browser menu in the popup window? * DEFAULT: false + * 'onload' - (string) A JS function to call after the popup window is + * fully loaded. + * DEFAULT: None * 'params' - (array) Additional parameters to pass to the URL. * DEFAULT: None - * 'urlencode' - (boolean) URL encode the json string + * 'urlencode' - (boolean) URL encode the json string? * DEFAULT: No * 'width' - (integer) The width of the popup window. * DEFAULT: 700 px @@ -2278,14 +2281,17 @@ HTML; if (!empty($options['height'])) { $params->height = $options['height']; } - if (!empty($options['width'])) { - $params->width = $options['width']; + if (!empty($options['menu'])) { + $params->menu = 1; + } + if (!empty($options['onload'])) { + $params->onload = $options['onload']; } if (!empty($options['params'])) { $params->params = http_build_query(array_map('rawurlencode', $options['params'])); } - if (!empty($options['menu'])) { - $params->menu = 1; + if (!empty($options['width'])) { + $params->width = $options['width']; } return 'Horde.popup(' . self::escapeJson($params, array('urlencode' => !empty($options['urlencode']))) . ');'; diff --git a/horde/js/popup.js b/horde/js/popup.js index 02890a9f6..4cbde2030 100644 --- a/horde/js/popup.js +++ b/horde/js/popup.js @@ -15,6 +15,7 @@ window.Horde = window.Horde || {}; * @param object $opts The following params: * 'height' - The height of the popup window. (Default: 650 px) * 'menu' - Show the browser menu in the popup? (Default: no) + * 'onload' - A function to call when the window is loaded. (Default: none) * 'params' - Any additional params to pass to the script. (Default: no args) * 'width' - The width of the popup window. (Default: 700 px) * 'url' - The URL to open in the popup window. @@ -47,9 +48,14 @@ Horde.popup = function(opts) params.set('uniq', name); win = window.open(url + '?' + params.toQueryString(), name, 'menubar=' + menu + ',toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height + ',left=0,top=0'); + if (!win) { alert(Horde.popup_block_text); } else { + if (opts.onload) { + opts.onload = eval(opts.onload); + win.onload = opts.onload.curry(win); + } if (Object.isUndefined(win.name)) { win.name = name; } diff --git a/imp/config/conf.xml b/imp/config/conf.xml index 904d193cd..17d1a3d5b 100644 --- a/imp/config/conf.xml +++ b/imp/config/conf.xml @@ -137,12 +137,6 @@ - - - Print Options - false - diff --git a/imp/js/DimpCore.js b/imp/js/DimpCore.js index 60c933b68..3fca23383 100644 --- a/imp/js/DimpCore.js +++ b/imp/js/DimpCore.js @@ -398,10 +398,6 @@ var DimpCore = { id = elt.readAttribute('id'); switch (id) { - case 'msg_print': - window.print(); - break; - case 'largeaddrspan_active': tmp = elt.down(); if (!tmp.next().visible() || diff --git a/imp/js/imp.js b/imp/js/imp.js index 7ab3b4191..5c968d1ed 100644 --- a/imp/js/imp.js +++ b/imp/js/imp.js @@ -110,6 +110,12 @@ document.observe('dom:loaded', function() { } }; + IMP.printWindow = function(win) + { + win.print(); + win.close(); + }; + // If menu is present, attach event handlers to folder switcher. var tmp = $('openfoldericon'); if (tmp) { diff --git a/imp/js/message.js b/imp/js/message.js index ac433aba8..2872a45d2 100644 --- a/imp/js/message.js +++ b/imp/js/message.js @@ -169,8 +169,6 @@ var ImpMessage = { this.submit('spam_report'); } else if (elt.hasClassName('notspamAction')) { this.submit('notspam_report'); - } else if (elt.hasClassName('printAction')) { - window.print(); } } else if (elt.hasClassName('unblockImageLink')) { IMP.unblockImages(e); diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index abf285468..b8b21bc8f 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -24,7 +24,8 @@ class IMP_Contents const SUMMARY_DOWNLOAD_NOJS = 128; const SUMMARY_DOWNLOAD_ZIP = 256; const SUMMARY_IMAGE_SAVE = 512; - const SUMMARY_STRIP_LINK = 1024; + const SUMMARY_PRINT = 1024; + const SUMMARY_STRIP_LINK = 2048; /* Rendering mask entries. */ const RENDER_FULL = 1; @@ -601,6 +602,9 @@ class IMP_Contents * IMP_Contents::SUMMARY_IMAGE_SAVE * Output: parts = 'img_save' * + * IMP_Contents::SUMMARY_PRINT + * Output: parts = 'print' + * * IMP_Contents::SUMMARY_STRIP_LINK * Output: parts = 'strip' * @@ -696,6 +700,11 @@ class IMP_Contents $part['img_save'] = Horde::link('#', _("Save Image in Gallery"), 'saveImgAtc', null, Horde::popupJs(Horde::applicationUrl('saveimage.php'), array('params' => array('uid' => ($this->_uid . IMP::IDX_SEP . $this->_mailbox), 'id' => $id), 'height' => 200, 'width' => 450)) . 'return false;') . ''; } + /* Add print link? */ + if ($mask && self::SUMMARY_PRINT) { + $part['print'] = $this->linkViewJS($mime_part, 'view_attach', '', array('css' => 'printAtc', 'onload' => 'IMP.printWindow', 'jstext' => _("Print"), 'params' => $param_array)); + } + /* Strip Attachment? Allow stripping of base parts other than the * base multipart and the base text (body) part. */ if (($mask & self::SUMMARY_STRIP_LINK) && @@ -795,6 +804,8 @@ class IMP_Contents *
      * 'css' - (string) The CSS class to use.
      * 'jstext' - (string) The javascript link text.
+     * 'onload' - (string) A JS function to run when popup window is
+     *            fully loaded.
      * 'params' - (array) A list of any additional parameters that need to be
      *            passed to view.php. (key = name)
      * 'widget' - (boolean) If true use Horde::widget() to generate,
@@ -814,7 +825,7 @@ class IMP_Contents
             $options['jstext'] = sprintf(_("View %s"), $mime_part->getDescription(true));
         }
 
-        $url = Horde::popupJs(Horde::applicationUrl('view.php'), array('menu' => true, 'params' => $this->_urlViewParams($mime_part, $actionID, isset($options['params']) ? $options['params'] : array()), 'urlencode' => true)) . 'return false;';
+        $url = Horde::popupJs(Horde::applicationUrl('view.php'), array('menu' => true, 'onload' => empty($options['onload']) ? '' : $options['onload'], 'params' => $this->_urlViewParams($mime_part, $actionID, isset($options['params']) ? $options['params'] : array()), 'urlencode' => true)) . 'return false;';
 
         return empty($options['widget'])
             ? Horde::link('#', $options['jstext'], empty($options['css']) ? null : $options['css'], null, $url) . $text . ''
diff --git a/imp/lib/Views/ShowMessage.php b/imp/lib/Views/ShowMessage.php
index 1c0d4b177..88f09ca4c 100644
--- a/imp/lib/Views/ShowMessage.php
+++ b/imp/lib/Views/ShowMessage.php
@@ -251,9 +251,10 @@ class IMP_Views_ShowMessage
             IMP_Contents::SUMMARY_ICON |
             IMP_Contents::SUMMARY_DESCRIP_LINK |
             IMP_Contents::SUMMARY_DOWNLOAD |
-            IMP_Contents::SUMMARY_DOWNLOAD_ZIP;
+            IMP_Contents::SUMMARY_DOWNLOAD_ZIP |
+            IMP_Contents::SUMMARY_PRINT;
 
-        $part_info = $part_info_display = array('icon', 'description', 'size', 'download', 'download_zip');
+        $part_info = $part_info_display = array('icon', 'description', 'size', 'download', 'download_zip', 'print');
 
         /* Do MDN processing now. */
         if ($imp_ui->MDNCheck($mailbox, $uid, $mime_headers)) {
diff --git a/imp/message-dimp.php b/imp/message-dimp.php
index c4964ec24..131f34a95 100644
--- a/imp/message-dimp.php
+++ b/imp/message-dimp.php
@@ -41,7 +41,8 @@ if (isset($show_msg_result['error'])) {
 
 $scripts = array(
     array('ContextSensitive.js', 'horde'),
-    array('fullmessage-dimp.js', 'imp')
+    array('fullmessage-dimp.js', 'imp'),
+    array('imp.js', 'imp')
 );
 
 $js_onload = $js_out = array();
diff --git a/imp/message.php b/imp/message.php
index 55c36fe52..a801bce12 100644
--- a/imp/message.php
+++ b/imp/message.php
@@ -528,8 +528,6 @@ if (!$disable_compose &&
 $imp_params = IMP::getIMPMboxParameters($imp_mbox['mailbox'], $uid, $mailbox_name);
 $a_template->set('save_as', Horde::widget(Horde::downloadUrl($subject, array_merge(array('actionID' => 'save_message'), $imp_params)), _("Save as"), 'widget', '', '', _("Sa_ve as"), 2));
 
-$a_template->set('print', Horde::widget('#', _("Print"), 'widget printAction', '', '', _("_Print"), true));
-
 if ($conf['spam']['reporting'] &&
     ($conf['spam']['spamfolder'] ||
      ($mailbox_name != IMP::folderPref($prefs->getValue('spam_folder'), true)))) {
@@ -576,7 +574,7 @@ foreach ($all_list_headers as $head => $val) {
 
 /* Determine the fields that will appear in the MIME info entries. */
 $part_info = $part_info_display = array('icon', 'description', 'size');
-$part_info_action = array('download', 'download_zip', 'img_save', 'strip');
+$part_info_action = array('download', 'download_zip', 'img_save', 'strip', 'print');
 
 $show_parts = Horde_Util::getFormData('show_parts', $prefs->getValue('parts_display'));
 $strip_atc = $prefs->getValue('strip_attachments');
@@ -588,7 +586,8 @@ $contents_mask = IMP_Contents::SUMMARY_BYTES |
     IMP_Contents::SUMMARY_DESCRIP_LINK |
     IMP_Contents::SUMMARY_DOWNLOAD |
     IMP_Contents::SUMMARY_DOWNLOAD_ZIP |
-    IMP_Contents::SUMMARY_IMAGE_SAVE;
+    IMP_Contents::SUMMARY_IMAGE_SAVE |
+    IMP_Contents::SUMMARY_PRINT;
 if (!$readonly && $strip_atc) {
     $contents_mask |= IMP_Contents::SUMMARY_STRIP_LINK;
 }
@@ -647,15 +646,6 @@ if (!empty($inlineout['atc_parts'])) {
     );
 }
 
-if (!empty($conf['print']['add_printedby'])) {
-    $hdrs[] = array(
-        'class' => 'printedby',
-        'name' => _("Printed By"),
-        'val' => $user_identity->getFullname() ? $user_identity->getFullname() : Horde_Auth::getAuth(),
-        'i' => (++$i % 2)
-    );
-}
-
 $m_template->set('headers', $hdrs);
 $m_template->set('msgtext', $mdntext . $inlineout['msgtext']);
 
diff --git a/imp/templates/chunks/message.php b/imp/templates/chunks/message.php
index ee543f3e8..b0a4a8ed4 100644
--- a/imp/templates/chunks/message.php
+++ b/imp/templates/chunks/message.php
@@ -30,12 +30,6 @@
    
-
- - - - -
diff --git a/imp/templates/index/index-dimp.inc b/imp/templates/index/index-dimp.inc index 9da8d6bd0..bd2aceb22 100644 --- a/imp/templates/index/index-dimp.inc +++ b/imp/templates/index/index-dimp.inc @@ -236,12 +236,6 @@ function _simpleButton($id, $text, $image, $nodisplay = false)
-
- - - - -
diff --git a/imp/templates/message/navbar_actions.html b/imp/templates/message/navbar_actions.html index f31fe7ed0..1ee06f220 100644 --- a/imp/templates/message/navbar_actions.html +++ b/imp/templates/message/navbar_actions.html @@ -32,7 +32,6 @@
  • -
  • diff --git a/imp/themes/screen-dimp.css b/imp/themes/screen-dimp.css index 1e066241a..f73452e85 100644 --- a/imp/themes/screen-dimp.css +++ b/imp/themes/screen-dimp.css @@ -1021,9 +1021,6 @@ div.msgSubject span.treeImg { margin-left: 4px; margin-right: 0; } -#msg_print span.iconImg { - background-image: url("graphics/print.png"); -} #quota span.iconImg { background-image: url("graphics/quotauncover.gif"); width: 0; @@ -1063,34 +1060,3 @@ span.readonlyImg { #Growler div.imp-forward, div.imp-redirect, span.imp-forward, span.imp-redirect { background-image: url("graphics/mail_forwarded.png"); } - - -/* Print CSS rules. */ -@media print { - #dimpmain { - position: relative; - left: 0 !important; - margin-left: 0; - top: 0; - } - - #previewPane { - overflow: visible !important; - } - - #msgSplitPane { - border: 0; - } - - #msgHeaders, .dispaddrlist { - display: block !important; - } - - #sidebar, #dimpmain_folder_top, #msgSplitPane .msglist, div.sbdiv, .splitBarVertSidebar, .splitBarHoriz, #toggleHeaders, #Growler, #GrowlerLog, #writemsg, .dimpActions, .dimpOptions { - display: none !important; - } - - a.address { - padding: 0 !important; - } -} diff --git a/imp/themes/screen.css b/imp/themes/screen.css index ebd62689e..f8913e2d0 100644 --- a/imp/themes/screen.css +++ b/imp/themes/screen.css @@ -58,11 +58,6 @@ margin-left: 3px; } -/* Message view styling. */ -#msgheaders tr.printedby { - display: none; -} - /* Newmail alerts. */ #newmail { padding: 1em; @@ -597,7 +592,7 @@ div.mimeStatusMessage, div.mimePartInfo { border-color: #ffd0af; } -.downloadAtc, .downloadZipAtc, .saveImgAtc, .closeImg, .deleteImg, .foldersImg, .searchuiImg, .reloadImg { +.downloadAtc, .downloadZipAtc, .saveImgAtc, .printAtc, .closeImg, .deleteImg, .foldersImg, .searchuiImg, .reloadImg { display: -moz-inline-stack; display: inline-block; height: 16px; @@ -616,6 +611,9 @@ div.mimeStatusMessage, div.mimePartInfo { .downloadZipAtc { background-image: url("graphics/mime/compressed.png"); } +.printAtc { + background-image: url("graphics/print.png"); +} .saveImgAtc { background-image: url("graphics/gallery.png"); } @@ -637,29 +635,3 @@ div.mimeStatusMessage, div.mimePartInfo { #itipconflicts tr.itipnearcollision { background-color: #ee0; } - - -/* Print CSS rules. */ -@media print { - body { - background: #fff; - } - - a, a:visited { - color: #000; - } - - #msgheaders tr.printedby { - display: table-row !important; - } - - .label { - min-width: 60px; - text-align: right; - font-weight: bold; - } - - #msgHeadersColl, .context, .address img, .mimeStatusMessage, .largeaddrlist, #msgAtc, table.msgActionTable, #messages h1.header, table.navbaractions, td.msgheader img, tr.msgheaderParts, .downloadAtc, .downloadZipAtc { - display: none !important; - } -} diff --git a/imp/themes/silver/screen-dimp.css b/imp/themes/silver/screen-dimp.css index e4789fb97..a27e75568 100644 --- a/imp/themes/silver/screen-dimp.css +++ b/imp/themes/silver/screen-dimp.css @@ -160,9 +160,6 @@ span.dimpactionDrafts { #msg_newwin span.iconImg, #msg_newwin_options span.iconImg { background-image: url("graphics/newwin.png"); } -#msg_print span.iconImg { - background-image: url("graphics/print.png"); -} #qsearch_icon { background-image: url("graphics/search.png"); diff --git a/imp/themes/silver/screen.css b/imp/themes/silver/screen.css index 7d43430fb..77064aca1 100644 --- a/imp/themes/silver/screen.css +++ b/imp/themes/silver/screen.css @@ -88,3 +88,7 @@ span.trashImg { .reloadImg { background-image: url("graphics/reload.png"); } + +.printAtc { + background-image: url("graphics/print.png"); +} -- 2.11.0