Example #1
0
 /**
  * Respond to requests for podcast feeds
  *
  */
 public function act_feed()
 {
     // Expecting: entire_match, name in handler_vars
     $this->current_url = Site::get_url('habari') . '/' . $this->handler_vars['entire_match'];
     $params = array();
     switch ($this->handler_vars['name']) {
         case 'entries':
             parent::act_collection();
             exit;
         case 'links':
             $params['content_type'] = array(Post::type('link'));
             break;
         case 'all':
             $params['content_type'] = array(Post::type('link'), Post::type('entry'));
             break;
         default:
             $params['content_type'] = array(Post::type($this->handler_vars['name']));
             break;
     }
     parent::get_collection($params);
     exit;
 }
 /**
  * Searches content based on criteria
  * Creates a new Atom feed based on criteria and other parameters (pagination, limit, etc.)
  */
 public function search()
 {
     $criteria = $this->handler_vars['criteria'];
     $page = isset($this->handler_vars['page']) ? $this->handler_vars['page'] : 1;
     $limit = isset($this->handler_vars['count']) ? $this->handler_vars['count'] : Options::get('pagination');
     preg_match_all('/(?<=")(\\w[^"]*)(?=")|(\\w+)/', $criteria, $matches);
     $words = $matches[0];
     $where = 'status = ?';
     $params = array(Post::status('published'));
     foreach ($words as $word) {
         $where .= " AND (title LIKE CONCAT('%',?,'%') OR content LIKE CONCAT('%',?,'%'))";
         $params[] = $word;
         $params[] = $word;
         // Not a typo
     }
     $user_filters = array('where' => $where, 'params' => $params, 'page' => $page, 'criteria' => $criteria, 'limit' => $limit);
     $atomhandler = new AtomHandler();
     $atomhandler->handler_vars['index'] = $page;
     $atomhandler->get_collection($user_filters);
 }