aboutsummaryrefslogtreecommitdiffstats
path: root/Zotlabs/Widget/Sitesearch.php
diff options
context:
space:
mode:
authorzotlabs <mike@macgirvin.com>2017-03-15 18:48:27 -0700
committerzotlabs <mike@macgirvin.com>2017-03-15 18:48:27 -0700
commit664c762b35d894b6c055eb57a72f01dae97b48c3 (patch)
treea6e6865f4849539112bb1fffb505c1f1e1f1fe75 /Zotlabs/Widget/Sitesearch.php
parent9cb9608209ab5f9fb123acc82a563ba54c450db1 (diff)
downloadvolse-hubzilla-664c762b35d894b6c055eb57a72f01dae97b48c3.tar.gz
volse-hubzilla-664c762b35d894b6c055eb57a72f01dae97b48c3.tar.bz2
volse-hubzilla-664c762b35d894b6c055eb57a72f01dae97b48c3.zip
more widgets
Diffstat (limited to 'Zotlabs/Widget/Sitesearch.php')
-rw-r--r--Zotlabs/Widget/Sitesearch.php38
1 files changed, 38 insertions, 0 deletions
diff --git a/Zotlabs/Widget/Sitesearch.php b/Zotlabs/Widget/Sitesearch.php
new file mode 100644
index 000000000..b3a25d76a
--- /dev/null
+++ b/Zotlabs/Widget/Sitesearch.php
@@ -0,0 +1,38 @@
+<?php
+
+namespace Zotlabs\Widget;
+
+
+class Sitesearch {
+
+ function widget($arr) {
+
+ $search = ((x($_GET,'search')) ? $_GET['search'] : '');
+
+ $srchurl = \App::$query_string;
+
+ $srchurl = rtrim(preg_replace('/search\=[^\&].*?(\&|$)/is','',$srchurl),'&');
+ $srchurl = rtrim(preg_replace('/submit\=[^\&].*?(\&|$)/is','',$srchurl),'&');
+ $srchurl = str_replace(array('?f=','&f='),array('',''),$srchurl);
+
+
+ $hasq = ((strpos($srchurl,'?') !== false) ? true : false);
+ $hasamp = ((strpos($srchurl,'&') !== false) ? true : false);
+
+ if(($hasamp) && (! $hasq))
+ $srchurl = substr($srchurl,0,strpos($srchurl,'&')) . '?f=&' . substr($srchurl,strpos($srchurl,'&')+1);
+
+ $o = '';
+
+ $saved = array();
+
+ $tpl = get_markup_template("sitesearch.tpl");
+ $o = replace_macros($tpl, array(
+ '$title' => t('Search'),
+ '$searchbox' => searchbox($search, 'netsearch-box', $srchurl . (($hasq) ? '' : '?f='), false),
+ '$saved' => $saved,
+ ));
+
+ return $o;
+ }
+}