Skip to content
This repository was archived by the owner on Sep 10, 2021. It is now read-only.

Commit 989eece

Browse files
author
Charles Marion
committed
BUG: Long name (bug: 9610)
1 parent 750841e commit 989eece

File tree

15 files changed

+98
-68
lines changed

15 files changed

+98
-68
lines changed

core/controllers/FolderController.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -94,24 +94,24 @@ public function viewAction()
9494
{
9595
$items[$key]->size=$this->Component->Utility->formatSize($i->getSizebytes());
9696
}
97-
$header.=" <li class='pathFolder'><img alt='' src='{$this->view->coreWebroot}/public/images/FileTree/folder_open.png' /><span><a href='{$this->view->webroot}/folder/{$folder->getKey()}'>{$folder->getName()}</a></span></li>";
97+
$header.=" <li class='pathFolder'><img alt='' src='{$this->view->coreWebroot}/public/images/FileTree/folder_open.png' /><span><a href='{$this->view->webroot}/folder/{$folder->getKey()}'>".$this->Component->Utility->sliceName($folder->getName(),25)."</a></span></li>";
9898
$parent=$folder->getParent();
9999
while($parent!==false)
100100
{
101101
if(strpos($parent->getName(), 'community')!==false&&$this->Folder->getCommunity($parent)!==false)
102102
{
103103
$community=$this->Folder->getCommunity($parent);
104-
$header=" <li class='pathCommunity'><img alt='' src='{$this->view->coreWebroot}/public/images/icons/community.png' /><span><a href='{$this->view->webroot}/community/{$community->getKey()}#tabs-3'>{$community->getName()}</a></span></li>".$header;
104+
$header=" <li class='pathCommunity'><img alt='' src='{$this->view->coreWebroot}/public/images/icons/community.png' /><span><a href='{$this->view->webroot}/community/{$community->getKey()}#tabs-3'>".$this->Component->Utility->sliceName($community->getName(),25)."</a></span></li>".$header;
105105
}
106106
elseif(strpos($parent->getName(), 'user')!==false&&$this->Folder->getUser($parent)!==false)
107107
{
108108
$user=$this->Folder->getUser($parent);
109-
$header=" <li class='pathUser'><img alt='' src='{$this->view->coreWebroot}/public/images/icons/unknownUser-small.png' /><span><a href='{$this->view->webroot}/user/{$user->getKey()}'>{$user->getFullName()}</a></span></li>".$header;
109+
$header=" <li class='pathUser'><img alt='' src='{$this->view->coreWebroot}/public/images/icons/unknownUser-small.png' /><span><a href='{$this->view->webroot}/user/{$user->getKey()}'>".$this->Component->Utility->sliceName($user->getFullName(),25)."</a></span></li>".$header;
110110

111111
}
112112
else
113113
{
114-
$header=" <li class='pathFolder'><img alt='' src='{$this->view->coreWebroot}/public/images/FileTree/directory.png' /><span><a href='{$this->view->webroot}/folder/{$parent->getKey()}'>{$parent->getName()}</a></span></li>".$header;
114+
$header=" <li class='pathFolder'><img alt='' src='{$this->view->coreWebroot}/public/images/FileTree/directory.png' /><span><a href='{$this->view->webroot}/folder/{$parent->getKey()}'>".$this->Component->Utility->sliceName($parent->getName(),15)."</a></span></li>".$header;
115115
}
116116
$parent=$parent->getParent();
117117
}

core/controllers/components/UtilityComponent.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,23 @@ static public function getAllModules()
4040

4141
return $modules;
4242
}
43+
44+
/** format long names*/
45+
static public function sliceName($name, $nchar)
46+
{
47+
if(strlen($name)>$nchar)
48+
{
49+
$toremove=(strlen($name))-$nchar;
50+
if($toremove<8)
51+
{
52+
return $name;
53+
}
54+
$name=substr($name, 0,5).'...'.substr($name, 8 + $toremove);
55+
return $name;
56+
}
57+
return $name;
58+
}
59+
4360
/** create init file*/
4461
static public function createInitFile($path,$data)
4562
{

core/layouts/layout.phtml

Lines changed: 2 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@
172172
{
173173
if(is_array($item))
174174
{
175-
echo "<li onclick=\"location.replace('{$this->webroot}/item/{$item['item_id']}');\" class='recentItem' title='". str_replace("'", '"', $item['name'])." | todo'><a href='{$this->webroot}/item/{$item['item_id']}'>".sliceRecentItem($item['name'])."</a></li>";
175+
echo "<li onclick=\"location.replace('{$this->webroot}/item/{$item['item_id']}');\" class='recentItem' title='". str_replace("'", '"', $item['name'])." | todo'><a href='{$this->webroot}/item/{$item['item_id']}'>".$this->slicename($item['name'],20)."</a></li>";
176176
}
177177
}
178178
echo '</ul>';
@@ -224,15 +224,4 @@
224224
<?php echo $this->json?>
225225
</div>
226226
</body>
227-
</html>
228-
229-
<?php
230-
function sliceRecentItem($name)
231-
{
232-
if(strlen($name)>20)
233-
{
234-
$name=substr($name,0, 6).'...'.substr($name,strlen($name)-11);
235-
}
236-
return $name;
237-
}
238-
?>
227+
</html>

core/public/css/folder/folder.view.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ div.viewAction{
88

99
div.viewInfo{
1010
display:inherit!important;
11-
}
11+
}

core/public/js/browse/browse.movecopy.js

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,18 +59,4 @@
5959
return html;
6060
}
6161

