From d73972e8e26d2155a49ef7fe01dda0af85112e09 Mon Sep 17 00:00:00 2001 From: friendica Date: Mon, 26 Jan 2015 17:09:33 -0800 Subject: provide a json feed of search results --- mod/search.php | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) (limited to 'mod/search.php') diff --git a/mod/search.php b/mod/search.php index 2ea6ad86f..5b15b0593 100644 --- a/mod/search.php +++ b/mod/search.php @@ -21,6 +21,10 @@ function search_content(&$a,$update = 0, $load = false) { require_once('include/conversation.php'); require_once('include/items.php'); + $format = (($_REQUEST['format']) ? $_REQUEST['format'] : ''); + if($format !== '') { + $update = $load = 1; + } $observer = $a->get_observer(); $observer_hash = (($observer) ? $observer['xchan_hash'] : ''); @@ -179,6 +183,19 @@ function search_content(&$a,$update = 0, $load = false) { $items = array(); } + + if($format == 'json') { + $result = array(); + require_once('include/conversation.php'); + foreach($items as $item) { + $item['html'] = bbcode($item['body']); + $x = encode_item($item); + $x['html'] = prepare_text($item['body'],$item['mimetype']); + $result[] = $x; + } + json_return_and_die(array('success' => true,'messages' => $result)); + } + if($tag) $o .= '

Items tagged with: ' . htmlspecialchars($search, ENT_COMPAT,'UTF-8') . '

'; else -- cgit v1.2.3