Exemple #1
0
 /**
 * Осуществляет поиск по тэгу. В случае, если пользователь не указал параметр поиска - перенаправляет в раздел статей.
 */
 public function action_search()
 {
     if ($this->request->param('query')) {
         $query = $this->request->param('query');
         $this->title = 'Поиск по тэгу: ' . $query;
         $tags_obj = new Model_Tags();
         $result = $tags_obj->search_by_query($query);
         if ($result !== NULL) {
             $this->view["articles"] = DB::select('*')->from('Articles')->where('id', 'IN', $result)->and_where('is_removed', '=', 0)->order_by('id', 'DESC')->execute();
             $content = View::factory('templates/articles/list', $this->view);
             $this->template->content = View::factory("templates/articles/wrapper", array("active" => "allArticles", "content" => $content));
         } else {
             $this->template->content = 'Ooops! Nothing has been found.';
         }
     } else {
         $this->redirect('article', 302);
     }
 }
Exemple #2
0
 public function action_initial()
 {
     $inner_route = $this->request->param('inner_route');
     $tags_obj = new Model_Tags();
     if ($inner_route == null || $inner_route == 'list') {
         $this->title = 'Список тэгов';
         $tags_obj->tags_list('all');
         $this->template->content = var_dump($tags_obj->tag_name);
     }
     if ($inner_route == 'search') {
         $this->title = 'Поиск по тэгам';
         $query = "ftag,thtag";
         $queries = explode(",", $query);
         for ($i = 0; $i < count($queries); ++$i) {
             $tags_obj->search_by_query($queries[$i]);
             $output[$i] = $tags_obj->found_article_id;
         }
         $this->template->content = var_dump($output);
     }
 }