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 $r = q("SELECT COUNT(*) AS `total`
40 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
41 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
42 AND ( `wall` = 1 OR `contact`.`uid` = %d )
43 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
44 AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )
51 $a->set_pager_total($r[0]['total']);
53 if(! $r[0]['total']) {
54 notice('No results.');
58 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
59 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
60 `contact`.`network`, `contact`.`thumb`, `contact`.`self`,
61 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
63 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
64 LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
65 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
66 AND ( `wall` = 1 OR `contact`.`uid` = %d )
67 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
68 AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )
70 ORDER BY `parent` DESC ",
75 $tpl = load_view_file('view/search_item.tpl');
76 $droptpl = load_view_file('view/wall_fake_drop.tpl');
78 $return_url = $_SESSION['return_url'] = $a->cmd;
82 foreach($r as $item) {
90 if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
91 && ($item['id'] != $item['parent']))
94 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
95 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
96 $profile_link = ((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
99 $location = (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
100 $coord = (($item['coord']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
103 $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
105 $location = '<span class="smalltext">' . $coord . '</span>';
108 $drop = replace_macros($droptpl,array('$id' => $item['id']));
109 $lock = '<div class="wall-item-lock"></div>';
111 $o .= replace_macros($tpl,array(
112 '$id' => $item['item_id'],
113 '$profile_url' => $profile_link,
114 '$name' => $profile_name,
115 '$sparkle' => $sparkle,
117 '$thumb' => $profile_avatar,
118 '$title' => $item['title'],
119 '$body' => bbcode($item['body']),
120 '$ago' => relative_date($item['created']),
121 '$location' => $location,
123 '$owner_url' => $owner_url,
124 '$owner_photo' => $owner_photo,
125 '$owner_name' => $owner_name,
127 '$conv' => '<a href="' . $a->get_baseurl() . '/display/' . $item['nickname'] . '/' . $item['id'] . '">' . t('View in context') . '</a>'