From e788f88e8475e9c87eef355c71abed3c329c4c0b Mon Sep 17 00:00:00 2001 From: Calin Burloiu Date: Mon, 5 Sep 2011 15:11:51 +0300 Subject: [PATCH] search improved but not finished --- application/config/autoload.php | 4 +- application/controllers/catalog.php | 4 +- application/controllers/video.php | 2 - application/libraries/Html_head_params.php | 1 - application/models/videos_model.php | 12 +-- application/views/header.php | 117 +++++++++++++++++---- system/core/Controller.php | 4 +- system/core/Model.php | 4 +- 8 files changed, 111 insertions(+), 37 deletions(-) diff --git a/application/config/autoload.php b/application/config/autoload.php index 68acde8..bac0142 100644 --- a/application/config/autoload.php +++ b/application/config/autoload.php @@ -52,7 +52,7 @@ $autoload['packages'] = array(APPPATH.'third_party'); | $autoload['libraries'] = array('database', 'session', 'xmlrpc'); */ -$autoload['libraries'] = array(); +$autoload['libraries'] = array('form_validation'); /* @@ -64,7 +64,7 @@ $autoload['libraries'] = array(); | $autoload['helper'] = array('url', 'file'); */ -$autoload['helper'] = array(); +$autoload['helper'] = array('url', 'form'); /* diff --git a/application/controllers/catalog.php b/application/controllers/catalog.php index 0248f9e..816be74 100644 --- a/application/controllers/catalog.php +++ b/application/controllers/catalog.php @@ -145,12 +145,14 @@ class Catalog extends CI_Controller { public function search($str_search = "") { // TODO get query string from URL. - $str_search = $this->input->post('search', TRUE); + if ($str_search === "") + redirect('catalog/search/'. $this->input->post('search', TRUE)); // ** // ** LOADING MODEL // ** // Video Category + // TODO $vs_data['category_name'] = ""; $vs_data['category_title'] = "Search Results for «$str_search»"; diff --git a/application/controllers/video.php b/application/controllers/video.php index 3637f14..4a15ba5 100644 --- a/application/controllers/video.php +++ b/application/controllers/video.php @@ -31,8 +31,6 @@ class Video extends CI_Controller { */ public function watch($id, $name = NULL, $plugin = NULL) { - $this->load->helper('url'); - // ** // ** LOADING MODEL // ** diff --git a/application/libraries/Html_head_params.php b/application/libraries/Html_head_params.php index d729d88..08a792d 100644 --- a/application/libraries/Html_head_params.php +++ b/application/libraries/Html_head_params.php @@ -47,7 +47,6 @@ class Html_head_params { public function __construct($params) { $CI =& get_instance(); - $CI->load->helper('url'); if (isset($this->site_config)) $CI->load->config($this->site_config); diff --git a/application/models/videos_model.php b/application/models/videos_model.php index c887b70..0d9fe7b 100644 --- a/application/models/videos_model.php +++ b/application/models/videos_model.php @@ -16,8 +16,6 @@ class Videos_model extends CI_Model { $this->load->library('singleton_db'); $this->db = $this->singleton_db->connect(); } - - $this->load->helper('url'); } /** @@ -208,23 +206,23 @@ class Videos_model extends CI_Model { $count = 100; $str_search = trim($str_search); - - $this->load->helper('text'); $query = $this->db->query( "SELECT id, name, title, duration, user_id, views, thumbs_count, default_thumb FROM `videos` - WHERE title LIKE '%". $str_search . "%' + WHERE MATCH (title, description, tags) AGAINST (?) ORDER BY name - LIMIT ?, ?", // TODO summary order - array($offset, $count)); + LIMIT ?, ?", + array($str_search, $offset, $count)); if ($query->num_rows() > 0) $videos = $query->result_array(); else return NULL; + $this->load->helper('text'); + foreach ($videos as & $video) { // P2P-Tube Video URL diff --git a/application/views/header.php b/application/views/header.php index 7659482..d7b616e 100644 --- a/application/views/header.php +++ b/application/views/header.php @@ -1,23 +1,40 @@ - -