aboutsummaryrefslogtreecommitdiffstats
path: root/mod/search.php
diff options
context:
space:
mode:
authorFriendika <info@friendika.com>2011-09-08 21:42:52 -0700
committerFriendika <info@friendika.com>2011-09-08 21:42:52 -0700
commit3f59f632241d14b43ba8861033aac27dfcfbc9e3 (patch)
tree89fc6df4fddeb248f736ec7ce08e601be7d6c337 /mod/search.php
parentf03c2b1b79b4a0b242b4e74cc25eb158cf40decb (diff)
downloadvolse-hubzilla-3f59f632241d14b43ba8861033aac27dfcfbc9e3.tar.gz
volse-hubzilla-3f59f632241d14b43ba8861033aac27dfcfbc9e3.tar.bz2
volse-hubzilla-3f59f632241d14b43ba8861033aac27dfcfbc9e3.zip
saved searches on search page, templates: Invalid argument supplied for foreach() on line 167
Diffstat (limited to 'mod/search.php')
-rw-r--r--mod/search.php56
1 files changed, 55 insertions, 1 deletions
diff --git a/mod/search.php b/mod/search.php
index 88ff9bbb7..d22fea6ff 100644
--- a/mod/search.php
+++ b/mod/search.php
@@ -1,5 +1,59 @@
<?php
+function search_saved_searches() {
+
+ $o = '';
+
+ $r = q("select `term` from `search` WHERE `uid` = %d",
+ intval(local_user())
+ );
+
+ if(count($r)) {
+ $o .= '<h3>' . t('Saved Searches') . '</h3>' . "\r\n";
+ $o .= '<div id="saved-search-list"><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'))
@@ -30,7 +84,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;