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

Commit 106b9d4

Browse files
author
Julien Jomier
committed
ENH: Improved search
1 parent b24dad4 commit 106b9d4

File tree

8 files changed

+92
-17
lines changed

8 files changed

+92
-17
lines changed

application/controllers/SearchController.php

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,15 @@ class SearchController extends AppController
1313
function init()
1414
{
1515
$this->view->activemenu = 'feed'; // set the active menu
16-
} // end init()
16+
17+
// if the number of parameters is more than 3 then it's the liveAction
18+
if(count($this->_getAllParams()) == 3)
19+
{
20+
$actionName=Zend_Controller_Front::getInstance()->getRequest()->getActionName();
21+
$this->_forward('index',null,null,array('q'=>$actionName));
22+
}
23+
} // end init()
24+
1725

1826
/** search live Action */
1927
public function indexAction()
@@ -25,8 +33,20 @@ public function indexAction()
2533
$this->view->json['search']['keyword'] = $keyword;
2634

2735
// Get the items corresponding to the search
28-
$items = $this->ItemKeyword->getItemsFromSearch($keyword,$this->userSession->Dao);
29-
$this->view->items=$items;
36+
$ItemsDao = $this->ItemKeyword->getItemsFromSearch($keyword,$this->userSession->Dao);
37+
$this->view->items=$ItemsDao;
38+
39+
// Search for the folders
40+
$FoldersDao = $this->Folder->getFoldersFromSearch($keyword,$this->userSession->Dao);
41+
$this->view->folders=$FoldersDao;
42+
43+
// Search for the communities
44+
$CommunitiesDao = $this->Community->getCommunitiesFromSearch($keyword,$this->userSession->Dao);
45+
$this->view->communities=$CommunitiesDao;
46+
47+
// Search for the users
48+
$UsersDao = $this->User->getUsersFromSearch($keyword,$this->userSession->Dao);
49+
$this->view->users=$UsersDao;
3050
}
3151

3252
/** search live Action */

application/layouts/layout.phtml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,7 @@
116116
<div class="HeaderSearch">
117117
<input type="text" id="live_search" value="<?= $this->t('Jump to a data, folder...') ?>" autocomplete="off" autocorrect="off" autocapitalize="off" />
118118
<input type="hidden" id="live_search_value" value="init" />
119+
<div id="searchloading" style="display:none"></div>
119120
</div>
120121
<div class="HeaderAction">
121122
<ul>

application/views/search/index.phtml

Lines changed: 30 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,45 @@
22
$this->headScript()->appendFile($this->webroot.'/public/js/search/search.index.js');
33
?>
44
<div class="viewMain">
5+
<ul>
6+
<li class="searchheader"><?php echo $this->t('Items')?></li>
57
<?php
6-
echo "<ul>";
78
foreach($this->items as $item)
89
{
910
echo "<li> <a href='{$this->webroot}/item/{$item->getKey()}'>{$item->getName()}</a>";
1011
}
11-
echo "</ul>";
1212
?>
13+
</ul>
14+
<ul>
15+
<li class="searchheader"><?php echo $this->t('Folders')?></li>
16+
<?php
17+
foreach($this->folders as $folder)
18+
{
19+
echo "<li> <a href='{$this->webroot}/folder/{$folder->getKey()}'>{$folder->getName()}</a>";
20+
}
21+
?>
22+
</ul>
23+
<ul>
24+
<li class="searchheader"><?php echo $this->t('Communities')?></li>
25+
<?php
26+
foreach($this->communities as $community)
27+
{
28+
echo "<li> <a href='{$this->webroot}/community/{$community->getKey()}'>{$community->getName()}</a>";
29+
}
30+
?>
31+
</ul>
32+
<ul>
33+
<li class="searchheader"><?php echo $this->t('Users')?></li>
34+
<?php
35+
foreach($this->users as $user)
36+
{
37+
echo "<li> <a href='{$this->webroot}/user/{$user->getKey()}'>{$user->getName()}</a>";
38+
}
39+
?>
40+
</ul>
1341
</div>
1442
<div class="viewSideBar">
1543
blabla
16-
1744
</div>
1845

