further improvements on folder tree

This commit is contained in:
Klaus Leithoff 2013-02-12 14:30:58 +00:00
parent 734f495039
commit a24508fa34
3 changed files with 33 additions and 54 deletions

View File

@ -267,11 +267,13 @@ class mail_ui
/** /**
* getFolderTree, get folders from server and prepare the folder tree * getFolderTree, get folders from server and prepare the folder tree
* @param bool $_fetchCounters, wether to fetch extended information on folders * @param bool $_fetchCounters, wether to fetch extended information on folders
* @return array something like that: array( * @return array something like that: array('id'=>0,
* '/INBOX'=>array('label'=>'INBOX','title'=>'INBOX','image'=>'kfm_home.png'), * 'item'=>array(
* '/INBOX/sub'=>array('label'=>'sub','title'=>'INBOX/sub'), * 'text'=>'INBOX',
* '/user' => array('label' => 'user'), * 'tooltip'=>'INBOX'.' '.lang('(not connected)'),
* '/user/birgit' => 'birgit', * 'im0'=>'kfm_home.png'
* 'item'=>array($MORE_ITEMS)
* )
* ); * );
*/ */
function getFolderTree($_fetchCounters=false) function getFolderTree($_fetchCounters=false)
@ -286,8 +288,9 @@ class mail_ui
if (isset($sentFolder) && $sentFolder != 'none') $userDefinedFunctionFolders['Sent'] = $sentFolder; if (isset($sentFolder) && $sentFolder != 'none') $userDefinedFunctionFolders['Sent'] = $sentFolder;
if (isset($draftFolder) && $draftFolder != 'none') $userDefinedFunctionFolders['Drafts'] = $draftFolder; if (isset($draftFolder) && $draftFolder != 'none') $userDefinedFunctionFolders['Drafts'] = $draftFolder;
if (isset($templateFolder) && $templateFolder != 'none') $userDefinedFunctionFolders['Templates'] = $templateFolder; if (isset($templateFolder) && $templateFolder != 'none') $userDefinedFunctionFolders['Templates'] = $templateFolder;
_debug_array($folderObjects); //_debug_array($folderObjects);
$out = array('id' => 0); $out = array('id' => 0);
$c = 0;
foreach($folderObjects as $key => $obj) foreach($folderObjects as $key => $obj)
{ {
$fS = $this->mail_bo->getFolderStatus($key,false,($_fetchCounters?false:true)); $fS = $this->mail_bo->getFolderStatus($key,false,($_fetchCounters?false:true));
@ -300,25 +303,25 @@ class mail_ui
// the rest of the array is the name of the parent // the rest of the array is the name of the parent
$parentName = implode((array)$folderParts,$obj->delimiter); $parentName = implode((array)$folderParts,$obj->delimiter);
$path = $obj->folderName; //$obj->delimiter $path = $key; //$obj->folderName; //$obj->delimiter
$oA =array('text'=> $obj->shortDisplayName, 'tooltip'=> $obj->displayName); $oA =array('text'=> $obj->shortDisplayName, 'tooltip'=> $obj->displayName);
$oA['path'] = $fFP; $oA['path'] = $fFP;
if ($fS['unseen']) $oA['text'] = '<b>'.$oA['text'].' ('.$fS['unseen'].')</b>'; if ($fS['unseen']) $oA['text'] = '<b>'.$oA['text'].' ('.$fS['unseen'].')</b>';
if ($path=='INBOX') if ($path=='INBOX')
{ {
$oA['im0'] = 'kfm_home.png'; $oA['im0'] = $oA['im1']= $oA['im2'] = "kfm_home.png";
} }
elseif (in_array($obj->shortFolderName,mail_bo::$autoFolders)) elseif (in_array($obj->shortFolderName,mail_bo::$autoFolders))
{ {
//echo $obj->shortFolderName.'<br>'; //echo $obj->shortFolderName.'<br>';
$oA['im0'] = "MailFolder".$obj->shortFolderName.".png"; $oA['im0'] = $oA['im1']= $oA['im2'] = "MailFolder".$obj->shortFolderName.".png";
//$image2 = "'MailFolderPlain.png'"; //$image2 = "'MailFolderPlain.png'";
//$image3 = "'MailFolderPlain.png'"; //$image3 = "'MailFolderPlain.png'";
} }
elseif (in_array($key,$userDefinedFunctionFolders)) elseif (in_array($key,$userDefinedFunctionFolders))
{ {
$_key = array_search($key,$userDefinedFunctionFolders); $_key = array_search($key,$userDefinedFunctionFolders);
$oA['im0'] = "MailFolder".$_key.".png"; $oA['im0'] = $oA['im1']= $oA['im2'] = "MailFolder".$_key.".png";
} }
else else
{ {
@ -332,18 +335,23 @@ class mail_ui
$oA['child']=1; // translates to: hasChildren -> dynamicLoading $oA['child']=1; // translates to: hasChildren -> dynamicLoading
} }
$oA['parent'] = $parentName; $oA['parent'] = $parentName;
//$out[] = $oA;
$this->setOutStructure($oA,$out,$obj->delimiter); $this->setOutStructure($oA,$out,$obj->delimiter);
$c++;
} }
//$structuredOut = array('id'=>0, 'item'=>$out); return ($c?$out:array('id'=>0, 'item'=>array('text'=>'INBOX','tooltip'=>'INBOX'.' '.lang('(not connected)'),'im0'=>'kfm_home.png')));
_debug_array($out);
return $out;
return (isset($out)?$structuredOut:array('id'=>0, 'item'=>array('text'=>'INBOX','tooltip'=>'INBOX'.' '.lang('(not connected)'),'im0'=>'kfm_home.png')));
} }
/**
* setOutStructure - helper function to transform the folderObjectList to dhtmlXTreeObject requirements
*
* @param array $data, data to be processed
* @param array &$out, out array
* @param string $del='.', needed as glue for parent/child operation / comparsion
* @return void
*/
function setOutStructure($data, &$out, $del='.') function setOutStructure($data, &$out, $del='.')
{ {
error_log(__METHOD__."(".array2string($data).', '.array2string($out).", '$del')"); //error_log(__METHOD__."(".array2string($data).', '.array2string($out).", '$del')");
$components = $data['path']; $components = $data['path'];
array_pop($components); // remove own name array_pop($components); // remove own name
@ -353,21 +361,21 @@ class mail_ui
{ {
$parent = implode($del, $parents); $parent = implode($del, $parents);
if ($parent) $parent .= $del; if ($parent) $parent .= $del;
if (!is_array($insert) || !isset($insert['item'])) throw new Exception("1. id=$data[id]: Parent '$parent' '$component' not found! out=".array2string($out)); if (!is_array($insert) || !isset($insert['item'])) throw new egw_exception_assertion_failed(__METHOD__.':'.__LINE__." id=$data[id]: Parent '$parent' '$component' not found! out=".array2string($out));
foreach($insert['item'] as $key => &$item) foreach($insert['item'] as &$item)
{ {
if ($item['id'] == $parent.$component) if ($item['id'] == $parent.$component)
{ {
$insert =& $item;//$insert['item'][$key]; $insert =& $item;
break; break;
} }
} }
if ($item['id'] != $parent.$component) {_debug_array($out); exit;}//throw new Exception("2. id=$data[id]: Parent '$parent' '$component' not found!"); if ($item['id'] != $parent.$component) throw new egw_exception_assertion_failed(__METHOD__.':'.__LINE__.": id=$data[id]: Parent '$parent' '$component' not found!");
$parents[] = $component; $parents[] = $component;
} }
unset($data['path']); unset($data['path']);
$insert['item'][] = $data; $insert['item'][] = $data;
error_log(__METHOD__."() leaving with out=".array2string($out)); //error_log(__METHOD__."() leaving with out=".array2string($out));
} }
/** /**
@ -1138,7 +1146,7 @@ error_log(__METHOD__.__LINE__.array2string($query));
} }
if (in_array("size", $cols)) if (in_array("size", $cols))
$data["size"] = self::show_readable_size($header['size']); /// size $data["size"] = $header['size']; /// size
/* /*
@ -1157,33 +1165,4 @@ error_log(__METHOD__.__LINE__.array2string($query));
return $rv; return $rv;
} }
/**
* Returns a string showing the size of the message/attachment
* @param int $bytes
* @param string mode (not used)
* @return string ($bytes $type)
*/
static function show_readable_size($bytes, $_mode='short')
{
$bytes /= 1024;
$type = 'k';
if ($bytes / 1024 > 1)
{
$bytes /= 1024;
$type = 'M';
}
if ($bytes < 10)
{
$bytes *= 10;
settype($bytes, 'integer');
$bytes /= 10;
}
else
settype($bytes, 'integer');
return $bytes . ' ' . $type ;
}
} }

