From: Michael M Slusarz Date: Fri, 31 Jul 2009 17:45:12 +0000 (-0600) Subject: Move popup generation to horde X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=1a4826f819fb941ce372666614541bdc9290c772;p=horde.git Move popup generation to horde --- diff --git a/imp/js/src/imp.js b/imp/js/src/imp.js index baf06cdf6..c2dd05eed 100644 --- a/imp/js/src/imp.js +++ b/imp/js/src/imp.js @@ -19,51 +19,6 @@ IMP.menuFolderSubmit = function(clear) }; /** - * Open a popup window. - * - * @param string $url The URL to open in the popup window. - * @param integer $width The width of the popup window. (Default: 600 px) - * @param integer $height The height of the popup window. (Default: 500 px) - * @param string $args Any additional args to pass to the script. - * (Default: no args) - */ -IMP.popup = function(url, width, height, args) -{ - var q, win, - params = $H(), - name = new Date().getTime(); - - height = Math.min(screen.height - 75, height || 500); - width = Math.min(screen.width - 75, width || 600); - - q = url.indexOf('?'); - if (q != -1) { - params = $H(url.toQueryParams()); - url = url.substring(0, q); - } - - if (args) { - $H(args.toQueryParams()).each(function(a) { - params.set(a.key, unescape(a.value)); - }); - } - params.set('uniq', name); - - win = window.open(url + '?' + params.toQueryString(), name, 'toolbar=no,location=no,status=yes,scrollbars=yes,resizable=yes,width=' + width + ',height=' + height + ',left=0,top=0'); - if (!win) { - alert(IMP.text.popup_block); - } else { - if (Object.isUndefined(win.name)) { - win.name = name; - } - if (Object.isUndefined(win.opener)) { - win.opener = self; - } - win.focus(); - } -}; - -/** * Use DOM manipulation to un-block images. */ IMP.unblockImages = function(e) diff --git a/imp/lib/Contents.php b/imp/lib/Contents.php index c49977105..907f4ad9f 100644 --- a/imp/lib/Contents.php +++ b/imp/lib/Contents.php @@ -642,7 +642,7 @@ class IMP_Contents if (($mask && self::SUMMARY_IMAGE_SAVE) && $GLOBALS['registry']->hasMethod('images/selectGalleries') && ($mime_part->getPrimaryType() == 'image')) { - $part['img_save'] = Horde::link('#', _("Save Image in Gallery"), 'saveImgAtc', null, IMP::popupIMPString('saveimage.php', array('index' => ($this->_index . IMP::IDX_SEP . $this->_mailbox), 'id' => $id), 450, 200) . "return false;") . ''; + $part['img_save'] = Horde::link('#', _("Save Image in Gallery"), 'saveImgAtc', null, Horde::popupJs(Horde::applicationUrl('saveimage.php'), array('params' => array('index' => ($this->_index . IMP::IDX_SEP . $this->_mailbox), 'id' => $id), 'height' => 200, 'width' => 450)) . 'return false;') . ''; } /* Strip Attachment? Allow stripping of base parts other than the @@ -764,7 +764,7 @@ class IMP_Contents $options['jstext'] = sprintf(_("View %s"), $mime_part->getDescription(true)); } - $url = IMP::popupIMPString('view.php', $this->_urlViewParams($mime_part, $actionID, isset($options['params']) ? $options['params'] : array())) . 'return false;'; + $url = Horde::popupJs(Horde::applicationUrl('view.php'), array('params' => $this->_urlViewParams($mime_part, $actionID, isset($options['params']) ? $options['params'] : array()))) . 'return false;'; return empty($options['widget']) ? Horde::link('#', $options['jstext'], empty($options['css']) ? null : $options['css'], null, $url) . $text . '' diff --git a/imp/lib/Crypt/Pgp.php b/imp/lib/Crypt/Pgp.php index ccaaf58ed..9f5694806 100644 --- a/imp/lib/Crypt/Pgp.php +++ b/imp/lib/Crypt/Pgp.php @@ -470,7 +470,7 @@ class IMP_Crypt_Pgp extends Horde_Crypt_Pgp 'uid' => $uid, 'mime_id' => $id ); - return IMP::popupIMPString('pgp.php', $params, 450, 200); + return Horde::popupJs(Horde::applicationUrl('pgp.php'), array('params' => $params, 'height' => 200, 'width' => 450)); } /** diff --git a/imp/lib/Crypt/Smime.php b/imp/lib/Crypt/Smime.php index 736d4cf5c..fea83d9ac 100644 --- a/imp/lib/Crypt/Smime.php +++ b/imp/lib/Crypt/Smime.php @@ -329,7 +329,7 @@ class IMP_Crypt_Smime extends Horde_Crypt_Smime 'uid' => $uid, 'mime_id' => $id ); - return IMP::popupIMPString('smime.php', $params, 450, 200); + return Horde::popupJs(Horde::applicationUrl('smime.php'), array('params' => $params, 'height' => 200, 'width' => 450)); } /** diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 65fb7c727..4705ad9fb 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -405,11 +405,10 @@ class IMP if (($view != 'mimp') && $GLOBALS['prefs']->getValue('compose_popup') && $GLOBALS['browser']->hasFeature('javascript')) { - Horde::addScriptFile('imp.js', 'imp', true); if (isset($args['to'])) { $args['to'] = addcslashes($args['to'], '\\"'); } - return "javascript:" . self::popupIMPString('compose.php', $args); + return "javascript:" . Horde::popupJs(Horde::applicationUrl('compose.php'), array('params' => $args, 'urlencode' => true)); } return Horde_Util::addParameter(Horde::applicationUrl(($view == 'mimp') ? 'compose-mimp.php' : 'compose.php'), $args); @@ -1187,22 +1186,6 @@ class IMP } /** - * Output the javascript needed to call the IMP popup JS function. - * - * @param string $url The IMP page to load. - * @param array $params An array of paramters to pass to the URL. - * @param integer $width The width of the popup window. - * @param integer $height The height of the popup window. - * - * @return string The javascript needed to call the popup code. - */ - static public function popupIMPString($url, $params = array(), - $width = 700, $height = 650) - { - return "IMP.popup('" . Horde::applicationUrl($url) . "'," . $width . "," . $height . ",'" . $GLOBALS['browser']->escapeJSCode(str_replace('+', '%20', substr(Horde_Util::addParameter('', $params, null, false), 1))) . "');"; - } - - /** * Returns a Horde_Cache object (if configured) and handles any errors * associated with creating the object. * diff --git a/imp/mailbox.php b/imp/mailbox.php index 70c28b18b..c18f29f74 100644 --- a/imp/mailbox.php +++ b/imp/mailbox.php @@ -395,8 +395,7 @@ if ($open_compose_window === false) { if (!isset($options)) { $options = array(); } - Horde::addScriptFile('imp.js', 'imp', true); - $notification->push(IMP::popupIMPString('compose.php', array_merge(array('popup' => 1), $options, IMP::getComposeArgs())), 'javascript'); + Horde::addInlineScript(Horde::popupJs(Horde::applicationUrl('compose.php'), array('params' => array_merge(array('popup' => 1), $options, IMP::getComposeArgs()))), 'dom'); } if (!empty($newmsgs)) { @@ -411,7 +410,7 @@ if (!empty($newmsgs)) { } /* Newmail alert. */ if ($prefs->getValue('nav_popup')) { - $notification->push(IMP::getNewMessagePopup($newmsgs), 'javascript'); + Horde::addInlineScript(IMP::getNewMessagePopup($newmsgs), 'dom'); } } } diff --git a/imp/pgp.php b/imp/pgp.php index 1c19a81dd..664ba6b93 100644 --- a/imp/pgp.php +++ b/imp/pgp.php @@ -346,7 +346,7 @@ if ($prefs->getValue('use_pgp')) { $t->set('no_source', !$GLOBALS['prefs']->getValue('add_source')); if (!$t->get('no_source')) { $cacheSess = Horde_SessionObjects::singleton(); - $t->set('public_import_url', Horde_Util::addParameter(Horde_Util::addParameter($selfURL, 'actionID', 'import_public_key'), 'reload', $cacheSess->storeOid($selfURL, false))); + $t->set('public_import_url', Horde::popupJs($selfURL, array('params' => array('actionID' => 'import_public_key', 'reload' => $cacheSess->storeOid($selfURL, false)), 'height' => 275, 'width' => 750, 'urlencode' => true))); $t->set('import_pubkey-help', Horde_Help::link('imp', 'pgp-import-pubkey')); } } @@ -377,7 +377,7 @@ if ($prefs->getValue('use_pgp')) { $t->set('personalkey-create-keylength-help', Horde_Help::link('imp', 'pgp-personalkey-create-keylength')); $t->set('personalkey-create-passphrase-help', Horde_Help::link('imp', 'pgp-personalkey-create-passphrase')); $t->set('keygen', addslashes(_("Key generation may take a long time to complete. Continue with key generation?"))); - $t->set('personal_import_url', Horde_Util::addParameter($selfURL, 'actionID', 'import_personal_public_key')); + $t->set('personal_import_url', Horde::popupJs($selfURL, array('params' => array('actionID' => 'import_personal_public_key'), 'height' => 275, 'width' => 750, 'urlencode' => true))); $t->set('personalkey-create-actions-help', Horde_Help::link('imp', 'pgp-personalkey-create-actions')); } } diff --git a/imp/smime.php b/imp/smime.php index c1d8026f6..5113afd07 100644 --- a/imp/smime.php +++ b/imp/smime.php @@ -266,7 +266,7 @@ if ($openssl_check && $prefs->getValue('use_smime')) { $t->set('no_source', !$GLOBALS['prefs']->getValue('add_source')); if (!$t->get('no_source')) { $cacheSess = Horde_SessionObjects::singleton(); - $t->set('public_import_url', Horde_Util::addParameter(Horde_Util::addParameter($selfURL, 'actionID', 'import_public_key'), 'reload', $cacheSess->storeOid($selfURL, false))); + $t->set('public_import_url', Horde::popupJs($selfURL, array('params' => array('actionID' => 'import_public_key', 'reload' => $cacheSess->storeOid($selfURL, false)), 'height' => 275, 'width' => 750, 'urlencode' => true))); $t->set('import_pubkey-help', Horde_Help::link('imp', 'smime-import-pubkey')); } } @@ -284,7 +284,7 @@ if ($openssl_check && $prefs->getValue('use_smime')) { $t->set('deletekeypair', addslashes(_("Are you sure you want to delete your keypair? (This is NOT recommended!)"))); $t->set('personalkey-delete-help', Horde_Help::link('imp', 'smime-delete-personal-certs')); } else { - $t->set('personal_import_url', Horde_Util::addParameter($selfURL, 'actionID', 'import_personal_certs')); + $t->set('personal_import_url', Horde::popupJs($selfURL, array('params' => array('actionID' => 'import_personal_certs'), 'height' => 275, 'width' => 750, 'urlencode' => true))); $t->set('import-cert-help', Horde_Help::link('imp', 'smime-import-personal-certs')); } } diff --git a/imp/templates/javascript_defs_dimp.php b/imp/templates/javascript_defs_dimp.php index 2627b9b50..c281075b5 100644 --- a/imp/templates/javascript_defs_dimp.php +++ b/imp/templates/javascript_defs_dimp.php @@ -113,7 +113,6 @@ $code['text'] = array( 'of' => _("of"), 'ok' => _("Ok"), 'onlogout' => _("Logging Out..."), - 'popup_block' => _("A popup window could not be opened. Your browser may be blocking popups."), 'portal' => ("Portal"), 'prefs' => _("User Options"), 'rename_prompt' => _("Rename folder to:"), diff --git a/imp/templates/pgp/pgp.html b/imp/templates/pgp/pgp.html index 6c5ad00e9..6f0816bbc 100644 --- a/imp/templates/pgp/pgp.html +++ b/imp/templates/pgp/pgp.html @@ -49,7 +49,7 @@
Key import is not available. You have no address book defined to add your contacts.
-
+
@@ -125,7 +125,7 @@

- +

diff --git a/imp/templates/smime/smime.html b/imp/templates/smime/smime.html index 61cbaa619..36dd343df 100644 --- a/imp/templates/smime/smime.html +++ b/imp/templates/smime/smime.html @@ -41,7 +41,7 @@ Key import is not available. You have no address book defined to add your contacts. -

+

@@ -75,7 +75,7 @@ Certificate import is not available. File upload is not enabled on this server. -

+