123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137 |
- <?php
- if (!defined('GNUSOCIAL')) { exit(1); }
- class ApiSearchJSONAction extends ApiPrivateAuthAction
- {
- var $query;
- var $lang;
- var $rpp;
- var $page;
- var $since_id;
- var $limit;
- var $geocode;
-
- function prepare(array $args = array())
- {
- parent::prepare($args);
- $this->query = $this->trimmed('q');
- $this->lang = $this->trimmed('lang');
- $this->rpp = $this->trimmed('rpp');
- if (!$this->rpp) {
- $this->rpp = 15;
- }
- if ($this->rpp > 100) {
- $this->rpp = 100;
- }
- $this->page = $this->trimmed('page');
- if (!$this->page) {
- $this->page = 1;
- }
-
-
- $this->since_id = $this->trimmed('since_id');
- $this->geocode = $this->trimmed('geocode');
- return true;
- }
-
- function handle()
- {
- parent::handle();
- $this->showResults();
- }
-
- function showResults()
- {
-
- $notice = new Notice();
- $this->notices = array();
- $search_engine = $notice->getSearchEngine('notice');
- $search_engine->set_sort_mode('chron');
- $search_engine->limit(($this->page - 1) * $this->rpp, $this->rpp + 1);
- if ($search_engine->query($this->query)) {
- $cnt = $notice->find();
- $this->notices = $notice->fetchAll();
- }
- $this->showJsonTimeline($this->notices);
- }
-
- function isReadOnly($args)
- {
- return true;
- }
- }
|