setting foldernames now as text and (optional) style

This commit is contained in:
Ralf Becker 2014-02-05 12:23:04 +00:00
parent 8e35567e6a
commit 92701be185
4 changed files with 67 additions and 61 deletions

View File

@ -88,11 +88,7 @@ class etemplate_widget_tree extends etemplate_widget
{ {
$item['text'] = html::htmlspecialchars($item['text']); $item['text'] = html::htmlspecialchars($item['text']);
if (!empty($item['tooltip'])) if (isset($item['item']) && is_array($item['item']))
{
$item['tooltip'] = html::htmlspecialchars($item['tooltip']);
}
if ($item['child'] && isset($item['item']) && is_array($item['item']))
{ {
foreach($item['item'] as &$child) foreach($item['item'] as &$child)
{ {

View File

@ -268,7 +268,7 @@ var et2_tree = et2_inputWidget.extend(
// Item color - not working // Item color - not working
if(options[key].data && typeof options[key].data.color !== 'undefined' && options[key].data.color) if(options[key].data && typeof options[key].data.color !== 'undefined' && options[key].data.color)
{ {
options[key].style = options[key].style || "" + "background-color ='"+options[key].data.color+"';"; options[key].style = options[key].style || "" + "background-color:'"+options[key].data.color+"';";
} }
// Tooltip // Tooltip
@ -309,28 +309,39 @@ var et2_tree = et2_inputWidget.extend(
}, },
/** /**
* Regexp used by _htmlencode_node * Regexp used by _htmlencode
*/ */
_lt_regexp: /</g, _lt_regexp: /</g,
/** /**
* Minimal html encoding of text and tooltip of node incl. all children * html encoding of text of node
* *
* @param {object} _item with required attributes text, id and optional tooltip, child and item * We only do a minimal html encoding by replacing opening bracket < with &lt;
* as tree seems not to need more and we dont want to waste time.
*
* @param {string} _text text to encode
* @return {string}
*/
_htmlencode: function(_text)
{
if (_text && _text.indexOf('<') >= 0)
{
_text = _text.replace(this._lt_regexp, '&lt;');
}
return _text;
},
/**
* html encoding of text of node incl. all children
*
* @param {object} _item with required attributes text, id and optional tooltip and item
* @return {object} encoded node * @return {object} encoded node
*/ */
_htmlencode_node: function(_item) _htmlencode_node: function(_item)
{ {
// htmlencode text and tooltip _item.text = this._htmlencode(_item.text);
if (_item.text && _item.text.indexOf('<') >= 0)
{ if (_item.item && jQuery.isArray(_item.item))
_item.text = _item.text.replace(this._lt_regexp, '&lt;');
}
if (_item.tooltip && _item.tooltip.indexOf('<') >= 0)
{
_item.tooltip = _item.tooltip.replace(this._lt_regexp, '&lt;');
}
if (_item.child && jQuery.isArray(_item.item))
{ {
for(var i=0; i < _item.item.length; ++i) for(var i=0; i < _item.item.length; ++i)
{ {
@ -469,7 +480,7 @@ var et2_tree = et2_inputWidget.extend(
} }
} }
if (typeof _label != 'undefined') this.input.setItemText(_newItemId,_label); if (typeof _label != 'undefined') this.setLabel(_newItemId, _label);
}, },
/** /**
@ -602,14 +613,27 @@ var et2_tree = et2_inputWidget.extend(
}, },
/** /**
* setLabel, sets the Label of of an item by id * Sets label of an item by id
*
* @param _id ID of the node * @param _id ID of the node
* @param _label label to set * @param _label label to set
* @return void * @return void
*/ */
setLabel: function(_id, _label) { setLabel: function(_id, _label) {
if(this.input == null) return null; if(this.input == null) return null;
this.input.setItemText(_id,_label); this.input.setItemText(_id, this._htmlencode(_label));
},
/**
* Sets a style for an item by id
*
* @param {string} _id ID of node
* @param {string} _style style to set
* @return void
*/
setStyle: function(_id, _style) {
if(this.input == null) return null;
this.input.setItemStyle(_id, _style);
}, },
/** /**

View File

@ -585,9 +585,7 @@ class mail_ui
$data = $this->getFolderTree($fetchCounters, $nodeID, $subscribedOnly); $data = $this->getFolderTree($fetchCounters, $nodeID, $subscribedOnly);
//error_log(__METHOD__.__LINE__.':'.$nodeID.'->'.array2string($data)); //error_log(__METHOD__.__LINE__.':'.$nodeID.'->'.array2string($data));
if (!is_null($_nodeID)) return $data; if (!is_null($_nodeID)) return $data;
header('Content-Type: application/json; charset=utf-8'); etemplate_widget_tree::send_quote_json($data);
echo json_encode($data);
common::egw_exit();
} }
/** /**
@ -640,7 +638,7 @@ class mail_ui
if ($_profileID && $acc_id != $_profileID) continue; if ($_profileID && $acc_id != $_profileID) continue;
$oA = array('id' => $acc_id, $oA = array('id' => $acc_id,
'text' => str_replace(array('<','>'),array('[',']'),$identity_name),// htmlspecialchars($identity_name), 'text' => $identity_name,// htmlspecialchars($identity_name),
'tooltip' => '('.$acc_id.') '.htmlspecialchars_decode($identity_name), 'tooltip' => '('.$acc_id.') '.htmlspecialchars_decode($identity_name),
'im0' => 'thunderbird.png', 'im0' => 'thunderbird.png',
'im1' => 'thunderbird.png', 'im1' => 'thunderbird.png',
@ -710,7 +708,11 @@ class mail_ui
$oA['im1'] = "folderOpen.gif"; $oA['im1'] = "folderOpen.gif";
$oA['im2'] = "MailFolderClosed.png"; // has Children $oA['im2'] = "MailFolderClosed.png"; // has Children
} }
if ($fS['unseen']) $oA['text'] = '<b>'.$oA['text'].' ('.$fS['unseen'].')</b>'; if ($fS['unseen'])
{
$oA['text'] = $oA['text'].' ('.$fS['unseen'].')';
$oA['style'] = 'font-weight: bold';
}
$path = $this->mail_bo->profileID.self::$delimiter.$key; //$obj->folderName; //$obj->delimiter $path = $this->mail_bo->profileID.self::$delimiter.$key; //$obj->folderName; //$obj->delimiter
$oA['id'] = $path; // ID holds the PATH $oA['id'] = $path; // ID holds the PATH
if (!empty($fS['attributes']) && stripos(array2string($fS['attributes']),'\noselect')!== false) if (!empty($fS['attributes']) && stripos(array2string($fS['attributes']),'\noselect')!== false)
@ -3253,12 +3255,11 @@ blockquote[type=cite] {
//error_log(__METHOD__.__LINE__.array2string($fS)); //error_log(__METHOD__.__LINE__.array2string($fS));
if ($fS['unseen']) if ($fS['unseen'])
{ {
$oA[$_folderName] = '<b>'.$fS['shortDisplayName'].' ('.$fS['unseen'].')</b>'; $oA[$_folderName] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
} }
if ($fS['unseen']==0 && $fS['shortDisplayName']) if ($fS['unseen']==0 && $fS['shortDisplayName'])
{ {
$oA[$_folderName] = $fS['shortDisplayName']; $oA[$_folderName] = $fS['shortDisplayName'];
} }
} }
} }
@ -3427,7 +3428,7 @@ blockquote[type=cite] {
$oA[$_folderName]['olddesc'] = $oldFolderInfo['shortDisplayName']; $oA[$_folderName]['olddesc'] = $oldFolderInfo['shortDisplayName'];
if ($fS['unseen']) if ($fS['unseen'])
{ {
$oA[$_folderName]['desc'] = '<b>'.$fS['shortDisplayName'].' ('.$fS['unseen'].')</b>'; $oA[$_folderName]['desc'] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
} }
else else
@ -3442,7 +3443,7 @@ blockquote[type=cite] {
$fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment,false); $fS = $this->mail_bo->getFolderStatus($newFolderName.$fragment,false);
if ($fS['unseen']) if ($fS['unseen'])
{ {
$oA[$oldFolderName]['desc'] = '<b>'.$fS['shortDisplayName'].' ('.$fS['unseen'].')</b>'; $oA[$oldFolderName]['desc'] = $fS['shortDisplayName'].' ('.$fS['unseen'].')';
} }
else else

View File

@ -840,6 +840,8 @@ app.classes.mail = AppJS.extend(
var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]'); var ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
for (var i in _status) { for (var i in _status) {
ftree.setLabel(i,_status[i]); ftree.setLabel(i,_status[i]);
// display folder-name bold for unseen mails
ftree.setStyle(i, 'font-weight: '+(_status[i].match(this._unseen_regexp) ? 'bold' : 'normal'));
//alert(i +'->'+_status[i]); //alert(i +'->'+_status[i]);
} }
}, },
@ -1003,6 +1005,11 @@ app.classes.mail = AppJS.extend(
if (calledFromPopup && this.mail_isMainWindow==false) window.close(); if (calledFromPopup && this.mail_isMainWindow==false) window.close();
}, },
/**
* Regular expression to find (and remove) unseen count from folder-name
*/
_unseen_regexp: / \([0-9]\)$/,
/** /**
* Delete mails - actually calls the backend function for deletion * Delete mails - actually calls the backend function for deletion
* takes in all arguments * takes in all arguments
@ -1014,18 +1021,7 @@ app.classes.mail = AppJS.extend(
ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]'); ftree = this.et2.getWidgetById(this.nm_index+'[foldertree]');
var _foldernode = ftree.getSelectedNode(); var _foldernode = ftree.getSelectedNode();
var displayname = _foldernode.label; var displayname = _foldernode.label.replace(this._unseen_regexp, '');
var inBraket = displayname.indexOf('\(');
if (inBraket!=-1)
{
var outBraket = displayname.indexOf('\)');
if (outBraket!=-1)
{
displayname = displayname.replace(/\((.*?)\)/,"");
displayname = displayname.replace(/<b>/,"");
displayname = displayname.replace(/<\/b>/,"");
}
}
// Tell server // Tell server
egw.json('mail.mail_ui.ajax_deleteMessages',[_msg,(typeof _action == 'undefined'?'no':_action)]) egw.json('mail.mail_ui.ajax_deleteMessages',[_msg,(typeof _action == 'undefined'?'no':_action)])
.sendRequest(true); .sendRequest(true);
@ -1190,18 +1186,7 @@ app.classes.mail = AppJS.extend(
// Get nice folder name for message, if selected is not a profile // Get nice folder name for message, if selected is not a profile
if(!profile_selected) if(!profile_selected)
{ {
var displayname = _widget.getSelectedLabel(); var displayname = _widget.getSelectedLabel().replace(this._remove_unseen_regexp, '');
var inBraket = displayname.indexOf('\(');
if (inBraket!=-1)
{
var outBraket = displayname.indexOf('\)');
if (outBraket!=-1)
{
displayname = displayname.replace(/\((.*?)\)/,"");
displayname = displayname.replace(/<b>/,"");
displayname = displayname.replace(/<\/b>/,"");
}
}
var myMsg = (displayname?displayname:_folder)+' '+this.egw.lang('selected'); var myMsg = (displayname?displayname:_folder)+' '+this.egw.lang('selected');
egw_message(myMsg); egw_message(myMsg);
} }