#1307935 closed Bugs (Fixed)
Folder Structure in GUI would make life easier
| Reported by: | dolittle | Owned by: | roundcube |
|---|---|---|---|
| Priority: | 5 | Milestone: | |
| Component: | Client Scripts | Version: | None |
| Severity: | Keywords: | ||
| Cc: |
Description
Create a tree style view of the folder list instead of
a long list..
The following code, which isn't optimal, will generate
an arrayed hash of the folder structure... limitations
... only up to 4 levels deep are supported, the use of
"ROOT" as a base item isn't necessary...
Also I didn't know how to convert the below folder
structure into the viewable GUI... please proceed...
this is one of the features most (in my opinion)
missing from RoundCube.
$foldernames = array();
foreach ($a_folders as $i => $folder)
{
$currentsubfolder = $folder;
$item = array();
while (preg_match('/^([^\.]+)\.(.*)/',
$currentsubfolder, $matches))
{ // Current folder is a child...
array_push($item, $matches[1]);
$currentsubfolder = $matches[2];
}
if ($currentsubfolder != "")
{
array_push($item, $currentsubfolder);
}
if (count($item) == 0)
{
$item = array("$folder");
}
if (array_key_exists($item[0], $foldernames))
{ // Parent folder already inside array
if (count($item) == 2)
{
$foldernames["$item[0]"]["$item[1]"] =
array("ROOT" => "N/A");
}
if (count($item) == 3)
{
$foldernames["$item[0]"]["$item[1]"]["$item[2]"] =
array("ROOT" => "N/A");
}
if (count($item) == 4)
{
$foldernames["$item[0]"]["$item[1]"]["$item[2]"]["$item[3]"]
= array("ROOT" => "N/A");
}
}
else
{
if (count($item) == 1)
{
$foldernames["$item[0]"] = array("ROOT" => "N/A");
}
else
{
$foldernames["$item[0]"] = array("ROOT" => $item[1]);
}
}
}
print "<PRE>";
print_r($foldernames);
print "</PRE>";
Change History (5)
comment:1 Changed 8 years ago by dolittle
comment:2 Changed 8 years ago by rpoulton
Logged In: YES user_id=19991 the code in dolittle's comment works perfectly, and presents the folders exactly how I like seeing them. Looks MUCH better, thank you dolittle.
comment:3 Changed 8 years ago by dolittle
- Summary changed from Folder Strucutre in GUI would make life easier to Folder Structure in GUI would make life easier
comment:4 Changed 8 years ago by rpoulton
Logged In: YES user_id=19991 The latest version of RoundCube, v0.1-20051007, has cleaned up the folder list considerably. This should render this bug closed as the query has been addressed.
comment:5 Changed 8 years ago by roundcube
- Status changed from assigned to closed
Note: See
TracTickets for help on using
tickets.

Logged In: YES user_id=116044 I found a workaround which is easier to implement, it creates a "hierachy" of folders (from line 107): $tempfolder = $folder; $Depth = 0; while (preg_match('/^([^.]+)\.(.*)/', $tempfolder, $matches)) { $Depth ++; $tempfolder = $matches[2]; } if ($Depth) $foldername_subed = $tempfolder; else $foldername_subed = $folder; $Depth_stringed = ""; for ($i = 0; $i < $Depth; $i ++) { $Depth_stringed .= " "; } $out .= sprintf('<li class="mailbox %s %s%s%s"><a href="#%s" onclick="return %s.command(\'list\',\'%s\')" onmouseup="return %s.mbox_mouse_up(\'%s\')">%s%s</a></li>'."\n", preg_replace('/[^a-z0-9\-_]/', '', $folder_lc), $zebra_class, $unread_count ? ' unread' : '', $folder==$mbox ? ' selected' : '', $folder, $JS_OBJECT_NAME, $folder, $JS_OBJECT_NAME, $folder, $Depth_stringed, rep_specialchars_output($foldername_subed)); }