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) {
91 if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
92 && ($item['id'] != $item['parent']))
97 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
98 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
99 $profile_link = ((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
102 $location = (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
103 $coord = (($item['coord']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
106 $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
108 $location = '<span class="smalltext">' . $coord . '</span>';
111 $drop = replace_macros($droptpl,array('$id' => $item['id']));
112 $lock = '<div class="wall-item-lock"></div>';
114 $o .= replace_macros($tpl,array(
115 '$id' => $item['item_id'],
116 '$profile_url' => $profile_link,
117 '$name' => $profile_name,
118 '$sparkle' => $sparkle,
120 '$thumb' => $profile_avatar,
121 '$title' => $item['title'],
122 '$body' => bbcode($item['body']),
123 '$ago' => relative_date($item['created']),
124 '$location' => $location,
126 '$owner_url' => $owner_url,
127 '$owner_photo' => $owner_photo,
128 '$owner_name' => $owner_name,
130 '$conv' => '<a href="' . $a->get_baseurl() . '/display/' . $item['nickname'] . '/' . $item['id'] . '">' . t('View in context') . '</a>'
137 if(! $r[0]['total']) {
138 notice('No results.');