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

Commit 71ec689

Browse files
author
Charles Ma
committed
ENH: refs #301 Added parameters as metadata in the results items
Fixed session lost issue
1 parent ce59f28 commit 71ec689

File tree

17 files changed

+417
-160
lines changed

17 files changed

+417
-160
lines changed

core/AppController.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ public function preDispatch()
7979
else
8080
{
8181
$user = new Zend_Session_Namespace('Auth_User');
82+
$user->setExpirationSeconds(60 * Zend_Registry::get('configGlobal')->session->lifetime);
8283
}
8384

8485
if($user->Dao == null)

core/controllers/BrowseController.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -194,13 +194,26 @@ public function selectfolderAction()
194194
{
195195
throw new Zend_Exception("Why are you here ? Should be ajax.");
196196
}
197-
$this->_helper->layout->disableLayout();
197+
$this->disableLayout();
198+
$policy = $this->_getParam("policy");
199+
200+
$communities = $this->User->getUserCommunities($this->userSession->Dao);
201+
202+
203+
if(isset($policy) && $policy == 'read')
204+
{
205+
$policy = MIDAS_POLICY_READ;
206+
$communities = array_merge($communities, $this->Community->getPublicCommunities());
207+
}
208+
else
209+
{
210+
$policy = MIDAS_POLICY_WRITE;
211+
}
198212

199213
$this->view->selectEnabled = true;
200214

201-
$communities = $this->User->getUserCommunities($this->userSession->Dao);
202-
$communities = array_merge($communities, $this->Community->getPublicCommunities());
203215
$this->view->Date = $this->Component->Date;
216+
$this->view->policy = $policy;
204217

205218
$this->Component->Sortdao->field = 'name';
206219
$this->Component->Sortdao->order = 'asc';

core/controllers/SearchController.php

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ public function liveAction()
8484
$search = $this->getRequest()->getParam('term');
8585
$shareSearch = $this->getRequest()->getParam('shareSearch'); //return user group and communities
8686
$userSearch = $this->getRequest()->getParam('userSearch');
87+
$itemSearch = $this->getRequest()->getParam('itemSearch');
8788

8889
if(isset($shareSearch))
8990
{
@@ -121,6 +122,15 @@ public function liveAction()
121122
// Search for the users
122123
$UsersDao = $this->User->getUsersFromSearch($search, $this->userSession->Dao);
123124
}
125+
elseif(isset($itemSearch))
126+
{
127+
$ItemsDao = $this->Item->getItemsFromSearch($search, $this->userSession->Dao, 15, false);
128+
$FoldersDao = array();
129+
$CommunitiesDao = array();
130+
$GroupsDao = array();
131+
// Search for the users
132+
$UsersDao = array();
133+
}
124134
else
125135
{
126136
// Search for the items
@@ -187,7 +197,7 @@ public function liveAction()
187197
echo '{';
188198
echo '"id":"'.$id.'"';
189199
echo ', "label":"'.$this->Component->Utility->sliceName($itemDao->getName(), 55);
190-
if($itemDao->count > 1)
200+
if(isset($itemDao->count) && $itemDao->count > 1)
191201
{
192202
echo ' ('.$itemDao->count.')"';
193203
}
@@ -198,7 +208,7 @@ public function liveAction()
198208

199209
echo ', "value":"'.$itemDao->getName().'"';
200210

201-
if($itemDao->count == 1)
211+
if(isset($itemDao->count) && $itemDao->count == 1)
202212
{
203213
echo ', "itemid":"'.$itemDao->getItemId().'"';
204214
}

core/public/css/browse/browse.selectfolder.css

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,28 @@ table#moveTable{
1313

1414
.treeTable .browserPrivacyInformation{
1515
right: 10px!important;
16+
}
17+
18+
#createFolderButton{
19+
float:none!important;
20+
width: 200px;
21+
border:none;
22+
display:none;
23+
}
24+
25+
#createFolderContent{
26+
display:none;
27+
border: 1px #CCD7E0 dotted!important;
28+
margin-top: 5px;
29+
width: 300px;
30+
margin-bottom: 2px;
31+
border: #354856 1px solid;
32+
-moz-border-radius: 6px;
33+
-webkit-border-radius: 6px;
34+
-khtml-border-radius: 6px;
35+
border-radius: 6px;
36+
-webkit-box-shadow: #666 0 0 2px;
37+
box-shadow: #666 0 0 2px;
38+
-moz-box-shadow: 0px 0px 2px #666;
39+
padding: 0px 5px 6px 5px;
1640
}

core/public/css/browse/browse.selectitem.css

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,32 @@ table#moveTable{
1313

