From 90b58a32f7b349ab8ed1d1ce3c62b8e36007f890 Mon Sep 17 00:00:00 2001 From: Jan Schneider Date: Mon, 15 Nov 2010 22:59:24 +0100 Subject: [PATCH] Implement folder page. --- framework/Tree/lib/Horde/Tree/Jquerymobile.php | 102 +++++++++++++++++++++++++ framework/Tree/package.xml | 83 ++++++++++++-------- imp/lib/Imap/Tree.php | 28 +++++-- imp/mobile.php | 24 +++++- imp/templates/mobile/folders.html.php | 7 +- imp/templates/mobile/mailbox.html.php | 3 + 6 files changed, 202 insertions(+), 45 deletions(-) create mode 100644 framework/Tree/lib/Horde/Tree/Jquerymobile.php diff --git a/framework/Tree/lib/Horde/Tree/Jquerymobile.php b/framework/Tree/lib/Horde/Tree/Jquerymobile.php new file mode 100644 index 000000000..6c138e53f --- /dev/null +++ b/framework/Tree/lib/Horde/Tree/Jquerymobile.php @@ -0,0 +1,102 @@ + + * @author Jan Schneider + * @category Horde + * @license http://www.fsf.org/copyleft/lgpl.html LGPL + * @package Tree + */ +class Horde_Tree_Jquerymobile extends Horde_Tree_Base +{ + /** + * Allowed parameters for nodes. + * + * @var array + */ + protected $_allowed = array( + 'icon', + 'special', + 'url', + ); + + /** + * Returns the tree. + * + * @return string The HTML code of the rendered tree. + */ + public function getTree($static = false) + { + $tree = ''; + foreach (array(true, false) as $special) { + foreach ($this->_root_nodes as $node_id) { + $tree .= $this->_buildTree($node_id, $special); + } + } + + return $tree; + } + + /** + * Recursive function to walk through the tree array and build the output. + * + * @param string $node_id The Node ID. + * + * @return string The tree rendering. + */ + protected function _buildTree($node_id, $special) + { + $node = $this->_nodes[$node_id]; + $output = ''; + + if ($node['special'] == $special) { + $output = '
  • '; + if (isset($node['extra'][Horde_Tree::EXTRA_LEFT])) { + $output .= implode(' ', $node['extra'][Horde_Tree::EXTRA_LEFT]); + } + if (!empty($node['url'])) { + $output .= ''; + } + $output .= $this->_getIcon($node_id) . $node['label']; + if (!empty($node['url'])) { + $output .= ''; + } + if (isset($node['extra'][Horde_Tree::EXTRA_RIGHT])) { + $output .= '' . implode(' ', $node['extra'][Horde_Tree::EXTRA_RIGHT]) . ''; + } + $output .= '
  • '; + } + + if (isset($node['children'])) { + foreach ($node['children'] as $val) { + $output .= $this->_buildTree($val, $special); + } + } + + return $output; + } + + /** + * Sets the icon for the node. + * + * @param string $node_id The Node ID. + * + * @return string The node icon for the tree line. + */ + protected function _getIcon($node_id) + { + $node = $this->_nodes[$node_id]; + if (empty($node['icon'])) { + return ''; + } + return ''; + } + +} diff --git a/framework/Tree/package.xml b/framework/Tree/package.xml index e300abb4b..8e0247de6 100644 --- a/framework/Tree/package.xml +++ b/framework/Tree/package.xml @@ -1,13 +1,9 @@ - + Tree pear.horde.org Horde Tree API - This package provides a tree view of hierarchical information. It allows for expanding/collapsing of branches and maintains their state. - + This package provides a tree view of hierarchical information. It allows for expanding/collapsing of branches and maintains their state. Chuck Hagenbuch chuck @@ -26,7 +22,8 @@ http://pear.php.net/dtd/package-2.0.xsd"> slusarz@horde.org yes - 2009-12-15 + 2010-11-15 + 0.1.0 0.1.0 @@ -36,27 +33,30 @@ http://pear.php.net/dtd/package-2.0.xsd"> beta GPL - * Split driver code from main class into Base class. - * Add simple HTML renderer. - * Remove dependency on horde/Core. - * Move javascript renderer to horde/Core. - * Add Horde_Tree_Exception::. - * Initial Horde 4 package. + +* Add jQuery Mobile list view renderer. +* Split driver code from main class into Base class. +* Add simple HTML renderer. +* Remove dependency on horde/Core. +* Move javascript renderer to horde/Core. +* Add Horde_Tree_Exception::. +* Initial Horde 4 package. - + + - + - - + + @@ -84,16 +84,32 @@ http://pear.php.net/dtd/package-2.0.xsd"> - - - - - - + + + + + + + + + 0.0.1 + 0.0.1 + + + alpha + alpha + + 2003-07-05 + GPL + +Initial release as a PEAR package + + + 2006-05-08 @@ -105,21 +121,28 @@ http://pear.php.net/dtd/package-2.0.xsd"> alpha GPL - Converted to package.xml 2.0 for pear.horde.org + +Converted to package.xml 2.0 for pear.horde.org - 0.0.1 - 0.0.1 + 0.1.0 + 0.1.0 - alpha - alpha + beta + beta - 2003-07-05 + 2010-11-15 GPL - Initial release as a PEAR package + +* Split driver code from main class into Base class. + * Add simple HTML renderer. + * Remove dependency on horde/Core. + * Move javascript renderer to horde/Core. + * Add Horde_Tree_Exception::. + * Initial Horde 4 package. diff --git a/imp/lib/Imap/Tree.php b/imp/lib/Imap/Tree.php index cba4d88fc..e7d0b3bee 100644 --- a/imp/lib/Imap/Tree.php +++ b/imp/lib/Imap/Tree.php @@ -1519,21 +1519,35 @@ class IMP_Imap_Tree implements ArrayAccess, Iterator, Serializable $is_open = $val->is_open; $label = htmlspecialchars(Horde_String::abbreviate($val->label, 30 - ($val->level * 2))); break; + + case 'Jquerymobile': + $is_open = true; + $label = htmlspecialchars($val->display); + $icon = $val->icon; + $params['icon'] = $icon->icon; + $params['special'] = $val->special; + break; } if (!empty($opts['poll_info']) && $val->polled) { $poll_info = $val->poll_info; - if ($poll_info->unseen) { - $this->unseen += $poll_info->unseen; - if ($poll_info->recent) { - $recent[$val->value] = $poll_info->recent; + if ($opts['render_type'] == 'Jquerymobile') { + if ($poll_info->unseen) { + $after = $poll_info->unseen; } + } else { + if ($poll_info->unseen) { + $this->unseen += $poll_info->unseen; + if ($poll_info->recent) { + $recent[$val->value] = $poll_info->recent; + } - $label = '' . $label . ''; - } + $label = '' . $label . ''; + } - $after = ' (' . $poll_info->unseen . '/' . $poll_info->msgs . ')'; + $after = ' (' . $poll_info->unseen . '/' . $poll_info->msgs . ')'; + } } if (!$val->container) { diff --git a/imp/mobile.php b/imp/mobile.php index 48c63d58a..31123c783 100644 --- a/imp/mobile.php +++ b/imp/mobile.php @@ -14,17 +14,35 @@ */ require_once dirname(__FILE__) . '/lib/Application.php'; -Horde_Registry::appInit('imp', array('impmode' => 'mimp')); +Horde_Registry::appInit('imp', array('impmode' => 'imp')); $view = new Horde_View(array('templatePath' => IMP_TEMPLATES . '/mobile')); new Horde_View_Helper_Text($view); -$view->logout = Horde::getServiceLink('logout')->setRaw(false); +if (empty($conf['user']['allow_folders'])) { + $view->allowFolders = false; +} else { + $view->allowFolders = true; + + /* Initialize the IMP_Imap_Tree object. */ + $imptree = $injector->getInstance('IMP_Imap_Tree'); + $imptree->setIteratorFilter(IMP_Imap_Tree::FLIST_NOCONTAINER); + $tree = $imptree->createTree('mobile_folders', array( + 'poll_info' => true, + 'render_type' => 'Jquerymobile' + )); + $view->tree = $tree->getTree(true); +} + +$view->portal = Horde::getServiceLink('portal', 'horde')->setRaw(false); +$view->logout = Horde::getServiceLink('logout')->setRaw(false); $title = _("Mobile Mail"); require $registry->get('templates', 'horde') . '/common-header-mobile.inc'; echo $view->render('head.html.php'); -echo $view->render('folders.html.php'); +if (!empty($conf['user']['allow_folders'])) { + echo $view->render('folders.html.php'); +} echo $view->render('mailbox.html.php'); echo $view->render('message.html.php'); require $registry->get('templates', 'horde') . '/common-footer-mobile.inc'; diff --git a/imp/templates/mobile/folders.html.php b/imp/templates/mobile/folders.html.php index c1b678143..2f5fe0611 100644 --- a/imp/templates/mobile/folders.html.php +++ b/imp/templates/mobile/folders.html.php @@ -1,6 +1,6 @@
    - +

    logout): ?> @@ -8,10 +8,7 @@
    diff --git a/imp/templates/mobile/mailbox.html.php b/imp/templates/mobile/mailbox.html.php index 0d0ff51cd..1c30a0981 100644 --- a/imp/templates/mobile/mailbox.html.php +++ b/imp/templates/mobile/mailbox.html.php @@ -1,5 +1,8 @@
    + allowFolders): ?> + +

    logout): ?> -- 2.11.0