4 function search_post(&$a) {
6 $a->data['search'] = $_POST['search'];
10 function search_content(&$a) {
12 $o = '<div id="live-search"></div>' . "\r\n";
14 $o .= '<h3>' . t('Search') . '</h3>';
16 if(x($a->data,'search'))
17 $search = notags(trim($a->data['search']));
19 $search = ((x($_GET,'search')) ? notags(trim(rawurldecode($_GET['search']))) : '');
21 $o .= search($search);
26 require_once("include/bbcode.php");
27 require_once('include/security.php');
30 AND `item`.`allow_cid` = ''
31 AND `item`.`allow_gid` = ''
32 AND `item`.`deny_cid` = ''
33 AND `item`.`deny_gid` = ''
36 $r = q("SELECT COUNT(*) AS `total`
37 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
38 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
39 AND ( `wall` = 1 OR `contact`.`uid` = %d )
40 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
41 AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )
48 $a->set_pager_total($r[0]['total']);
50 if(! $r[0]['total']) {
51 notice('No results.');
55 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
56 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
57 `contact`.`network`, `contact`.`thumb`, `contact`.`self`,
58 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
60 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
61 LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
62 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
63 AND ( `wall` = 1 OR `contact`.`uid` = %d )
64 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
65 AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )
67 ORDER BY `parent` DESC ",
72 $tpl = load_view_file('view/search_item.tpl');
73 $droptpl = load_view_file('view/wall_fake_drop.tpl');
75 $return_url = $_SESSION['return_url'] = $a->cmd;
79 foreach($r as $item) {
87 if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
88 && ($item['id'] != $item['parent']))
91 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
92 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
93 $profile_link = ((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
96 $location = (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
97 $coord = (($item['coord']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
100 $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
102 $location = '<span class="smalltext">' . $coord . '</span>';
105 $drop = replace_macros($droptpl,array('$id' => $item['id']));
106 $lock = '<div class="wall-item-lock"></div>';
108 $o .= replace_macros($tpl,array(
109 '$id' => $item['item_id'],
110 '$profile_url' => $profile_link,
111 '$name' => $profile_name,
112 '$sparkle' => $sparkle,
114 '$thumb' => $profile_avatar,
115 '$title' => $item['title'],
116 '$body' => bbcode($item['body']),
117 '$ago' => relative_date($item['created']),
118 '$location' => $location,
120 '$owner_url' => $owner_url,
121 '$owner_photo' => $owner_photo,
122 '$owner_name' => $owner_name,
124 '$conv' => '<a href="' . $a->get_baseurl() . '/display/' . $item['nickname'] . '/' . $item['id'] . '">' . t('View in context') . '</a>'