1414
.treeTable .browserPrivacyInformation{
1515
right: 10px!important;
16+
}
17+
18+
input#live_search_item {
19+
background: white url(../../images/icons/search.png) no-repeat scroll 3px 1px;
20+
border: 1px solid white;
21+
-moz-border-radius: 4px;
22+
-webkit-border-radius: 4px;
23+
-khtml-border-radius: 4px;
24+
border-radius: 4px;
25+
font-size: 12px;
26+
opacity: 0.9;
27+
padding: 3px 10px 3px 24px;
28+
width: 400px;
29+
-webkit-box-shadow: #666 0 0 3px;
30+
box-shadow: #666 0 0 3px;
31+
-moz-box-shadow: 0px 0px 15px #666;
32+
width:200px;
33+
}
34+
35+
#searchloadingSelectItem{
36+
position:absolute;
37+
background: url("../../images/icons/loading-small.gif") bottom center no-repeat;
38+
color:#FFFFFF;
39+
text-decoration:none;
40+
width: 16px;
41+
height: 16px;
42+
top: 12px;
43+
right: 7px;
1644
}

core/public/js/browse/browse.selectfolder.js

Lines changed: 67 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -49,15 +49,76 @@
4949
}
5050
}
5151

52-
$('#selectedDestinationHidden').val(node.attr('element'));
53-
$('#selectedDestination').html(sliceFileName(selectedElement, 40));
54-
$('#selectElements').removeAttr('disabled');
55-
52+
$('#createFolderContent').hide();
53+
if(node.attr('element') == -1)
54+
{
55+
$('#selectElements').attr('disabled', 'disabled');
56+
$('#createFolderButton').hide();
57+
}
58+
else
59+
{
60+
$('#selectedDestinationHidden').val(node.attr('element'));
61+
$('#selectedDestination').html(sliceFileName(selectedElement, 40));
62+
$('#selectElements').removeAttr('disabled');
63+
64+
if($('#defaultPolicy').val() != 0)
65+
{
66+
$('#createFolderButton').show();
67+
}
68+
}
5669
}
5770

5871
$('img.infoLoading').show();
5972
$('div.ajaxInfoElement').html('');
6073

74+
$('#createFolderButton').click(function(){
75+
if($('#createFolderContent').is(':hidden'))
76+
{
77+
$('#createFolderContent').html('<img src="'+json.global.webroot+'/core/public/images/icons/loading.gif" alt="Loading..." />').show();
78+
var url = json.global.webroot+'/folder/createfolder?folderId='+$('#selectedDestinationHidden').val();
79+
$('#createFolderContent').load(url);
80+
}
81+
else
82+
{
83+
$('#createFolderContent').hide();
84+
}
85+
})
86+
87+
88+
var newFolder = false;
89+
function successCreateFolderCallback(responseText, statusText, xhr, form)
90+
{
91+
jsonResponse = jQuery.parseJSON(responseText);
92+
if(jsonResponse==null)
93+
{
94+
createNotive('Error',4000);
95+
return;
96+
}
97+
if(jsonResponse[0])
98+
{
99+
createNotive(jsonResponse[1],4000);
100+
var node = $('table.treeTable tr[element='+jsonResponse[2].folder_id+']');
101+
node.reload();
102+
103+
$('#createFolderContent').hide();
104+
105+
newFolder = jsonResponse[3].folder_id;
106+
107+
}
108+
else
109+
{
110+
createNotive(jsonResponse[1],4000);
111+
}
112+
113+
}
114+
115+
function reloadNodeCallback(mainNode)
116+
{
117+
if(newFolder != false)
118+
{
119+
callbackSelect($('table.treeTable tr[element='+newFolder+']'));
120+
}
121+
}
61122