62-
63-
function trimName(name,padding)
64-
{
65-
if(name.length*7+padding>350)
66-
{
67-
toremove=(name.length*7+padding-350)/8;
68-
if(toremove<13)
69-
{
70-
return 'error';
71-
}
72-
name=name.substring(0,10)+'...'+name.substring(name.length+13-toremove);
73-
return name;
74-
}
75-
return name;
76-
}
62+

core/public/js/common/common.browser.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@
275275
{
276276
html+='<img class="infoLogo" alt="Data Type" src="'+json.global.coreWebroot+'/public/images/icons/document-big.png" />';
277277
}
278-
html+='<span class="infoTitle" >'+arrayElement['name']+'</span>';
278+
html+='<span class="infoTitle" >'+sliceFileName(arrayElement['name'],27)+'</span>';
279279
html+='<table>';
280280
html+=' <tr>';
281281
html+=' <td>'+arrayElement.translation.Created+'</td>';

core/public/js/folder/folder.view.js

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,17 @@
77

88
$( "#tabsGeneric" ).tabs();
99
$("#tabsGeneric").show();
10+
11+
if($('.pathBrowser li').length>4)
12+
{
13+
while($('.pathBrowser li').length>4)
14+
{
15+
$('.pathBrowser li:first').remove();
16+
}
17+
18+
$('.pathBrowser li:first').before('<li>...</li>');
19+
}
20+
$('.pathBrowser').show();
1021
});
1122

1223
//dependance: common/browser.js

core/public/js/jquery/jquery.fileupload-uix.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,7 @@
7272
};
7373

7474
this.formatFileName = function (name) {
75+
name=sliceFileName(name,40);
7576
return name.replace(/^.*[\/\\]/, '');
7677
};
7778

core/public/js/layout/jquery.treeTable.js

Lines changed: 2 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -313,20 +313,6 @@
313313
});
314314
}
315315

316-
function trimName(name,padding)
317-
{
318-
if(name.length*7+padding>350)
319-
{
320-
toremove=(name.length*7+padding-350)/8;
321-
if(toremove<13)
322-
{
323-
return 'error';
324-
}
325-
name=name.substring(0,10)+'...'+name.substring(name.length+13-toremove);
326-
return name;
327-
}
328-
return name;
329-
}
330316

331317
function createElementsAjax(node,elements,first)
332318
{
@@ -344,7 +330,7 @@
344330
var html='';
345331
$.each(elements['folders'], function(index, value) {
346332
html+= "<tr id='"+id+"-"+i+"' deletable='"+value['deletable']+"' class='parent child-of-"+id+"' ajax='"+value['folder_id']+"'type='folder' policy='"+value['policy']+"' element='"+value['folder_id']+"'>";
347-
html+= " <td><span class='folder'>"+trimName(value['name'],padding)+"</span></td>";
333+
html+= " <td><span class='folder'>"+sliceFileName(value['name'],40)+"</span></td>";
348334
html+= " <td>"+'<img class="folderLoading" element="'+value['folder_id']+'" alt="" src="'+json.global.coreWebroot+'/public/images/icons/loading.gif"/>'+"</td>";
349335
html+= " <td>"+value['creation']+"</td>";
350336
html+= " <td><input type='checkbox' class='treeCheckbox' type='folder' element='"+value['folder_id']+"'/></td>";
@@ -354,7 +340,7 @@
354340

355341
$.each(elements['items'], function(index, value) {
356342
html+= "<tr id='"+id+"-"+i+"' class='child-of-"+id+"' type='item' policy='"+value['policy']+"' element='"+value['item_id']+"'>";
357-
html+= " <td><span class='file'>"+trimName(value['name'],padding)+"</span></td>";
343+
html+= " <td><span class='file'>"+sliceFileName(value['name'],40)+"</span></td>";
358344
html+= " <td>"+value['size']+"</td>";
359345
html+= " <td>"+value['creation']+"</td>";
360346
html+= " <td><input type='checkbox' class='treeCheckbox' type='item' element='"+value['item_id']+"'/></td>";

core/public/js/layout/main.js

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,37 @@ if (typeof console != "object") {
66
'log':function(){}
77
};
88
}
9+
10+
function sliceFileName(name,nchar)
11+
{
12+
if(name.length>nchar)
13+
{
14+
toremove=(name.length)-nchar;
15+
if(toremove<13)
16+
{
17+
return name;
18+
}
19+
name=name.substring(0,10)+'...'+name.substring(13+toremove);
20+
return name;
21+
}
22+
return name;
23+
}
24+
25+
function trimName(name,padding)
26+
{
27+
if(name.length*7+padding>350)
28+
{
29+
toremove=(name.length*7+padding-350)/8;
30+
if(toremove<13)
31+
{
32+
return 'error';
33+
}
34+
name=name.substring(0,10)+'...'+name.substring(name.length+13-toremove);
35+
return name;
36+
}
37+
return name;
38+
}
39+
940
$(function() {
1041
json = jQuery.parseJSON($('div.jsonContent').html());
1142
if(!json.global.logged)

0 commit comments

Comments
 (0)