4 function search_post(&$a) {
6 $a->data['search'] = $_POST['search'];
10 function search_content(&$a) {
12 if(x($_SESSION,'theme'))
13 unset($_SESSION['theme']);
15 $o = '<div id="live-search"></div>' . "\r\n";
17 $o .= '<h3>' . t('Search') . '</h3>';
19 if(x($a->data,'search'))
20 $search = notags(trim($a->data['search']));
22 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
24 $o .= search($search);
29 require_once("include/bbcode.php");
30 require_once('include/security.php');
33 AND `item`.`allow_cid` = ''
34 AND `item`.`allow_gid` = ''
35 AND `item`.`deny_cid` = ''
36 AND `item`.`deny_gid` = ''
39 $s_bool = "AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )";
40 $s_regx = "AND `item`.`body` REGEXP '%s' ";
42 if(mb_strlen($search) >= 3)
43 $search_alg = $s_bool;
45 $search_alg = $s_regx;
47 $r = q("SELECT COUNT(*) AS `total`
48 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
49 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
50 AND ( `wall` = 1 OR `contact`.`uid` = %d )
51 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
59 $a->set_pager_total($r[0]['total']);
61 if(! $r[0]['total']) {
62 notice( t('No results.') . EOL);
66 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
67 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
68 `contact`.`network`, `contact`.`thumb`, `contact`.`self`,
69 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
71 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
72 LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
73 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
74 AND ( `wall` = 1 OR `contact`.`uid` = %d )
75 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
78 ORDER BY `parent` DESC ",
83 $tpl = load_view_file('view/search_item.tpl');
84 $droptpl = load_view_file('view/wall_fake_drop.tpl');
86 $return_url = $_SESSION['return_url'] = $a->cmd;
90 foreach($r as $item) {
99 if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
100 && ($item['id'] != $item['parent']))
105 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
106 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
107 $profile_link = ((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
110 $location = (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
111 $coord = (($item['coord']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
114 $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
116 $location = '<span class="smalltext">' . $coord . '</span>';
119 $drop = replace_macros($droptpl,array('$id' => $item['id']));
120 $lock = '<div class="wall-item-lock"></div>';
122 $o .= replace_macros($tpl,array(
123 '$id' => $item['item_id'],
124 '$linktitle' => t('View $name\'s profile'),
125 '$profile_url' => $profile_link,
126 '$item_photo_menu' => item_photo_menu($item),
127 '$name' => $profile_name,
128 '$sparkle' => $sparkle,
130 '$thumb' => $profile_avatar,
131 '$title' => $item['title'],
132 '$body' => bbcode($item['body']),
133 '$ago' => relative_date($item['created']),
134 '$location' => $location,
136 '$owner_url' => $owner_url,
137 '$owner_photo' => $owner_photo,
138 '$owner_name' => $owner_name,
140 '$conv' => '<a href="' . $a->get_baseurl() . '/display/' . $item['nickname'] . '/' . $item['id'] . '">' . t('View in context') . '</a>'