4 function search_content(&$a) {
6 $o = '<div id="live-search"></div>' . "\r\n";
8 $o .= '<h3>' . t('Search') . '</h3>';
10 $search = ((x($_GET,'search')) ? rawurldecode($_GET['search']) : '');
12 $o .= search($search);
17 require_once("include/bbcode.php");
18 require_once('include/security.php');
21 AND `item`.`allow_cid` = ''
22 AND `item`.`allow_gid` = ''
23 AND `item`.`deny_cid` = ''
24 AND `item`.`deny_gid` = ''
27 $r = q("SELECT COUNT(*) AS `total`
28 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
29 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
30 AND ( `wall` = 1 OR `contact`.`uid` = %d )
31 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
32 AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )
39 $a->set_pager_total($r[0]['total']);
41 if(! $r[0]['total']) {
42 notice('No results.');
46 $r = q("SELECT `item`.*, `item`.`id` AS `item_id`,
47 `contact`.`name`, `contact`.`photo`, `contact`.`url`, `contact`.`rel`,
48 `contact`.`network`, `contact`.`thumb`, `contact`.`self`,
49 `contact`.`id` AS `cid`, `contact`.`uid` AS `contact-uid`,
51 FROM `item` LEFT JOIN `contact` ON `contact`.`id` = `item`.`contact-id`
52 LEFT JOIN `user` ON `user`.`uid` = `item`.`uid`
53 WHERE `item`.`visible` = 1 AND `item`.`deleted` = 0
54 AND ( `wall` = 1 OR `contact`.`uid` = %d )
55 AND `contact`.`blocked` = 0 AND `contact`.`pending` = 0
56 AND MATCH (`item`.`body`) AGAINST ( '%s' IN BOOLEAN MODE )
58 ORDER BY `parent` DESC ",
63 $tpl = load_view_file('view/search_item.tpl');
64 $droptpl = load_view_file('view/wall_fake_drop.tpl');
66 $return_url = $_SESSION['return_url'] = $a->cmd;
70 foreach($r as $item) {
78 if(((activity_match($item['verb'],ACTIVITY_LIKE)) || (activity_match($item['verb'],ACTIVITY_DISLIKE)))
79 && ($item['id'] != $item['parent']))
82 $profile_name = ((strlen($item['author-name'])) ? $item['author-name'] : $item['name']);
83 $profile_avatar = ((strlen($item['author-avatar'])) ? $item['author-avatar'] : $item['thumb']);
84 $profile_link = ((strlen($item['author-link'])) ? $item['author-link'] : $item['url']);
87 $location = (($item['location']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['location']) . '">' . $item['location'] . '</a>' : '');
88 $coord = (($item['coord']) ? '<a target="map" href="http://maps.google.com/?q=' . urlencode($item['coord']) . '">' . $item['coord'] . '</a>' : '');
91 $location .= '<br /><span class="smalltext">(' . $coord . ')</span>';
93 $location = '<span class="smalltext">' . $coord . '</span>';
96 $drop = replace_macros($droptpl,array('$id' => $item['id']));
97 $lock = '<div class="wall-item-lock"></div>';
99 $o .= replace_macros($tpl,array(
100 '$id' => $item['item_id'],
101 '$profile_url' => $profile_link,
102 '$name' => $profile_name,
103 '$sparkle' => $sparkle,
105 '$thumb' => $profile_avatar,
106 '$title' => $item['title'],
107 '$body' => bbcode($item['body']),
108 '$ago' => relative_date($item['created']),
109 '$location' => $location,
111 '$owner_url' => $owner_url,
112 '$owner_photo' => $owner_photo,
113 '$owner_name' => $owner_name,
115 '$conv' => '<a href="' . $a->get_baseurl() . '/display/' . $item['nickname'] . '/' . $item['id'] . '">' . t('View in context') . '</a>'