aboutsummaryrefslogtreecommitdiffstats
path: root/mod/tagmatch.php
blob: b2313694b0bc252ca431c356fc15a41cd0970735 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php


function tagmatch_content(&$a) {

	$search = $_REQUEST['search'];
	
	$o = '';
	if(! local_user())
		return;

	$o .= '<h2>' . t('Tag Match') . ' - ' . notags($search) . '</h2>';

	
	if($search) {
		$params['s'] = $search;
		if($a->pager['page'] != 1)
			$params['p'] = $a->pager['page'];
			
		if(strlen(get_config('system','directory_submit_url')))
			$x = fetch_url('http://dir.friendika.com/lsearch?f=&search=' . urlencode($search));
//		else
//			$x = post_url($a->get_baseurl() . '/msearch', $params);

		$j = json_decode($x);

		if($j->total) {
			$a->set_pager_total($j->total);
			$a->set_pager_itemspage($j->items_page);
		}

		if(count($j->results)) {
			
			$tpl = get_markup_template('match.tpl');
			foreach($j->results as $jj) {
				
				$o .= replace_macros($tpl,array(
					'$url' => $jj->url,
					'$name' => $jj->name,
					'$photo' => $jj->photo,
					'$tags' => $jj->tags
				));
			}
		}
		else {
			info( t('No matches') . EOL);
		}		

	}

	$o .= '<div class="clear"></div>';
	$o .= paginate($a);
	return $o;
}