aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/diaspora.php12
-rw-r--r--include/html2plain.php2
-rw-r--r--mod/item.php2
-rw-r--r--mod/search.php30
-rw-r--r--mod/tagger.php8
5 files changed, 34 insertions, 20 deletions
diff --git a/include/diaspora.php b/include/diaspora.php
index afd86957b..5069c1127 100644
--- a/include/diaspora.php
+++ b/include/diaspora.php
@@ -706,10 +706,10 @@ function diaspora_post($importer,$xml) {
continue;
$basetag = str_replace('_',' ',substr($tag,1));
- $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
+ $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
if(strlen($str_tags))
$str_tags .= ',';
- $str_tags .= '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
+ $str_tags .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
continue;
}
}
@@ -872,10 +872,10 @@ function diaspora_reshare($importer,$xml) {
$basetag = str_replace('_',' ',substr($tag,1));
- $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
+ $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
if(strlen($str_tags))
$str_tags .= ',';
- $str_tags .= '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
+ $str_tags .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
continue;
}
}
@@ -1113,10 +1113,10 @@ function diaspora_comment($importer,$xml,$msg) {
$basetag = str_replace('_',' ',substr($tag,1));
- $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
+ $body = str_replace($tag,'#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]',$body);
if(strlen($str_tags))
$str_tags .= ',';
- $str_tags .= '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
+ $str_tags .= '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
continue;
}
}
diff --git a/include/html2plain.php b/include/html2plain.php
index 21261327d..839dd70a7 100644
--- a/include/html2plain.php
+++ b/include/html2plain.php
@@ -83,7 +83,7 @@ function collecturls($message) {
$urls = array();
foreach ($result as $treffer) {
// A list of some links that should be ignored
- $list = array("/user/", "/tag/", "/group/", "/profile/", "/search?search=", "mailto:", "/u/", "/node/",
+ $list = array("/user/", "/tag/", "/group/", "/profile/", "/search?search=", "/search?tag=", "mailto:", "/u/", "/node/",
"//facebook.com/profile.php?id=", "//plus.google.com/");
foreach ($list as $listitem)
if (strpos($treffer[1], $listitem) !== false)
diff --git a/mod/item.php b/mod/item.php
index 642a6758a..1436f7ffc 100644
--- a/mod/item.php
+++ b/mod/item.php
@@ -872,7 +872,7 @@ function handle_tag($a, &$body, &$inform, &$str_tags, $profile_uid, $tag) {
//base tag has the tags name only
$basetag = str_replace('_',' ',substr($tag,1));
//create text for link
- $newtag = '#[url=' . $a->get_baseurl() . '/search?search=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
+ $newtag = '#[url=' . $a->get_baseurl() . '/search?tag=' . rawurlencode($basetag) . ']' . $basetag . '[/url]';
//replace tag by the link
$body = str_replace($tag, $newtag, $body);
diff --git a/mod/search.php b/mod/search.php
index 4ca7db9bb..d467764b0 100644
--- a/mod/search.php
+++ b/mod/search.php
@@ -87,11 +87,26 @@ function search_content(&$a) {
else
$search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
+ $tag = false;
+ if(x($_GET,'tag')) {
+ $tag = true;
+ $search = ((x($_GET,'tag')) ? notags(trim(rawurldecode($_GET['tag']))) : '');
+ }
+
+
$o .= search($search,'search-box','/search',((local_user()) ? true : false));
if(! $search)
return $o;
+ if($tag)
+ $sql_extra = sprintf(" AND `item`.`tag` REGEXP '%s' ", dbesc('\\]' . preg_quote($search) . '\\['));
+ else
+ $sql_extra = sprintf(" AND `item`.`body` REGEXP '%s' ", dbesc(preg_quote($search)));
+
+
+
+
// Here is the way permissions work in the search module...
// Only public posts can be shown
// OR your own posts if you are a logged in member
@@ -103,10 +118,8 @@ function search_content(&$a) {
AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0)
OR `item`.`uid` = %d )
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' ) group by `item`.`uri` ",
- intval(local_user()),
- dbesc(preg_quote($search)),
- dbesc('\\]' . preg_quote($search) . '\\[')
+ $sql_extra group by `item`.`uri` ",
+ intval(local_user())
);
if(count($r))
@@ -127,18 +140,19 @@ function search_content(&$a) {
AND (( `item`.`allow_cid` = '' AND `item`.`allow_gid` = '' AND `item`.`deny_cid` = '' AND `item`.`deny_gid` = '' AND `item`.`private` = 0 AND `user`.`hidewall` = 0 )
OR `item`.`uid` = %d )
AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
- AND ( `item`.`body` REGEXP '%s' OR `item`.`tag` REGEXP '%s' )
+ $sql_extra
group by `item`.`uri`
ORDER BY `received` DESC LIMIT %d , %d ",
intval(local_user()),
- dbesc(preg_quote($search)),
- dbesc('\\]' . preg_quote($search) . '\\['),
intval($a->pager['start']),
intval($a->pager['itemspage'])
);
- $o .= '<h2>Search results for: ' . $search . '</h2>';
+ if($tag)
+ $o .= '<h2>Items tagged with: ' . $search . '</h2>';
+ else
+ $o .= '<h2>Search results for: ' . $search . '</h2>';
$o .= conversation($a,$r,'search',false);
diff --git a/mod/tagger.php b/mod/tagger.php
index 3ff5d57aa..8ee499f5f 100644
--- a/mod/tagger.php
+++ b/mod/tagger.php
@@ -86,7 +86,7 @@ function tagger_content(&$a) {
</target>
EOT;
- $tagid = $a->get_baseurl() . '/search?search=' . $term;
+ $tagid = $a->get_baseurl() . '/search?tag=' . $term;
$objtype = ACTIVITY_OBJ_TAGTERM;
$obj = <<< EOT
@@ -105,7 +105,7 @@ EOT;
if(! isset($bodyverb))
return;
- $termlink = html_entity_decode('&#x2317;') . '[url=' . $a->get_baseurl() . '/search?search=' . urlencode($term) . ']'. $term . '[/url]';
+ $termlink = html_entity_decode('&#x2317;') . '[url=' . $a->get_baseurl() . '/search?tag=' . urlencode($term) . ']'. $term . '[/url]';
$arr = array();
@@ -161,7 +161,7 @@ EOT;
if((! $blocktags) && (! stristr($item['tag'], ']' . $term . '[' ))) {
q("update item set tag = '%s' where id = %d limit 1",
- dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?search=' . $term . ']'. $term . '[/url]'),
+ dbesc($item['tag'] . (strlen($item['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
intval($item['id'])
);
}
@@ -177,7 +177,7 @@ EOT;
);
if(count($x) && !$x[0]['blocktags'] && (! stristr($r[0]['tag'], ']' . $term . '['))) {
q("update item set tag = '%s' where id = %d limit 1",
- dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?search=' . $term . ']'. $term . '[/url]'),
+ dbesc($r[0]['tag'] . (strlen($r[0]['tag']) ? ',' : '') . '#[url=' . $a->get_baseurl() . '/search?tag=' . $term . ']'. $term . '[/url]'),
intval($r[0]['id'])
);
}