62123
function callbackDblClick(node)
63124
{
@@ -77,9 +138,8 @@
77138

78139
var padding=parseInt(node.find('td:first').css('padding-left').slice(0,-2));
79140
var html='';
80-
81-
$.each(elements['folders'], function(index, value) {
82-
if(value['policy']!='0')
141+
$.each(elements['folders'], function(index, value) {
142+
if(value['policy'] >= parseInt($('#defaultPolicy').val()))
83143
{
84144
html+= "<tr id='"+id+"-"+i+"' class='parent child-of-"+id+"' ajax='"+value['folder_id']+"'type='folder' policy='"+value['policy']+"' element='"+value['folder_id']+"'>";
85145
html+= " <td><span class='folder'>"+trimName(value['name'],padding)+"</span></td>";

core/public/js/browse/browse.selectitem.js

Lines changed: 71 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -60,13 +60,10 @@
6060
var html='';
6161

6262
$.each(elements['folders'], function(index, value) {
63-
if(value['policy']!='0')
64-
{
6563
html+= "<tr id='"+id+"-"+i+"' class='parent child-of-"+id+"' ajax='"+value['folder_id']+"'type='folder' policy='"+value['policy']+"' element='"+value['folder_id']+"'>";
6664
html+= " <td><span class='folder'>"+trimName(value['name'],padding)+"</span></td>";
6765
html+= "</tr>";
6866
i++;
69-
}
7067
});
7168

7269
$.each(elements['items'], function(index, value) {
@@ -81,3 +78,74 @@
8178

8279
}
8380

81+
// Live search
82+
$.widget( "custom.catcomplete", $.ui.autocomplete, {
83+
_renderMenu: function( ul, items ) {
84+
var self = this,
85+
currentCategory = "";
86+
$.each( items, function( index, item ) {
87+
if ( item.category != currentCategory ) {
88+
ul.append( '<li class="search-category">' + item.category + "</li>" );
89+
currentCategory = item.category;
90+
}
91+
self._renderItem( ul, item );
92+
});
93+
}
94+
});
95+
96+
var cacheSearchSelectItem = {},
97+
lastXhr;
98+
$("#live_search_item").catcomplete({
99+
minLength: 2,
100+
delay: 10,
101+
source: function( request, response ) {
102+
var term = request.term;
103+
if ( term in cacheSearchSelectItem ) {
104+
response( cacheSearchSelectItem[ term ] );
105+
return;
106+
}
107+
108+
$("#searchloadingSelectItem").show();
109+
110+
lastXhr = $.getJSON( $('.webroot').val()+"/search/live?itemSearch=true", request, function( data, status, xhr ) {
111+
$("#searchloadingSelectItem").hide();
112+
cacheSearchSelectItem[ term ] = data;
113+
if ( xhr === lastXhr ) {
114+
itemselected = false;
115+
response( data );
116+
}
117+
});
118+
}, // end source
119+
select: function(event, ui) {
120+
itemselected = true;
121+
$('#selectedDestinationHidden').val(ui.item.itemid);
122+
$('#selectedDestination').html(ui.item.value);
123+
$('#selectElements').removeAttr('disabled');
124+
}
125+
});
126+
127+
$('#live_search_item').focus(function() {
128+
if($('#live_search_item_value').val() == 'init')
129+
{
130+
$('#live_search_item_value').val($('#live_search_item').val());
131+
$('#live_search_item').val('');
132+
}
133+
});
134+
135+
$('#live_search_item').focusout(function() {
136+
if($('#live_search_item').val() == '')
137+
{
138+
$('#live_search_item').val($('#live_search_item_value').val());
139+
$('#live_search_item_value').val('init');
140+
}
141+
});
142+
143+
$('#live_search_item').keyup(function(e)
144+
{
145+
if(e.keyCode == 13 && !itemselected) // enter key has been pressed
146+
{
147+
window.location.replace($('.webroot').val()+'/search/'+$('#live_search_item').val());
148+
}
149+
});
150+
151+

core/public/js/folder/folder.createfolder.js

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
$('#createFolderForm').ajaxForm( {beforeSubmit: validateCreateFolder, success: successCreateFolder} );
22

3-
if(typeof callbackDblClick != 'function') {
3+
if(typeof callbackDblClick != 'function') {
44
function childrenOf(node) {
55
if(node[0]==undefined)
66
{
@@ -10,20 +10,25 @@ $('#createFolderForm').ajaxForm( {beforeSubmit: validateCreateFolder, success:
1010
};
1111
}
1212

13-
1413

15-
function validateCreateFolder(formData, jqForm, options) {
16-
17-
var form = jqForm[0];
14+
15+
function validateCreateFolder(formData, jqForm, options) {
16+
17+
var form = jqForm[0];
1818
if (form.name.value.length<1)
1919
{
2020
createNotive('Error name',4000);
2121
return false;
2222
}
2323
}
2424

25-
function successCreateFolder(responseText, statusText, xhr, form)
25+
function successCreateFolder(responseText, statusText, xhr, form)
2626
{
27+
if(typeof successCreateFolderCallback == 'function')
28+
{
29+
successCreateFolderCallback(responseText, statusText, xhr, form);
30+
return;
31+
}
2732
$( "div.MainDialog" ).dialog("close");
2833
jsonResponse = jQuery.parseJSON(responseText);
2934
if(jsonResponse==null)

0 commit comments

Comments
 (0)