From: Michael M Slusarz Date: Tue, 4 Aug 2009 23:07:30 +0000 (-0600) Subject: Proper class naming conventions for Imp_Mimp and Imp_Dimp X-Git-Url: https://git.internetallee.de/?a=commitdiff_plain;h=51a035a3339b2b54461d23354290f4925bd8b226;p=horde.git Proper class naming conventions for Imp_Mimp and Imp_Dimp --- diff --git a/imp/ajax.php b/imp/ajax.php index 2e5f68cde..9ed06c554 100644 --- a/imp/ajax.php +++ b/imp/ajax.php @@ -196,7 +196,7 @@ case 'CreateFolder': $new = $imptree->createMailboxName(Horde_Util::getPost('parent'), $new); $result = $imp_folder->create($new, $prefs->getValue('subscribe')); if ($result) { - $result = DIMP::getFolderResponse($imptree); + $result = IMP_Dimp::getFolderResponse($imptree); } } catch (Horde_Exception $e) { $notification->push($e, 'horde.error'); @@ -215,7 +215,7 @@ case 'DeleteFolder': $imp_folder = IMP_Folder::singleton(); $result = $imp_folder->delete(array($mbox)); if ($result) { - $result = DIMP::getFolderResponse($imptree); + $result = IMP_Dimp::getFolderResponse($imptree); } break; @@ -239,7 +239,7 @@ case 'RenameFolder': if ($old != $new) { $result = $imp_folder->rename($old, $new); if ($result) { - $result = DIMP::getFolderResponse($imptree); + $result = IMP_Dimp::getFolderResponse($imptree); } } } catch (Horde_Exception $e) { @@ -291,7 +291,7 @@ case 'ListFolders': if (Horde_Util::getPost('unsub')) { $mask |= IMP_Imap_Tree::FLIST_UNSUB; } - $result = DIMP::getFolderResponse($imptree, array('a' => $imptree->folderList($mask), 'c' => array(), 'd' => array())); + $result = IMP_Dimp::getFolderResponse($imptree, array('a' => $imptree->folderList($mask), 'c' => array(), 'd' => array())); $quota = _getQuota(); if (!is_null($quota)) { @@ -523,7 +523,7 @@ case 'GetForwardData': $result = new stdClass; // Can't open read-only since we need to store the message cache id. $result->imp_compose = $imp_compose->getCacheId(); - $result->fwd_list = DIMP::getAttachmentInfo($imp_compose); + $result->fwd_list = IMP_Dimp::getAttachmentInfo($imp_compose); $result->body = $fwd_msg['body']; $result->header = $header; $result->format = $fwd_msg['format']; diff --git a/imp/compose-dimp.php b/imp/compose-dimp.php index 558571c99..87ff8b633 100644 --- a/imp/compose-dimp.php +++ b/imp/compose-dimp.php @@ -66,7 +66,7 @@ if (count($_POST)) { if ($action == 'add_attachment') { if ($_SESSION['imp']['file_upload'] && $imp_compose->addFilesFromUpload('file_')) { - $info = DIMP::getAttachmentInfo($imp_compose); + $info = IMP_Dimp::getAttachmentInfo($imp_compose); $result->success = 1; $result->info = end($info); $result->imp_compose = $imp_compose->getCacheId(); @@ -182,12 +182,12 @@ if (count($_POST)) { if (!empty($GLOBALS['conf']['maillog']['use_maillog'])) { $in_reply_to = $imp_compose->getMetadata('in_reply_to'); if (!empty($in_reply_to) && - ($tmp = DIMP::getMsgLogInfo($in_reply_to))) { + ($tmp = IMP_Dimp::getMsgLogInfo($in_reply_to))) { $result->log = $tmp; } } - $res = DIMP::getFolderResponse($imptree); + $res = IMP_Dimp::getFolderResponse($imptree); if (!empty($res)) { $result->folder = $res['a'][0]; } @@ -325,7 +325,7 @@ Horde::addInlineScript($compose_result['js']); /* Some actions, like adding forwards, may return error messages so explicitly * display those messages now. */ -Horde::addInlineScript(array(DIMP::notify()), 'dom'); +Horde::addInlineScript(array(IMP_Dimp::notify()), 'dom'); /* Javascript to be run on window load. */ $compose_result['js_onload'][] = 'DimpCompose.fillForm(' . Horde_Serialize::serialize($msg, Horde_Serialize::JSON) . ', ' . Horde_Serialize::serialize($header, Horde_Serialize::JSON) . ', "' . (($type == 'new' || $type == 'forward') ? 'to' : 'message') . '", true)'; @@ -335,7 +335,7 @@ $scripts = array( array('compose-dimp.js', 'imp', true) ); -DIMP::header(_("Message Composition"), $scripts); +IMP_Dimp::header(_("Message Composition"), $scripts); echo $t->fetch('compose.html'); Horde::includeScriptFiles(); Horde::outputInlineScript(); diff --git a/imp/compose-mimp.php b/imp/compose-mimp.php index 64f7b66da..afa7ab762 100644 --- a/imp/compose-mimp.php +++ b/imp/compose-mimp.php @@ -255,7 +255,7 @@ foreach (array('to', 'cc', 'bcc', 'subject') as $val) { $menu = new Horde_Mobile_card('o', _("Menu")); $mset = &$menu->add(new Horde_Mobile_linkset()); -MIMP::addMIMPMenu($mset, 'compose'); +IMP_Mimp::addMIMPMenu($mset, 'compose'); if ($actionID == 'rc') { require IMP_TEMPLATES . '/compose/redirect-mimp.inc'; diff --git a/imp/index-dimp.php b/imp/index-dimp.php index defadbc8d..904753b2c 100644 --- a/imp/index-dimp.php +++ b/imp/index-dimp.php @@ -45,11 +45,11 @@ if (!empty($site_menu)) { } Horde::addInlineScript($js_code, true); -DIMP::header('', $scripts); +IMP_Dimp::header('', $scripts); /* Get application folders list. */ $application_folders = array(); -foreach (DIMP::menuList() as $app) { +foreach (IMP_Dimp::menuList() as $app) { if ($registry->get('status', $app) != 'inactive' && $registry->hasPermission($app, PERMS_SHOW)) { $application_folders[] = array( diff --git a/imp/js/DimpBase.js b/imp/js/DimpBase.js index 3e181a34a..223577126 100644 --- a/imp/js/DimpBase.js +++ b/imp/js/DimpBase.js @@ -1989,7 +1989,7 @@ var DimpBase = { }, // Folder actions. - // For format of the ob object, see DIMP::_createFolderElt(). + // For format of the ob object, see IMP_Dimp::_createFolderElt(). createFolder: function(ob) { var div, f_node, ftype, li, ll, parent_e, tmp, diff --git a/imp/lib/Api.php b/imp/lib/Api.php index 6625287ed..b3bc34bf7 100644 --- a/imp/lib/Api.php +++ b/imp/lib/Api.php @@ -483,7 +483,7 @@ class IMP_Api extends Horde_Registry_Api $GLOBALS['imp_authentication'] = 'throw'; require_once dirname(__FILE__) . '/base.php'; if (IMP::getViewMode() == 'dimp') { - Horde::addInlineScript(array(DIMP::notify(true)), 'dom'); + Horde::addInlineScript(array(IMP_Dimp::notify(true)), 'dom'); return; } } catch (Horde_Exception $e) {} diff --git a/imp/lib/DIMP.php b/imp/lib/DIMP.php deleted file mode 100644 index 1edd2c94f..000000000 --- a/imp/lib/DIMP.php +++ /dev/null @@ -1,352 +0,0 @@ - - * @package IMP - */ -class DIMP -{ - /** - * Output a dimp-style action (menubar) link. - * - * @param array $params A list of parameters. - *
-     * 'app' - The application to load the icon from.
-     * 'class' - The CSS classname to use for the link.
-     * 'icon' - The icon CSS classname.
-     * 'id' - The DOM ID of the link.
-     * 'title' - The title string.
-     * 'tooltip' - Tooltip text to use.
-     * 
- * - * @return string An HTML link to $url. - */ - static public function actionButton($params = array()) - { - $tooltip = (empty($params['tooltip'])) ? '' : $params['tooltip']; - - if (empty($params['title'])) { - $old_error = error_reporting(0); - $tooltip = nl2br(htmlspecialchars($tooltip, ENT_QUOTES, Horde_Nls::getCharset())); - $title = $ak = ''; - } else { - $title = $params['title']; - $ak = Horde::getAccessKey($title); - } - - return Horde::link('', $tooltip, - empty($params['class']) ? '' : $params['class'], - '', '', '', $ak, - empty($params['id']) ? array() : array('id' => $params['id']), - !empty($title)) - . (!empty($params['icon']) - ? '' - : '') - . $title . ''; - } - - /** - * Output everything up to but not including the tag. - * - * @param string $title The title of the page. - * @param array $scripts Any additional scripts that need to be loaded. - * Each entry contains the three elements necessary - * for a Horde::addScriptFile() call. - */ - static public function header($title, $scripts = array()) - { - // Need to include script files before we start output - $core_scripts = array( - array('effects.js', 'horde', true), - array('horde.js', 'horde', true), - array('DimpCore.js', 'imp', true), - array('Growler.js', 'horde', true) - ); - foreach (array_merge($core_scripts, $scripts) as $val) { - call_user_func_array(array('Horde', 'addScriptFile'), $val); - } - - $page_title = $GLOBALS['registry']->get('name'); - if (!empty($title)) { - $page_title .= ' :: ' . $title; - } - - $GLOBALS['imp_view'] = 'dimp'; - include IMP_BASE . '/templates/common-header.inc'; - - // Send what we have currently output so the browser can start - // loading CSS/JS. See: - // http://developer.yahoo.com/performance/rules.html#flush - flush(); - } - - /** - * Return an appended IMP folder string - */ - static private function _appendedFolderPref($folder) - { - return IMP::folderPref($folder, true); - } - - /** - * Return the javascript code necessary to display notification popups. - * - * @param boolean $parent Send notifications to parent window? - * - * @return string The notification JS code. - */ - static public function notify($parent = false) - { - $GLOBALS['notification']->notify(array('listeners' => 'status')); - $msgs = $GLOBALS['imp_notify']->getStack(); - - return count($msgs) - ? ($parent ? 'parent.' : '') . 'DimpCore.showNotifications(' . Horde_Serialize::serialize($msgs, Horde_Serialize::JSON) . ')' - : ''; - } - - /** - * Formats the response to send to javascript code when dealing with - * folder operations. - * - * @param IMP_Tree $imptree An IMP_Tree object. - * @param array $changes An array with three sub arrays - to be used - * instead of the return from - * $imptree->eltDiff(): - * 'a' - a list of folders/objects to add - * 'c' - a list of changed folders - * 'd' - a list of folders to delete - * - * @return array The object used by the JS code to update the folder tree. - */ - static public function getFolderResponse($imptree, $changes = null) - { - if (is_null($changes)) { - $changes = $imptree->eltDiff(); - } - if (empty($changes)) { - return false; - } - - $result = array(); - - if (!empty($changes['a'])) { - $result['a'] = array(); - foreach ($changes['a'] as $val) { - $result['a'][] = self::_createFolderElt(is_array($val) ? $val : $imptree->element($val)); - } - } - - if (!empty($changes['c'])) { - $result['c'] = array(); - foreach ($changes['c'] as $val) { - // Skip the base element, since any change there won't ever be - // updated on-screen. - if ($val != IMP_Imap_Tree::BASE_ELT) { - $result['c'][] = self::_createFolderElt($imptree->element($val)); - } - } - } - - if (!empty($changes['d'])) { - $result['d'] = array_map('rawurlencode', array_reverse($changes['d'])); - } - - return $result; - } - - /** - * Create an object used by DimpCore to generate the folder tree. - * - * @param array $elt The output from IMP_Tree::element(). - * - * @return stdClass The element object. Contains the following items: - *
-     * 'ch' (children) = Does the folder contain children? [boolean]
-     *                   [DEFAULT: no]
-     * 'cl' (class) = The CSS class. [string] [DEFAULT: 'base']
-     * 'co' (container) = Is this folder a container element? [boolean]
-     *                    [DEFAULT: no]
-     * 'i' (icon) = A user defined icon to use. [string] [DEFAULT: none]
-     * 'l' (label) = The folder display label. [string] [DEFAULT: 'm' val]
-     * 'm' (mbox) = The mailbox value. [string]
-     * 'pa' (parent) = The parent element. [string] [DEFAULT:
-     *                 DIMP.conf.base_mbox]
-     * 'po' (polled) = Is the element polled? [boolean] [DEFAULT: no]
-     * 's' (special) = Is this a "special" element? [boolean] [DEFAULT: no]
-     * 't' (title) = The title value. [string] [DEFAULT: 'm' val]
-     * 'u' (unseen) = The number of unseen messages. [integer]
-     * 'un' (unsubscribed) = Is this folder unsubscribed? [boolean]
-     *                       [DEFAULT: no]
-     * 'v' (virtual) = Is this a virtual folder? [boolean] [DEFAULT: no]
-     * 
- */ - static private function _createFolderElt($elt) - { - $ob = new stdClass; - - if ($elt['children']) { - $ob->ch = 1; - } - $ob->m = $elt['value']; - if ($ob->m != $elt['name']) { - $ob->l = $elt['name']; - } - if ($elt['parent'] != IMP_Imap_Tree::BASE_ELT) { - $ob->pa = $elt['parent']; - } - if ($elt['polled']) { - $ob->po = 1; - } - if ($elt['vfolder']) { - $ob->v = 1; - } - if (!$elt['sub']) { - $ob->un = 1; - } - - $tmp = IMP::getLabel($ob->m); - if ($tmp != $ob->m) { - $ob->t = $tmp; - } - - if ($elt['container']) { - $ob->co = 1; - $ob->cl = 'exp'; - } else { - if ($elt['polled']) { - $ob->u = intval($elt['unseen']); - } - - switch ($elt['special']) { - case IMP_Imap_Tree::SPECIAL_INBOX: - $ob->cl = 'inbox'; - $ob->s = 1; - break; - - case IMP_Imap_Tree::SPECIAL_TRASH: - $ob->cl = 'trash'; - $ob->s = 1; - break; - - case IMP_Imap_Tree::SPECIAL_SPAM: - $ob->cl = 'spam'; - $ob->s = 1; - break; - - case IMP_Imap_Tree::SPECIAL_DRAFT: - $ob->cl = 'drafts'; - $ob->s = 1; - break; - - case IMP_Imap_Tree::SPECIAL_SENT: - $ob->cl = 'sent'; - $ob->s = 1; - break; - - default: - if ($elt['vfolder']) { - if ($GLOBALS['imp_search']->isVTrashFolder($elt['value'])) { - $ob->cl = 'trash'; - } elseif ($GLOBALS['imp_search']->isVINBOXFolder($elt['value'])) { - $ob->cl = 'inbox'; - } - } elseif ($elt['children']) { - $ob->cl = 'exp'; - } - break; - } - } - - if ($elt['user_icon']) { - $ob->cl = 'customimg'; - $dir = empty($elt['icondir']) - ? $GLOBALS['registry']->getImageDir() - : $elt['icondir']; - $ob->i = empty($dir) - ? $elt['icon'] - : $dir . '/' . $elt['icon']; - } - - return $ob; - } - - /** - * Return information about the current attachments for a message - * - * @param IMP_Compose $imp_compose An IMP_Compose object. - * - * @return array An array of arrays with the following keys: - *
-     * 'number' - The current attachment number
-     * 'name' - The HTML encoded attachment name
-     * 'type' - The MIME type of the attachment
-     * 'size' - The size of the attachment in KB (string)
-     * 
- */ - static public function getAttachmentInfo($imp_compose) - { - $fwd_list = array(); - - if ($imp_compose->numberOfAttachments()) { - foreach ($imp_compose->getAttachments() as $atc_num => $data) { - $mime = $data['part']; - - $fwd_list[] = array( - 'number' => $atc_num, - 'name' => htmlspecialchars($mime->getName(true)), - 'type' => $mime->getType(), - 'size' => $mime->getSize() - ); - } - } - - return $fwd_list; - } - - /** - * Return a list of DIMP specific menu items. - * - * @return array The array of menu items. - */ - static public function menuList() - { - if (isset($GLOBALS['conf']['dimp']['menu']['apps'])) { - $apps = $GLOBALS['conf']['dimp']['menu']['apps']; - if (is_array($apps) && count($apps)) { - return $apps; - } - } - return array(); - } - - /** - * Build data structure needed by DimpCore javascript to display message - * log information. - * - * @var string $msg_id The Message-ID header of the message. - * - * @return array An array of information that can be parsed by - * DimpCore.updateInfoList(). - */ - static public function getMsgLogInfo($msg_id) - { - $ret = array(); - - foreach (IMP_Maillog::parseLog($msg_id) as $val) { - $ret[] = array_map('htmlspecialchars', array( - 'm' => $val['msg'], - 't' => $val['action'] - )); - } - - return $ret; - } - -} diff --git a/imp/lib/Dimp.php b/imp/lib/Dimp.php new file mode 100644 index 000000000..b9c272244 --- /dev/null +++ b/imp/lib/Dimp.php @@ -0,0 +1,352 @@ + + * @package IMP + */ +class IMP_Dimp +{ + /** + * Output a dimp-style action (menubar) link. + * + * @param array $params A list of parameters. + *
+     * 'app' - The application to load the icon from.
+     * 'class' - The CSS classname to use for the link.
+     * 'icon' - The icon CSS classname.
+     * 'id' - The DOM ID of the link.
+     * 'title' - The title string.
+     * 'tooltip' - Tooltip text to use.
+     * 
+ * + * @return string An HTML link to $url. + */ + static public function actionButton($params = array()) + { + $tooltip = (empty($params['tooltip'])) ? '' : $params['tooltip']; + + if (empty($params['title'])) { + $old_error = error_reporting(0); + $tooltip = nl2br(htmlspecialchars($tooltip, ENT_QUOTES, Horde_Nls::getCharset())); + $title = $ak = ''; + } else { + $title = $params['title']; + $ak = Horde::getAccessKey($title); + } + + return Horde::link('', $tooltip, + empty($params['class']) ? '' : $params['class'], + '', '', '', $ak, + empty($params['id']) ? array() : array('id' => $params['id']), + !empty($title)) + . (!empty($params['icon']) + ? '' + : '') + . $title . ''; + } + + /** + * Output everything up to but not including the tag. + * + * @param string $title The title of the page. + * @param array $scripts Any additional scripts that need to be loaded. + * Each entry contains the three elements necessary + * for a Horde::addScriptFile() call. + */ + static public function header($title, $scripts = array()) + { + // Need to include script files before we start output + $core_scripts = array( + array('effects.js', 'horde', true), + array('horde.js', 'horde', true), + array('DimpCore.js', 'imp', true), + array('Growler.js', 'horde', true) + ); + foreach (array_merge($core_scripts, $scripts) as $val) { + call_user_func_array(array('Horde', 'addScriptFile'), $val); + } + + $page_title = $GLOBALS['registry']->get('name'); + if (!empty($title)) { + $page_title .= ' :: ' . $title; + } + + $GLOBALS['imp_view'] = 'dimp'; + include IMP_BASE . '/templates/common-header.inc'; + + // Send what we have currently output so the browser can start + // loading CSS/JS. See: + // http://developer.yahoo.com/performance/rules.html#flush + flush(); + } + + /** + * Return an appended IMP folder string + */ + static private function _appendedFolderPref($folder) + { + return IMP::folderPref($folder, true); + } + + /** + * Return the javascript code necessary to display notification popups. + * + * @param boolean $parent Send notifications to parent window? + * + * @return string The notification JS code. + */ + static public function notify($parent = false) + { + $GLOBALS['notification']->notify(array('listeners' => 'status')); + $msgs = $GLOBALS['imp_notify']->getStack(); + + return count($msgs) + ? ($parent ? 'parent.' : '') . 'DimpCore.showNotifications(' . Horde_Serialize::serialize($msgs, Horde_Serialize::JSON) . ')' + : ''; + } + + /** + * Formats the response to send to javascript code when dealing with + * folder operations. + * + * @param IMP_Tree $imptree An IMP_Tree object. + * @param array $changes An array with three sub arrays - to be used + * instead of the return from + * $imptree->eltDiff(): + * 'a' - a list of folders/objects to add + * 'c' - a list of changed folders + * 'd' - a list of folders to delete + * + * @return array The object used by the JS code to update the folder tree. + */ + static public function getFolderResponse($imptree, $changes = null) + { + if (is_null($changes)) { + $changes = $imptree->eltDiff(); + } + if (empty($changes)) { + return false; + } + + $result = array(); + + if (!empty($changes['a'])) { + $result['a'] = array(); + foreach ($changes['a'] as $val) { + $result['a'][] = self::_createFolderElt(is_array($val) ? $val : $imptree->element($val)); + } + } + + if (!empty($changes['c'])) { + $result['c'] = array(); + foreach ($changes['c'] as $val) { + // Skip the base element, since any change there won't ever be + // updated on-screen. + if ($val != IMP_Imap_Tree::BASE_ELT) { + $result['c'][] = self::_createFolderElt($imptree->element($val)); + } + } + } + + if (!empty($changes['d'])) { + $result['d'] = array_map('rawurlencode', array_reverse($changes['d'])); + } + + return $result; + } + + /** + * Create an object used by DimpCore to generate the folder tree. + * + * @param array $elt The output from IMP_Tree::element(). + * + * @return stdClass The element object. Contains the following items: + *
+     * 'ch' (children) = Does the folder contain children? [boolean]
+     *                   [DEFAULT: no]
+     * 'cl' (class) = The CSS class. [string] [DEFAULT: 'base']
+     * 'co' (container) = Is this folder a container element? [boolean]
+     *                    [DEFAULT: no]
+     * 'i' (icon) = A user defined icon to use. [string] [DEFAULT: none]
+     * 'l' (label) = The folder display label. [string] [DEFAULT: 'm' val]
+     * 'm' (mbox) = The mailbox value. [string]
+     * 'pa' (parent) = The parent element. [string] [DEFAULT:
+     *                 DIMP.conf.base_mbox]
+     * 'po' (polled) = Is the element polled? [boolean] [DEFAULT: no]
+     * 's' (special) = Is this a "special" element? [boolean] [DEFAULT: no]
+     * 't' (title) = The title value. [string] [DEFAULT: 'm' val]
+     * 'u' (unseen) = The number of unseen messages. [integer]
+     * 'un' (unsubscribed) = Is this folder unsubscribed? [boolean]
+     *                       [DEFAULT: no]
+     * 'v' (virtual) = Is this a virtual folder? [boolean] [DEFAULT: no]
+     * 
+ */ + static private function _createFolderElt($elt) + { + $ob = new stdClass; + + if ($elt['children']) { + $ob->ch = 1; + } + $ob->m = $elt['value']; + if ($ob->m != $elt['name']) { + $ob->l = $elt['name']; + } + if ($elt['parent'] != IMP_Imap_Tree::BASE_ELT) { + $ob->pa = $elt['parent']; + } + if ($elt['polled']) { + $ob->po = 1; + } + if ($elt['vfolder']) { + $ob->v = 1; + } + if (!$elt['sub']) { + $ob->un = 1; + } + + $tmp = IMP::getLabel($ob->m); + if ($tmp != $ob->m) { + $ob->t = $tmp; + } + + if ($elt['container']) { + $ob->co = 1; + $ob->cl = 'exp'; + } else { + if ($elt['polled']) { + $ob->u = intval($elt['unseen']); + } + + switch ($elt['special']) { + case IMP_Imap_Tree::SPECIAL_INBOX: + $ob->cl = 'inbox'; + $ob->s = 1; + break; + + case IMP_Imap_Tree::SPECIAL_TRASH: + $ob->cl = 'trash'; + $ob->s = 1; + break; + + case IMP_Imap_Tree::SPECIAL_SPAM: + $ob->cl = 'spam'; + $ob->s = 1; + break; + + case IMP_Imap_Tree::SPECIAL_DRAFT: + $ob->cl = 'drafts'; + $ob->s = 1; + break; + + case IMP_Imap_Tree::SPECIAL_SENT: + $ob->cl = 'sent'; + $ob->s = 1; + break; + + default: + if ($elt['vfolder']) { + if ($GLOBALS['imp_search']->isVTrashFolder($elt['value'])) { + $ob->cl = 'trash'; + } elseif ($GLOBALS['imp_search']->isVINBOXFolder($elt['value'])) { + $ob->cl = 'inbox'; + } + } elseif ($elt['children']) { + $ob->cl = 'exp'; + } + break; + } + } + + if ($elt['user_icon']) { + $ob->cl = 'customimg'; + $dir = empty($elt['icondir']) + ? $GLOBALS['registry']->getImageDir() + : $elt['icondir']; + $ob->i = empty($dir) + ? $elt['icon'] + : $dir . '/' . $elt['icon']; + } + + return $ob; + } + + /** + * Return information about the current attachments for a message + * + * @param IMP_Compose $imp_compose An IMP_Compose object. + * + * @return array An array of arrays with the following keys: + *
+     * 'number' - The current attachment number
+     * 'name' - The HTML encoded attachment name
+     * 'type' - The MIME type of the attachment
+     * 'size' - The size of the attachment in KB (string)
+     * 
+ */ + static public function getAttachmentInfo($imp_compose) + { + $fwd_list = array(); + + if ($imp_compose->numberOfAttachments()) { + foreach ($imp_compose->getAttachments() as $atc_num => $data) { + $mime = $data['part']; + + $fwd_list[] = array( + 'number' => $atc_num, + 'name' => htmlspecialchars($mime->getName(true)), + 'type' => $mime->getType(), + 'size' => $mime->getSize() + ); + } + } + + return $fwd_list; + } + + /** + * Return a list of DIMP specific menu items. + * + * @return array The array of menu items. + */ + static public function menuList() + { + if (isset($GLOBALS['conf']['dimp']['menu']['apps'])) { + $apps = $GLOBALS['conf']['dimp']['menu']['apps']; + if (is_array($apps) && count($apps)) { + return $apps; + } + } + return array(); + } + + /** + * Build data structure needed by DimpCore javascript to display message + * log information. + * + * @var string $msg_id The Message-ID header of the message. + * + * @return array An array of information that can be parsed by + * DimpCore.updateInfoList(). + */ + static public function getMsgLogInfo($msg_id) + { + $ret = array(); + + foreach (IMP_Maillog::parseLog($msg_id) as $val) { + $ret[] = array_map('htmlspecialchars', array( + 'm' => $val['msg'], + 't' => $val['action'] + )); + } + + return $ret; + } + +} diff --git a/imp/lib/MIMP.php b/imp/lib/MIMP.php deleted file mode 100644 index 22f437623..000000000 --- a/imp/lib/MIMP.php +++ /dev/null @@ -1,55 +0,0 @@ - - * @author Michael Slusarz - * @package IMP - */ -class MIMP -{ - /** - * Take a Horde_Mobile_card and add global menu items. - * - * @param Horde_Mobile_linkset $menu The menu linkset, with page-specific - * options already filled in. - * @param string $page The current page ('compose', - * 'folders', 'mailbox', 'message'). - */ - public function addMIMPMenu($menu, $page) - { - $items = array(); - - if (!in_array($page, array('mailbox', 'message')) || - ($GLOBALS['imp_mbox']['mailbox'] != 'INBOX')) { - $items[IMP::generateIMPUrl('mailbox-mimp.php', 'INBOX')] = _("Inbox"); - } - - if (($page != 'compose') && IMP::canCompose()) { - $items[Horde_Util::addParameter(Horde::applicationUrl('compose-mimp.php'), 'u', uniqid(mt_rand()))] = _("New Message"); - } - - if ($page != 'folders') { - $items[Horde::applicationUrl('folders-mimp.php')] = _("Folders"); - } - - $items[Horde::getServiceLink('logout', 'imp')] = _("Log out"); - - foreach ($items as $link => $label) { - $menu->add(new Horde_Mobile_link($label, $link)); - } - - $menu = new Horde_Menu(); - foreach ($menu->getSiteLinks() as $menuitem) { - if ($menuitem != 'separator') { - $menu->add(new Horde_Mobile_link($menuitem['text'], $menuitem['url'])); - } - } - } - -} diff --git a/imp/lib/Mimp.php b/imp/lib/Mimp.php new file mode 100644 index 000000000..78e3b0c6d --- /dev/null +++ b/imp/lib/Mimp.php @@ -0,0 +1,55 @@ + + * @author Michael Slusarz + * @package IMP + */ +class IMP_Mimp +{ + /** + * Take a Horde_Mobile_card and add global menu items. + * + * @param Horde_Mobile_linkset $menu The menu linkset, with page-specific + * options already filled in. + * @param string $page The current page ('compose', + * 'folders', 'mailbox', 'message'). + */ + public function addMIMPMenu($menu, $page) + { + $items = array(); + + if (!in_array($page, array('mailbox', 'message')) || + ($GLOBALS['imp_mbox']['mailbox'] != 'INBOX')) { + $items[IMP::generateIMPUrl('mailbox-mimp.php', 'INBOX')] = _("Inbox"); + } + + if (($page != 'compose') && IMP::canCompose()) { + $items[Horde_Util::addParameter(Horde::applicationUrl('compose-mimp.php'), 'u', uniqid(mt_rand()))] = _("New Message"); + } + + if ($page != 'folders') { + $items[Horde::applicationUrl('folders-mimp.php')] = _("Folders"); + } + + $items[Horde::getServiceLink('logout', 'imp')] = _("Log out"); + + foreach ($items as $link => $label) { + $menu->add(new Horde_Mobile_link($label, $link)); + } + + $menu = new Horde_Menu(); + foreach ($menu->getSiteLinks() as $menuitem) { + if ($menuitem != 'separator') { + $menu->add(new Horde_Mobile_link($menuitem['text'], $menuitem['url'])); + } + } + } + +} diff --git a/imp/lib/Views/ShowMessage.php b/imp/lib/Views/ShowMessage.php index 8cc0357f4..e9b9fe473 100644 --- a/imp/lib/Views/ShowMessage.php +++ b/imp/lib/Views/ShowMessage.php @@ -191,7 +191,7 @@ class IMP_Views_ShowMessage /* Grab maillog information. */ if (!empty($GLOBALS['conf']['maillog']['use_maillog']) && - ($tmp = DIMP::getMsgLogInfo($envelope['message-id']))) { + ($tmp = IMP_Dimp::getMsgLogInfo($envelope['message-id']))) { $result['log'] = $tmp; } diff --git a/imp/mailbox-mimp.php b/imp/mailbox-mimp.php index f5b87df75..a78fbd366 100644 --- a/imp/mailbox-mimp.php +++ b/imp/mailbox-mimp.php @@ -229,5 +229,5 @@ foreach ($nav as $n) { } } -MIMP::addMIMPMenu($mset, 'mailbox'); +IMP_Mimp::addMIMPMenu($mset, 'mailbox'); require IMP_TEMPLATES . '/mailbox/mailbox-mimp.inc'; diff --git a/imp/message-dimp.php b/imp/message-dimp.php index d22bdd195..87d8c2c0d 100644 --- a/imp/message-dimp.php +++ b/imp/message-dimp.php @@ -32,7 +32,7 @@ $show_msg = new IMP_Views_ShowMessage(); $show_msg_result = $show_msg->showMessage($args); if (isset($show_msg_result['error'])) { echo Horde::wrapInlineScript(array( - DIMP::notify(), + IMP_Dimp::notify(), 'parent.close()' )); exit; @@ -78,9 +78,9 @@ if (!$disable_compose) { } Horde::addInlineScript($js_out); -Horde::addInlineScript(array(DIMP::notify()), 'dom'); +Horde::addInlineScript(array(IMP_Dimp::notify()), 'dom'); -DIMP::header($show_msg_result['subject'], $scripts); +IMP_Dimp::header($show_msg_result['subject'], $scripts); echo "\n"; require IMP_TEMPLATES . '/chunks/message.php'; Horde::includeScriptFiles(); diff --git a/imp/message-mimp.php b/imp/message-mimp.php index f512ea954..2fdc135ab 100644 --- a/imp/message-mimp.php +++ b/imp/message-mimp.php @@ -344,7 +344,7 @@ if (isset($prev_link)) { $mset->add(new Horde_Mobile_link(sprintf(_("To %s"), IMP::getLabel($imp_mbox['mailbox'])), $mailbox_link)); -MIMP::addMIMPMenu($mset, 'message'); +IMP_Mimp::addMIMPMenu($mset, 'message'); $mimp_render->set('title', $display_headers['subject']); diff --git a/imp/templates/chunks/compose.php b/imp/templates/chunks/compose.php index 64261efdd..2e07f1502 100644 --- a/imp/templates/chunks/compose.php +++ b/imp/templates/chunks/compose.php @@ -28,7 +28,7 @@ function _createDAcompose($text, $image, $id) } else { $params['title'] = $text; } - echo DIMP::actionButton($params); + echo IMP_Dimp::actionButton($params); } ?> diff --git a/imp/templates/chunks/message.php b/imp/templates/chunks/message.php index c2f25bc9a..a9b53480f 100644 --- a/imp/templates/chunks/message.php +++ b/imp/templates/chunks/message.php @@ -23,7 +23,7 @@ function _createDAfmsg($text, $image, $id, $class = '', $show_text = true) } else { $params['tooltip'] = $text; } - echo DIMP::actionButton($params); + echo IMP_Dimp::actionButton($params); } ?> diff --git a/imp/templates/folders/folders-mimp.inc b/imp/templates/folders/folders-mimp.inc index 37a447be9..6cc7265c8 100644 --- a/imp/templates/folders/folders-mimp.inc +++ b/imp/templates/folders/folders-mimp.inc @@ -32,7 +32,7 @@ $mset->add(new Horde_Mobile_link(_("Refresh"), $selfurl)); if ($subscribe) { $mset->add(new Horde_Mobile_link($sub_text, $sub_link)); } -MIMP::addMIMPMenu($mset, 'folders'); +IMP_Mimp::addMIMPMenu($mset, 'folders'); $mimp_render->add($menu); $mimp_render->display(); diff --git a/imp/templates/index/index-dimp.inc b/imp/templates/index/index-dimp.inc index 390cc4d1c..d050534d3 100644 --- a/imp/templates/index/index-dimp.inc +++ b/imp/templates/index/index-dimp.inc @@ -30,7 +30,7 @@ function _createDA($text, $image, $id = null, $class = '', $show_text = true) } else { $params['tooltip'] = $text; } - echo DIMP::actionButton($params); + echo IMP_Dimp::actionButton($params); } function _simpleButton($id, $text, $image, $imagedir = null) diff --git a/imp/templates/javascript_defs_dimp.php b/imp/templates/javascript_defs_dimp.php index 6628f955b..0f7a317d0 100644 --- a/imp/templates/javascript_defs_dimp.php +++ b/imp/templates/javascript_defs_dimp.php @@ -13,7 +13,7 @@ $horde_webroot = $GLOBALS['registry']->get('webroot', 'horde'); $app_urls = $code = $flags = array(); -foreach (DIMP::menuList() as $app) { +foreach (IMP_Dimp::menuList() as $app) { $app_urls[$app] = Horde::url($GLOBALS['registry']->getInitialPage($app), true); }