diff options
author | Olivier Migeot <olivier@migeot.org> | 2011-10-04 11:45:57 +0200 |
---|---|---|
committer | Olivier Migeot <olivier@migeot.org> | 2011-10-04 11:45:57 +0200 |
commit | 273594af62c960b5a52da5ec1cf6d6bd450415ba (patch) | |
tree | 5f79914d28c343f7642ecb13b99f9e0e3f5090a7 /mod/search.php | |
parent | 1548449586f17c0ef9bfab0ffb16f2a495fc6082 (diff) | |
parent | dfd5cc57c2134067dc6229b8583b5e808f160004 (diff) | |
download | volse-hubzilla-273594af62c960b5a52da5ec1cf6d6bd450415ba.tar.gz volse-hubzilla-273594af62c960b5a52da5ec1cf6d6bd450415ba.tar.bz2 volse-hubzilla-273594af62c960b5a52da5ec1cf6d6bd450415ba.zip |
Merge remote branch 'upstream/master'
Diffstat (limited to 'mod/search.php')
-rw-r--r-- | mod/search.php | 62 |
1 files changed, 59 insertions, 3 deletions
diff --git a/mod/search.php b/mod/search.php index 88ff9bbb7..034794e17 100644 --- a/mod/search.php +++ b/mod/search.php @@ -1,5 +1,60 @@ <?php +function search_saved_searches() { + + $o = ''; + + $r = q("select `term` from `search` WHERE `uid` = %d", + intval(local_user()) + ); + + if(count($r)) { + $o .= '<div id="saved-search-list" class="widget">'; + $o .= '<h3>' . t('Saved Searches') . '</h3>' . "\r\n"; + $o .= '<ul id="saved-search-ul">' . "\r\n"; + foreach($r as $rr) { + $o .= '<li class="saved-search-li clear"><a href="search/?f=&remove=1&search=' . $rr['term'] . '" class="icon drophide savedsearchdrop" title="' . t('Remove term') . '" onclick="return confirmDelete();" onmouseover="imgbright(this);" onmouseout="imgdull(this);" ></a> <a href="search/?f=&search=' . $rr['term'] . '" class="savedsearchterm" >' . $rr['term'] . '</a></li>' . "\r\n"; + } + $o .= '</ul></div>' . "\r\n"; + } + + return $o; + +} + + +function search_init(&$a) { + + $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); + + if(local_user()) { + if(x($_GET,'save') && $search) { + $r = q("select * from `search` where `uid` = %d and `term` = '%s' limit 1", + intval(local_user()), + dbesc($search) + ); + if(! count($r)) { + q("insert into `search` ( `uid`,`term` ) values ( %d, '%s') ", + intval(local_user()), + dbesc($search) + ); + } + } + if(x($_GET,'remove') && $search) { + q("delete from `search` where `uid` = %d and `term` = '%s' limit 1", + intval(local_user()), + dbesc($search) + ); + } + + $a->page['aside'] .= search_saved_searches(); + + } + + +} + + function search_post(&$a) { if(x($_POST,'search')) @@ -13,6 +68,8 @@ function search_content(&$a) { notice( t('Public access denied.') . EOL); return; } + + nav_set_selected('search'); require_once("include/bbcode.php"); require_once('include/security.php'); @@ -30,7 +87,7 @@ function search_content(&$a) { else $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : ''); - $o .= search($search); + $o .= search($search,'search-box','/search',((local_user()) ? true : false)); if(! $search) return $o; @@ -86,12 +143,11 @@ function search_content(&$a) { ); - + $o .= '<h2>Search results for: ' . $search . '</h2>'; $o .= conversation($a,$r,'search',false); $o .= paginate($a); - $o .= cc_license(); return $o; } |