Changeset 3e8bd7af in github


Ignore:
Timestamp:
Sep 12, 2008 7:29:12 AM (5 years ago)
Author:
thomascube <thomas@…>
Branches:
master, HEAD, courier-fix, dev-browser-capabilities, pdo, release-0.6, release-0.7, release-0.8
Children:
e5686f4
Parents:
9770fe5c
Message:

Insert virtual folders in subscription list (#1484779) + code cleanup

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • CHANGELOG

    r94e4be5 r3e8bd7af  
    11CHANGELOG RoundCube Webmail 
    22--------------------------- 
     3 
     42008/09/12 (thomasb) 
     5---------- 
     6- Refactor drag & drop functionality. Don't rely on browser events anymore (#1484453) 
     7- Insert "virtual" folders in subscription list (#1484779) 
    38 
    492008/09/05 (thomasb) 
  • program/steps/settings/manage_folders.inc

    r6eaac22 r3e8bd7af  
    9797      if (preg_match($regexp, $folderlist[$x])) 
    9898        { 
    99         $oldfolder = $oldname . $delimiter . preg_replace($regexp, '', $folderlist[$x]); 
     99        $oldfolder = $oldname . $delimiter . preg_replace($regexp, '', $folderlist[$x]); 
    100100        $foldersplit = explode($delimiter, $folderlist[$x]); 
    101101        $level = count($foldersplit) - 1; 
    102102        $display_rename = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $level)  
    103             . rcube_charset_convert($foldersplit[$level], 'UTF-7'); 
    104  
    105         $before = isset($folderlist[$x+1]) ? rcube_charset_convert($folderlist[$x+1], 'UTF-7') : false; 
     103          . rcube_charset_convert($foldersplit[$level], 'UTF-7'); 
     104 
     105        $before = isset($folderlist[$x+1]) ? rcube_charset_convert($folderlist[$x+1], 'UTF-7') : false; 
    106106         
    107         $OUTPUT->command('replace_folder_row', rcube_charset_convert($oldfolder, 'UTF-7'), 
    108             rcube_charset_convert($folderlist[$x], 'UTF-7'), $display_rename, $before); 
     107        $OUTPUT->command('replace_folder_row', rcube_charset_convert($oldfolder, 'UTF-7'), 
     108          rcube_charset_convert($folderlist[$x], 'UTF-7'), $display_rename, $before); 
    109109        } 
    110110      } 
     
    116116    $before = $index !== false && isset($folderlist[$index+1]) ? rcube_charset_convert($folderlist[$index+1], 'UTF-7') : false; 
    117117 
    118     $OUTPUT->command('replace_folder_row', $oldname_utf8, rcube_charset_convert($rename, 'UTF-7'), 
    119         $display_rename, $before); 
     118    $OUTPUT->command('replace_folder_row', $oldname_utf8, rcube_charset_convert($rename, 'UTF-7'), $display_rename, $before); 
    120119 
    121120    $OUTPUT->command('reset_folder_rename'); 
     
    175174    $attrib['id'] = 'rcmSubscriptionlist'; 
    176175 
    177   // allow the following attributes to be added to the <table> tag 
    178   $attrib_str = create_attrib_string($attrib, array('style', 'class', 'id', 'cellpadding', 'cellspacing', 'border', 'summary')); 
    179  
    180   $out = "$form_start\n<table" . $attrib_str . ">\n"; 
    181  
     176  $table = new html_table(); 
    182177 
    183178  // add table header 
    184   $out .= "<thead><tr>\n"; 
    185   $out .= sprintf('<td class="name">%s</td><td class="msgcount">%s</td><td class="subscribed">%s</td>'. 
    186                   '<td class="rename">&nbsp;</td><td class="delete">&nbsp;</td>', 
    187                   rcube_label('foldername'), rcube_label('messagecount'), rcube_label('subscribed')); 
    188                    
    189   $out .= "\n</tr></thead>\n<tbody>\n"; 
     179  $table->add_header('name', rcube_label('foldername')); 
     180  $table->add_header('msgcount', rcube_label('messagecount')); 
     181  $table->add_header('subscribed', rcube_label('subscribed')); 
     182  $table->add_header('rename', '&nbsp;'); 
     183  $table->add_header('delete', '&nbsp;'); 
    190184 
    191185 
     
    196190  $a_subscribed = $IMAP->list_mailboxes(); 
    197191  $delimiter = $IMAP->get_hierarchy_delimiter(); 
    198   $a_js_folders = array(); 
    199  
    200   $checkbox_subscribe = new html_checkbox(array('name' => '_subscribed[]', 'onclick' => JS_OBJECT_NAME.".command(this.checked?'subscribe':'unsubscribe',this.value)")); 
     192  $a_js_folders = $seen_folders = $list_folders = array(); 
     193   
     194  // pre-process folders list 
     195  foreach ($a_unsubscribed as $i => $folder) { 
     196    $foldersplit = explode($delimiter, $folder); 
     197    $name = rcube_charset_convert(array_pop($foldersplit), 'UTF-7'); 
     198    $parent_folder = join($delimiter, $foldersplit); 
     199    $level = count($foldersplit); 
     200     
     201    // add a "virtual" parent folder 
     202    if ($parent_folder && !$seen[$parent_folder]++) { 
     203      $parent_name = rcube_charset_convert($foldersplit[$level-1], 'UTF-7'); 
     204      $list_folders[] = array('id' => $parent_folder, 'name' => $parent_name, 'level' => $level-1, 'virtual' => true); 
     205    } 
     206     
     207    $list_folders[] = array('id' => $folder, 'name' => $name, 'level' => $level); 
     208    $seen[$folder]++; 
     209  } 
     210 
     211  $checkbox_subscribe = new html_checkbox(array( 
     212    'name' => '_subscribed[]', 
     213    'onclick' => JS_OBJECT_NAME.".command(this.checked?'subscribe':'unsubscribe',this.value)", 
     214  )); 
    201215   
    202216  if (!empty($attrib['deleteicon'])) 
    203     $del_button = sprintf('<img src="%s%s" alt="%s" border="0" />', $CONFIG['skin_path'], $attrib['deleteicon'], rcube_label('delete')); 
     217    $del_button = html::img(array('src' => $CONFIG['skin_path'] . $attrib['deleteicon'], 'alt' => rcube_label('delete'), 'border' => 0)); 
    204218  else 
    205219    $del_button = rcube_label('delete'); 
    206220 
    207221  if (!empty($attrib['renameicon'])) 
    208     $edit_button = sprintf('<img src="%s%s" alt="%s" border="0" />', $CONFIG['skin_path'], $attrib['renameicon'], rcube_label('rename')); 
     222    $edit_button = html::img(array('src' => $CONFIG['skin_path'] . $attrib['renameicon'], 'alt' => rcube_label('rename'), 'border' => 0)); 
    209223  else 
    210224    $del_button = rcube_label('rename'); 
    211  
     225     
    212226  // create list of available folders 
    213   foreach ($a_unsubscribed as $i => $folder) 
    214     { 
    215     $subscribed = in_array($folder, $a_subscribed); 
    216     $protected = ($CONFIG['protect_default_folders'] == TRUE && in_array($folder,$CONFIG['default_imap_folders'])); 
    217     $zebra_class = $i%2 ? 'even' : 'odd'; 
    218     $folder_js = JQ($folder); 
    219     $foldersplit = explode($delimiter, $folder); 
    220     $level = count($foldersplit) - 1; 
    221     $display_folder = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $level) . rcube_charset_convert($foldersplit[$level], 'UTF-7'); 
    222     $folder_html = $CONFIG['protect_default_folders'] && in_array($folder, $CONFIG['default_imap_folders']) ? rcmail_localize_foldername($folder) : $display_folder; 
    223     $folder_utf8 = rcube_charset_convert($folder, 'UTF-7'); 
    224  
    225     $a_js_folders['rcmrow'.($i+1)] = array($folder_utf8, $display_folder, $protected); 
    226  
    227     $out .= sprintf('<tr id="rcmrow%d" class="%s"><td class="name">%s</td><td class="msgcount">%d</td>', 
    228                     $i+1, 
    229                     $zebra_class, 
    230                     Q($folder_html), 
    231                     $IMAP->messagecount($folder)); 
    232                      
    233     if ($protected) 
    234       $out .= '<td class="subscribed">&nbsp;'.($subscribed ? '&#x2022;' : '-').'</td>'; 
    235     else 
    236       $out .= '<td class="subscribed">'.$checkbox_subscribe->show($subscribed?$folder_utf8:'', array('value' => $folder_utf8)).'</td>'; 
    237  
     227  foreach ($list_folders as $i => $folder) { 
     228    $idx = $i + 1; 
     229    $subscribed = in_array($folder['id'], $a_subscribed); 
     230    $protected = ($folder['virtual'] || ($CONFIG['protect_default_folders'] == true && in_array($folder['id'], $CONFIG['default_imap_folders']))); 
     231    $classes = array($i%2 ? 'even' : 'odd'); 
     232    $folder_js = JQ($folder['id']); 
     233    $display_folder = str_repeat('&nbsp;&nbsp;&nbsp;&nbsp;', $folder['level']) . ($protected ? rcmail_localize_foldername($folder['id']) : $folder['name']); 
     234    $folder_utf8 = rcube_charset_convert($folder['id'], 'UTF-7'); 
     235     
     236    if ($folder['virtual']) 
     237      $classes[] = 'virtual'; 
     238     
     239    $table->add_row(array('id' => 'rcmrow'.$idx, 'class' => join(' ', $classes))); 
     240     
     241    $table->add('name', Q($display_folder)); 
     242    $table->add('msgcount', ($folder['virtual'] ? '' : $IMAP->messagecount($folder['id']))); 
     243    $table->add('subscribed', $protected ? ($subscribed ? '&nbsp;&#x2022;' : '&nbsp;-') : 
     244        $checkbox_subscribe->show(($subscribed ? $folder_utf8 : ''), array('value' => $folder_utf8))); 
     245     
    238246    // add rename and delete buttons 
    239     if (!$protected) 
    240       $out .= sprintf('<td class="rename"><a href="#rename" title="%s">%s</a>'. 
    241                       '<td class="delete"><a href="#delete" title="%s">%s</a></td>', 
    242                       rcube_label('renamefolder'), 
    243                       $edit_button, 
    244                       rcube_label('deletefolder'), 
    245                       $del_button); 
    246     else 
    247       $out .= '<td></td><td></td>'; 
    248      
    249     $out .= "</tr>\n"; 
    250     } 
    251  
    252   $out .= "</tbody>\n</table>"; 
    253   $out .= "\n$form_end"; 
     247    if (!$protected) { 
     248      $table->add('rename', html::a(array('href' => "#rename", 'title' => rcube_label('renamefolder')), $edit_button)); 
     249      $table->add('delete', html::a(array('href' => "#delete", 'title' => rcube_label('deletefolder')), $del_button)); 
     250    } 
     251    else { 
     252      $table->add(null, ''); 
     253      $table->add(null, ''); 
     254    } 
     255     
     256    $a_js_folders['rcmrow'.$idx] = array($folder_utf8, $display_folder, $protected); 
     257  } 
     258 
    254259 
    255260  $OUTPUT->add_gui_object('subscriptionlist', $attrib['id']); 
     
    258263  $OUTPUT->set_env('delimiter', $delimiter); 
    259264 
    260   return $out;   
     265  return $form_start . $table->show($attrib) . $form_end; 
    261266  } 
    262267 
  • skins/default/settings.css

    r1996d8f r3e8bd7af  
    162162#subscription-table tbody td 
    163163{ 
    164   height: 16px; 
     164  height: 20px; 
    165165  padding-left: 6px; 
    166166  padding-right: 10px; 
     
    171171} 
    172172 
     173#subscription-table tr.virtual td 
     174{ 
     175  color: #666; 
     176} 
     177 
    173178#subscription-table tr.selected td, 
    174179#subscription-table tr.selected td a 
Note: See TracChangeset for help on using the changeset viewer.