1946

public/css/layout/main.css

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,6 +184,7 @@ div.Header div.HeaderSearch{
184184
padding-top: 6px;
185185
padding-left: 35px;
186186
float:left;
187+
position:relative;
187188
}
188189

189190
div.Header div.HeaderSearch input#live_search{
@@ -202,6 +203,29 @@ div.Header div.HeaderSearch input#live_search{
202203
-moz-box-shadow: 0px 0px 15px #666;
203204
}
204205

206+
#searchloading{
207+
position:absolute;
208+
background: url("../../images/icons/loading-small.gif") bottom center no-repeat;
209+
color:#FFFFFF;
210+
text-decoration:none;
211+
width: 16px;
212+
height: 16px;
213+
top: 12px;
214+
right: 7px;
215+
}
216+
217+
.search-category{
218+
clear: both;
219+
color: #333BA0;
220+
font-weight: bold;
221+
background-color: #F6F9FE;
222+
line-height: 1.5;
223+
}
224+
225+
.search-items{
226+
background-color: #FFFFFF;
227+
}
228+
205229
div.Header div.HeaderAction{
206230
padding-top: 7px;
207231
padding-left: 35px;
@@ -497,4 +521,5 @@ div.HeaderLinks .menu ul{
497521
}
498522
div.HeaderLinks .menu p{
499523
clear:left;
500-
}
524+
}
525+
673 Bytes
Loading

public/js/layout/main.js

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,6 @@ $(function() {
2020
loadAjaxDynamicBar('login','/user/login');
2121
});
2222

23-
24-
25-
2623
$("a.registerLink").click(function()
2724
{
2825
showOrHideDynamicBar('register');
@@ -36,7 +33,7 @@ $(function() {
3633
currentCategory = "";
3734
$.each( items, function( index, item ) {
3835
if ( item.category != currentCategory ) {
39-
ul.append( "<li class='ui-autocomplete-category'>" + item.category + "</li>" );
36+
ul.append( '<li class="search-category">' + item.category + "</li>" );
4037
currentCategory = item.category;
4138
}
4239
self._renderItem( ul, item );
@@ -56,7 +53,10 @@ $(function() {
5653
return;
5754
}
5855

56+
$("#searchloading").show();
57+
5958
lastXhr = $.getJSON( $('.webroot').val()+"/search/live", request, function( data, status, xhr ) {
59+
$("#searchloading").hide();
6060
cache[ term ] = data;
6161
if ( xhr === lastXhr ) {
6262
itemselected = false;
@@ -84,7 +84,7 @@ $(function() {
8484
}
8585
else
8686
{
87-
window.location.replace($('.webroot').val()+'/search?q='+ui.item.value);
87+
window.location.replace($('.webroot').val()+'/search/'+ui.item.value);
8888
}
8989
}
9090
});
@@ -109,7 +109,7 @@ $(function() {
109109
{
110110
if(e.keyCode == 13 && !itemselected) // enter key has been pressed
111111
{
112-
window.location.replace($('.webroot').val()+'/search?q='+$('#live_search').val());
112+
window.location.replace($('.webroot').val()+'/search/'+$('#live_search').val());
113113
}
114114
});
115115

public/js/search/search.index.js

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,3 @@ $(document).ready(function() {
22
$('#live_search_value').val($('#live_search').val());
33
$('#live_search').val(json.search.keyword);
44
});
5-
6-
7-

translation/fr-main.csv

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ added the item;a ajout
7575
added the link;a ajout� le lien
7676
registered;s'est inscrit
7777
Item;Document
78+
Items;Documents
79+
Folder;Repertoire
80+
Folders;Repertoires
81+
User;Utilisateur
82+
Users;Utilisateurs
7883
Size;Taille
7984
Modified;Modifi�
8085
Download;T�l�charger
@@ -86,4 +91,4 @@ Plugins;Plugins
8691
E-mail;E-mail
8792
Remember Me;Se souvenir de moi
8893
Members;Membres
89-
Generated in;G�n�r� en
94+
Generated in;G�n�r� en

0 commit comments

Comments
 (0)