From b14a67fd40e9cdd8f943a2db1e17a5d09abc00ab Mon Sep 17 00:00:00 2001 From: Michael M Slusarz Date: Thu, 8 Apr 2010 12:31:42 -0600 Subject: [PATCH] Make folder list display display via template. --- imp/js/mailbox.js | 2 +- imp/js/message.js | 2 +- imp/lib/IMP.php | 73 ++++++++++++++++++++++---------------- imp/templates/imp/flist/flist.html | 31 ++++++++++++++++ 4 files changed, 76 insertions(+), 32 deletions(-) create mode 100644 imp/templates/imp/flist/flist.html diff --git a/imp/js/mailbox.js b/imp/js/mailbox.js index eecc268bd..ca1e169bb 100644 --- a/imp/js/mailbox.js +++ b/imp/js/mailbox.js @@ -119,7 +119,7 @@ var ImpMailbox = { tmbox.setValue($F('targetMailbox1')); // Check for a mailbox actually being selected. - if ($F(tmbox) == '*new*') { + if ($F(tmbox) == "\0create") { newFolder = prompt(IMP.text.newfolder, ''); if (newFolder != null && newFolder != '') { $('newMbox').setValue(1); diff --git a/imp/js/message.js b/imp/js/message.js index 2872a45d2..ab949903c 100644 --- a/imp/js/message.js +++ b/imp/js/message.js @@ -65,7 +65,7 @@ var ImpMessage = { tmbox.setValue($F('target1')); // Check for a mailbox actually being selected. - if ($F(tmbox) == '*new*') { + if ($F(tmbox) == "\0create") { newFolder = window.prompt(IMP.text.newfolder, ''); if (newFolder != null && newFolder != '') { $('newMbox').setValue(1); diff --git a/imp/lib/IMP.php b/imp/lib/IMP.php index 8f4aa098d..af486d4c1 100644 --- a/imp/lib/IMP.php +++ b/imp/lib/IMP.php @@ -157,44 +157,56 @@ class IMP * rather than a cached value for each different mailbox we may * visit. */ $mailboxes = $GLOBALS['injector']->getInstance('IMP_Folder')->flist(); - $text = ''; - if (!empty($options['heading']) && - (strlen($options['heading']) > 0)) { - $text .= '\n"; + $t = $GLOBALS['injector']->getInstance('Horde_Template'); + $t->setOption('gettext', true); + + if (!empty($options['heading']) && (strlen($options['heading']) > 0)) { + $t->set('heading', $options['heading']); } if (!empty($options['new_folder']) && (!empty($GLOBALS['conf']['hooks']['permsdenied']) || ($GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('create_folders') && $GLOBALS['injector']->getInstance('Horde_Perms')->hasAppPermission('max_folders')))) { - $text .= "\n" . - '\n" . - "\n"; + $t->set('new_mbox', true); } /* Add the list of mailboxes to the lists. */ - $filter = empty($options['filter']) ? array() : array_flip($options['filter']); + $filter = empty($options['filter']) + ? array() + : array_flip($options['filter']); + $mbox_list = array(); + foreach ($mailboxes as $mbox) { - if (isset($filter[$mbox['val']])) { - continue; + if (!isset($filter[$mbox['val']])) { + $label = (isset($options['abbrev']) && !$options['abbrev']) + ? $mbox['label'] + : $mbox['abbrev']; + + $mbox_list[] = array( + 'l' => Horde_Text_Filter::filter($label, 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)), + 'sel' => (!empty($options['selected']) && ($mbox['val'] === $options['selected'])), + 'v' => htmlspecialchars($mbox['val']) + ); } - - $val = isset($filter[$mbox['val']]) ? '' : htmlspecialchars($mbox['val']); - $sel = ($mbox['val'] && !empty($options['selected']) && ($mbox['val'] === $options['selected'])) ? ' selected="selected"' : ''; - $label = (isset($options['abbrev']) && !$options['abbrev']) ? $mbox['label'] : $mbox['abbrev']; - $text .= sprintf('%s', $val, $sel, Horde_Text_Filter::filter($label, 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)), "\n"); } + $t->set('mbox', $mbox_list); /* Add the list of virtual folders to the list. */ if (!empty($options['inc_vfolder'])) { $vfolders = $GLOBALS['imp_search']->listQueries(IMP_Search::LIST_VFOLDER); if (!empty($vfolders)) { + $vfolder_list = array(); $vfolder_sel = $GLOBALS['imp_search']->searchMboxID(); - $text .= '' . "\n"; foreach ($vfolders as $id => $val) { - $text .= sprintf('%s', $GLOBALS['imp_search']->createSearchID($id), ($vfolder_sel == $id) ? ' selected="selected"' : '', Horde_Text_Filter::filter($val, 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)), "\n"); + $vfolder_list[] = array( + 'l' => Horde_Text_Filter::filter($val, 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)), + 'sel' => ($vfolder_sel == $id), + 'v' => htmlspecialchars($GLOBALS['imp_search']->createSearchID($id)) + ); } + $t->set('vfolder', $vfolder_list); } } @@ -205,14 +217,14 @@ class IMP $tasklists = $GLOBALS['registry']->call('tasks/listTasklists', array(false, Horde_Perms::EDIT)); if (count($tasklists)) { - $text .= '' . "\n"; - + $tasklist_list = array(); foreach ($tasklists as $id => $tasklist) { - $text .= sprintf('%s', - '_tasklist_' . $id, - Horde_Text_Filter::filter($tasklist->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)), - "\n"); + $tasklist_list[] = array( + 'l' => Horde_Text_Filter::filter($tasklist->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)), + 'v' => '_tasklist_' . $id + ); } + $t->set('tasklist', $tasklist_list); } } catch (Horde_Exception $e) {} } @@ -222,20 +234,21 @@ class IMP !empty($_SESSION['imp']['notepadavail'])) { try { $notepads = $GLOBALS['registry']->call('notes/listNotepads', array(false, Horde_Perms::EDIT)); - if (count($notepads)) { - $text .= '\n"; + if (count($notepads)) { + $notepad_list[] = array(); foreach ($notepads as $id => $notepad) { - $text .= sprintf('%s', - '_notepad_' . $id, - Horde_Text_Filter::filter($notepad->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)), - "\n"); + $notepad_list[] = array( + 'l' => Horde_Text_Filter::filter($notepad->get('name'), 'space2html', array('charset' => Horde_Nls::getCharset(), 'encode' => true)), + 'v' => '_notepad_' . $id + ); } + $t->set('notepad', $notepad_list); } } catch (Horde_Exception $e) {} } - return $text; + return $t->fetch(IMP_TEMPLATES . '/imp/flist/flist.html'); } /** diff --git a/imp/templates/imp/flist/flist.html b/imp/templates/imp/flist/flist.html new file mode 100644 index 000000000..36a932079 --- /dev/null +++ b/imp/templates/imp/flist/flist.html @@ -0,0 +1,31 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + -- 2.11.0