Proper class naming conventions for Imp_Mimp and Imp_Dimp
authorMichael M Slusarz <slusarz@curecanti.org>
Tue, 4 Aug 2009 23:07:30 +0000 (17:07 -0600)
committerMichael M Slusarz <slusarz@curecanti.org>
Tue, 4 Aug 2009 23:07:30 +0000 (17:07 -0600)
19 files changed:
imp/ajax.php
imp/compose-dimp.php
imp/compose-mimp.php
imp/index-dimp.php
imp/js/DimpBase.js
imp/lib/Api.php
imp/lib/DIMP.php [deleted file]
imp/lib/Dimp.php [new file with mode: 0644]
imp/lib/MIMP.php [deleted file]
imp/lib/Mimp.php [new file with mode: 0644]
imp/lib/Views/ShowMessage.php
imp/mailbox-mimp.php
imp/message-dimp.php
imp/message-mimp.php
imp/templates/chunks/compose.php
imp/templates/chunks/message.php
imp/templates/folders/folders-mimp.inc
imp/templates/index/index-dimp.inc
imp/templates/javascript_defs_dimp.php

index 2e5f68c..9ed06c5 100644 (file)
@@ -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'];
index 558571c..87ff8b6 100644 (file)
@@ -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();
index 64f7b66..afa7ab7 100644 (file)
@@ -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';
index defadbc..904753b 100644 (file)
@@ -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(
index 3e181a3..2235771 100644 (file)
@@ -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,
index 6625287..b3bc34b 100644 (file)
@@ -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 (file)
index 1edd2c9..0000000
+++ /dev/null
@@ -1,352 +0,0 @@
-<?php
-/**
- * DIMP Base Class - provides dynamic view functions.
- *
- * Copyright 2005-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author  Michael Slusarz <slusarz@horde.org>
- * @package IMP
- */
-class DIMP
-{
-    /**
-     * Output a dimp-style action (menubar) link.
-     *
-     * @param array $params  A list of parameters.
-     * <pre>
-     * '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.
-     * </pre>
-     *
-     * @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'])
-                  ? '<span class="iconImg dimpaction' . $params['icon'] . '"></span>'
-                  : '')
-            . $title . '</a>';
-    }
-
-    /**
-     * Output everything up to but not including the <body> 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:
-     * <pre>
-     * '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]
-     * </pre>
-     */
-    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:
-     * <pre>
-     * '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)
-     * </pre>
-     */
-    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 (file)
index 0000000..b9c2722
--- /dev/null
@@ -0,0 +1,352 @@
+<?php
+/**
+ * DIMP Base Class - provides dynamic view functions.
+ *
+ * Copyright 2005-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Michael Slusarz <slusarz@horde.org>
+ * @package IMP
+ */
+class IMP_Dimp
+{
+    /**
+     * Output a dimp-style action (menubar) link.
+     *
+     * @param array $params  A list of parameters.
+     * <pre>
+     * '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.
+     * </pre>
+     *
+     * @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'])
+                  ? '<span class="iconImg dimpaction' . $params['icon'] . '"></span>'
+                  : '')
+            . $title . '</a>';
+    }
+
+    /**
+     * Output everything up to but not including the <body> 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:
+     * <pre>
+     * '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]
+     * </pre>
+     */
+    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:
+     * <pre>
+     * '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)
+     * </pre>
+     */
+    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 (file)
index 22f4376..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-<?php
-/**
- * MIMP Base Class - provides minimalist view functions.
- *
- * Copyright 1999-2009 The Horde Project (http://www.horde.org/)
- *
- * See the enclosed file COPYING for license information (GPL). If you
- * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
- *
- * @author  Chuck Hagenbuch <chuck@horde.org>
- * @author  Michael Slusarz <slusarz@horde.org>
- * @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 (file)
index 0000000..78e3b0c
--- /dev/null
@@ -0,0 +1,55 @@
+<?php
+/**
+ * MIMP Base Class - provides minimalist view functions.
+ *
+ * Copyright 1999-2009 The Horde Project (http://www.horde.org/)
+ *
+ * See the enclosed file COPYING for license information (GPL). If you
+ * did not receive this file, see http://www.fsf.org/copyleft/gpl.html.
+ *
+ * @author  Chuck Hagenbuch <chuck@horde.org>
+ * @author  Michael Slusarz <slusarz@horde.org>
+ * @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']));
+            }
+        }
+    }
+
+}
index 8cc0357..e9b9fe4 100644 (file)
@@ -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;
         }
 
index f5b87df..a78fbd3 100644 (file)
@@ -229,5 +229,5 @@ foreach ($nav as $n) {
     }
 }
 
-MIMP::addMIMPMenu($mset, 'mailbox');
+IMP_Mimp::addMIMPMenu($mset, 'mailbox');
 require IMP_TEMPLATES . '/mailbox/mailbox-mimp.inc';
index d22bdd1..87d8c2c 100644 (file)
@@ -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 "<body>\n";
 require IMP_TEMPLATES . '/chunks/message.php';
 Horde::includeScriptFiles();
index f512ea9..2fdc135 100644 (file)
@@ -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']);
 
index 64261ef..2e07f15 100644 (file)
@@ -28,7 +28,7 @@ function _createDAcompose($text, $image, $id)
     } else {
         $params['title'] = $text;
     }
-    echo DIMP::actionButton($params);
+    echo IMP_Dimp::actionButton($params);
 }
 
 ?>
index c2f25bc..a9b5348 100644 (file)
@@ -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);
 }
 
 ?>
index 37a447b..6cc7265 100644 (file)
@@ -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();
index 390cc4d..d050534 100644 (file)
@@ -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)
index 6628f95..0f7a317 100644 (file)
@@ -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);
 }