View File

@ -2,7 +2,7 @@
/** /**
* EGroupware - eTemplates for Application mail * EGroupware - eTemplates for Application mail
* http://www.egroupware.org * http://www.egroupware.org
* generated by soetemplate::dump4setup() 2013-02-11 17:16 * generated by soetemplate::dump4setup() 2013-02-12 15:25
* *
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License * @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
* @package mail * @package mail
@ -14,7 +14,7 @@ $templ_version=1;
$templ_data[] = array('name' => 'mail.index','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:2:{i:0;a:3:{s:4:"type";s:4:"tree";s:4:"name";s:14:"nm[foldertree]";s:7:"onclick";s:39:"alert(\'on Changen node=\'+arguments[0]);";}i:1;a:3:{s:4:"type";s:9:"nextmatch";s:4:"name";s:2:"nm";s:4:"size";s:4:"rows";}}','size' => '100%,,,,0,3','style' => '','modified' => '1360577272',); $templ_data[] = array('name' => 'mail.index','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:2:{i:0;a:3:{s:4:"type";s:4:"tree";s:4:"name";s:14:"nm[foldertree]";s:7:"onclick";s:39:"alert(\'on Changen node=\'+arguments[0]);";}i:1;a:3:{s:4:"type";s:9:"nextmatch";s:4:"name";s:2:"nm";s:4:"size";s:4:"rows";}}','size' => '100%,,,,0,3','style' => '','modified' => '1360577272',);
$templ_data[] = array('name' => 'mail.index.rows','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:6:{s:2:"c1";s:2:"th";s:1:"A";s:2:"25";s:1:"F";s:2:"50";s:1:"E";s:3:"120";s:1:"D";s:3:"120";s:1:"C";s:2:"95";}i:1;a:6:{s:1:"A";a:4:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:2:"ID";s:4:"name";s:3:"uid";s:8:"readonly";s:1:"1";}s:1:"B";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:4:"name";s:7:"subject";s:5:"label";s:7:"subject";}s:1:"C";a:4:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"date";s:4:"name";s:4:"date";s:5:"align";s:6:"center";}s:1:"D";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:2:"to";s:4:"name";s:9:"toaddress";}s:1:"E";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"from";s:4:"name";s:11:"fromaddress";}s:1:"F";a:4:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"size";s:4:"name";s:4:"size";s:5:"align";s:6:"center";}}i:2;a:6:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"name";s:11:"${row}[uid]";s:8:"readonly";s:1:"1";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:4:"name";s:15:"${row}[subject]";}s:1:"C";a:4:{s:4:"type";s:9:"date-time";s:4:"name";s:12:"${row}[date]";s:8:"readonly";s:1:"1";s:5:"align";s:6:"center";}s:1:"D";a:3:{s:4:"type";s:9:"url-email";s:4:"name";s:17:"${row}[toaddress]";s:8:"readonly";s:1:"1";}s:1:"E";a:3:{s:4:"type";s:9:"url-email";s:4:"name";s:19:"${row}[fromaddress]";s:8:"readonly";s:1:"1";}s:1:"F";a:5:{s:4:"type";s:5:"label";s:4:"name";s:12:"${row}[size]";s:7:"no_lang";s:1:"1";s:8:"readonly";s:1:"1";s:5:"align";s:5:"right";}}}s:4:"rows";i:2;s:4:"cols";i:6;}}','size' => '','style' => '','modified' => '1360252030',); $templ_data[] = array('name' => 'mail.index.rows','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:3:{i:0;a:6:{s:2:"c1";s:2:"th";s:1:"A";s:2:"25";s:1:"F";s:2:"50";s:1:"E";s:3:"120";s:1:"D";s:3:"120";s:1:"C";s:2:"95";}i:1;a:6:{s:1:"A";a:4:{s:4:"type";s:16:"nextmatch-header";s:5:"label";s:2:"ID";s:4:"name";s:3:"uid";s:8:"readonly";s:1:"1";}s:1:"B";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:4:"name";s:7:"subject";s:5:"label";s:7:"subject";}s:1:"C";a:4:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"date";s:4:"name";s:4:"date";s:5:"align";s:6:"center";}s:1:"D";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:2:"to";s:4:"name";s:9:"toaddress";}s:1:"E";a:3:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"from";s:4:"name";s:11:"fromaddress";}s:1:"F";a:4:{s:4:"type";s:20:"nextmatch-sortheader";s:5:"label";s:4:"size";s:4:"name";s:4:"size";s:5:"align";s:6:"center";}}i:2;a:6:{s:1:"A";a:3:{s:4:"type";s:5:"label";s:4:"name";s:11:"${row}[uid]";s:8:"readonly";s:1:"1";}s:1:"B";a:2:{s:4:"type";s:5:"label";s:4:"name";s:15:"${row}[subject]";}s:1:"C";a:4:{s:4:"type";s:9:"date-time";s:4:"name";s:12:"${row}[date]";s:8:"readonly";s:1:"1";s:5:"align";s:6:"center";}s:1:"D";a:3:{s:4:"type";s:9:"url-email";s:4:"name";s:17:"${row}[toaddress]";s:8:"readonly";s:1:"1";}s:1:"E";a:3:{s:4:"type";s:9:"url-email";s:4:"name";s:19:"${row}[fromaddress]";s:8:"readonly";s:1:"1";}s:1:"F";a:5:{s:4:"type";s:8:"vfs-size";s:4:"name";s:12:"${row}[size]";s:7:"no_lang";s:1:"1";s:8:"readonly";s:1:"1";s:5:"align";s:5:"right";}}}s:4:"rows";i:2;s:4:"cols";i:6;}}','size' => '','style' => '','modified' => '1360252030',);
$templ_data[] = array('name' => 'mail.TestConnection','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:1;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1360585356',); $templ_data[] = array('name' => 'mail.TestConnection','template' => '','lang' => '','group' => '0','version' => '1.9.001','data' => 'a:1:{i:0;a:4:{s:4:"type";s:4:"grid";s:4:"data";a:2:{i:0;a:0:{}i:1;a:1:{s:1:"A";a:1:{s:4:"type";s:5:"label";}}}s:4:"rows";i:1;s:4:"cols";i:1;}}','size' => '','style' => '','modified' => '1360585356',);

View File

@ -26,7 +26,7 @@
<date-time align="center" id="${row}[date]" readonly="true"/> <date-time align="center" id="${row}[date]" readonly="true"/>
<url-email id="${row}[toaddress]" readonly="true"/> <url-email id="${row}[toaddress]" readonly="true"/>
<url-email id="${row}[fromaddress]" readonly="true"/> <url-email id="${row}[fromaddress]" readonly="true"/>
<description align="right" id="${row}[size]" no_lang="1" readonly="true"/> <vfs-size align="right" id="${row}[size]" no_lang="1" readonly="true"/>
</row> </row>
</rows> </rows>
</grid> </grid>