From 20c728949ddd7265cc26f9b686344230dfb92414 Mon Sep 17 00:00:00 2001 From: Arslan Hassan Date: Wed, 23 Dec 2009 13:06:42 +0000 Subject: [PATCH] ADDED : NEW SEARCH SYSTEM ADDED : ClipBucket VIDEO search ADDED : ClipBucket GROUPS search ADDED : CLipBucket USERS search FIXED : Minor Bugs MODIFIED : group.html MODIFIED : cb_bbcode.php plugins --- upload/.htaccess | 2 +- upload/groups.php | 2 +- upload/includes/classes/ClipBucket.class.php | 2 + upload/includes/classes/groups.class.php | 87 ++++++++++++++++++ upload/includes/classes/pages.class.php | 2 +- upload/includes/classes/search.class.php | 50 ++++++++++- upload/includes/classes/user.class.php | 85 +++++++++++++++++- upload/includes/classes/video.class.php | 12 ++- upload/includes/common.php | 8 +- upload/includes/config.inc.php | 1 + upload/includes/defined_links.php | 1 + upload/plugins/cb_bbcodes/cb_bbcode.php | 1 + upload/search_result.php | 23 +++-- .../styles/cbv2new/layout/blocks/group.html | 10 +++ .../layout/blocks/group/group_header.html | 4 + .../styles/cbv2new/layout/create_group.html | 89 +++++++++---------- upload/styles/cbv2new/layout/groups.html | 15 ++-- upload/styles/cbv2new/layout/header.html | 5 +- upload/styles/cbv2new/layout/search.html | 78 +++++++++++----- upload/styles/cbv2new/theme/main.css | 8 +- 20 files changed, 377 insertions(+), 108 deletions(-) create mode 100644 upload/styles/cbv2new/layout/blocks/group.html diff --git a/upload/.htaccess b/upload/.htaccess index 66813a8c..50792c83 100644 --- a/upload/.htaccess +++ b/upload/.htaccess @@ -123,7 +123,7 @@ RewriteRule ^group/([a-zA-Z0-9].+) view_group.php?url=$1&%{QUERY_STRING} [L] RewriteRule ^view_topic/([a-zA-Z0-9].+)_tid_([0-9]+) view_topic.php?tid=$2&%{QUERY_STRING} [L] RewriteRule ^groups/([0-9a-z].+)/(.*)/(.*)/(.*)/(.*) groups.php?cat=$1&sort=$3&time=$4&page=$5&seo_cat_name=$2 [L] RewriteRule ^groups groups.php [L] - +RewriteRule ^create_group create_group.php [L] RewriteRule ^sitemap.xml$ sitemap.php diff --git a/upload/groups.php b/upload/groups.php index 36a47abf..41675a5c 100644 --- a/upload/groups.php +++ b/upload/groups.php @@ -41,7 +41,7 @@ switch($sort) break; case "most_commented": { - $g_cond['order'] = " total_posts DESC"; + $g_cond['order'] = " total_topics DESC"; } break; } diff --git a/upload/includes/classes/ClipBucket.class.php b/upload/includes/classes/ClipBucket.class.php index 98089f90..aca5e8bb 100644 --- a/upload/includes/classes/ClipBucket.class.php +++ b/upload/includes/classes/ClipBucket.class.php @@ -28,6 +28,8 @@ class ClipBucket var $links = array(); var $captchas = array(); + var $search_types = array('videos'=>'cbvid','groups'=>'cbgroup','users'=>'userquery'); + /** * All Functions that are called * before after converting a video diff --git a/upload/includes/classes/groups.class.php b/upload/includes/classes/groups.class.php index 4ac8faab..98bf4317 100644 --- a/upload/includes/classes/groups.class.php +++ b/upload/includes/classes/groups.class.php @@ -1829,5 +1829,92 @@ class CBGroups extends CBCategory $count = $db->count($this->gp_tbl,"group_id"," userid='$user' "); $db->update("users",array("total_groups"),array($count)," userid='$user' "); } + + + + + /** + * Function used to use to initialize search object for video section + * op=>operator (AND OR) + */ + function init_search() + { + $this->search = new cbsearch; + $this->search->db_tbl = "groups"; + $this->search->columns =array( + array('field'=>'title','type'=>'LIKE','var'=>'%{KEY}%'), + ); + $this->search->cat_tbl = $this->cat_tbl; + + $this->search->display_template = LAYOUT.'/blocks/group.html'; + $this->search->template_var = 'group'; + $this->search->multi_cat = true; + + /** + * Setting up the sorting thing + */ + + $sorting = array( + 'date_added' => lang("date_added"), + 'total_views' => lang("views"), + 'total_comments' => lang("comments"), + 'total_videos' => lang("videos"), + 'total_members' => lang("total members"), + ); + + $this->search->sorting = array( + 'date_added'=> " date_added DESC", + 'total_views' => " total_views DESC", + 'total_comments' => " total_comments DESC ", + 'total_videos' => " total_videos DESC", + 'total_members' => " total_members DESC", + ); + /** + * Setting Up The Search Fields + */ + + $default = $_GET; + if(is_array($default['category'])) + $cat_array = array($default['category']); + $uploaded = $default['datemargin']; + $sort = $default['sort']; + + $this->search->search_type['groups'] = array('title'=>'Groups'); + + $fields = array( + 'keyword' => array( + 'title'=> lang('keywords'), + 'type'=> 'textfield', + 'name'=> 'keywords', + 'id'=> 'keywords', + 'value'=>cleanForm($default['keywords']) + ), + 'category' => array( + 'title' => lang('vdo_cat'), + 'type' => 'checkbox', + 'name' => 'category[]', + 'id' => 'category', + 'value' => array('category',$cat_array), + 'category_type'=>'group', + ), + 'date_margin' => array( + 'title' => lang('Joined'), + 'type' => 'dropdown', + 'name' => 'datemargin', + 'id' => 'datemargin', + 'value' => $this->search->date_margins(), + 'checked' => $uploaded, + ), + 'sort' => array( + 'title' => lang('sort_by'), + 'type' => 'dropdown', + 'name' => 'sort', + 'value' => $sorting, + 'checked' => $sort + ) + ); + + $this->search->search_type['groups']['fields'] = $fields; + } } ?> \ No newline at end of file diff --git a/upload/includes/classes/pages.class.php b/upload/includes/classes/pages.class.php index 3574dd29..f179f77f 100644 --- a/upload/includes/classes/pages.class.php +++ b/upload/includes/classes/pages.class.php @@ -160,7 +160,7 @@ class pages{ $params = 'href="'.$link.'"'; $params .= ' '.$extra_params; - if(SEO=='yes') + if(SEO=='yes' && THIS_PAGE !='search_result') { if(count($_GET)==0 || (count($_GET)==1 && isset($_GET['page']))) $params = $params; diff --git a/upload/includes/classes/search.class.php b/upload/includes/classes/search.class.php index 792d2f2f..ef1f8dd7 100644 --- a/upload/includes/classes/search.class.php +++ b/upload/includes/classes/search.class.php @@ -45,6 +45,43 @@ class cbsearch var $total_results = 0; + + var $multi_cat = true; + + var $date_added_colum = 'date_added'; + + /** + * ClipBucket Search System works pretty easily + * 1. It loads the appropriate class which defines what kind of search to perform and how to operate it + * 2. Gets the result and save it in variable + * 3. Loop results and assign VARIABLE.DATA to TEMPLATE_VAR + * 4. Call display_template to show the result + */ + + var $display_template = ''; + var $template_var = ''; + + /** + * INITIATION SEARCH + */ + function init_search($type='video') + { + global $Cbucket; + if($Cbucket->search_types[$type]) + { + $obj = $Cbucket->search_types[$type]; + global ${$obj}; + ${$obj}->init_search(); + return ${$obj}->search; + }else + { + global $cbvid; + $cbvid->init_search(); + return $cbvid->search; + } + } + + /** * Variable to hold search query condition */ @@ -61,12 +98,12 @@ class cbsearch #Checking for category if(isset($this->category)) { - $this->cat_to_query($this->category); + $this->cat_to_query($this->category,$this->multi_cat); } #Setting Date Margin if($this->date_margin!='') { - $this->add_cond('('.$this->date_margin().')'); + $this->add_cond('('.$this->date_margin($this->date_added_colum).')'); } #Sorting @@ -84,6 +121,7 @@ class cbsearch $results = $db->select($this->db_tbl,'*',$condition,$this->limit,$sorting); $this->total_results = $db->count($this->db_tbl,'*',$condition); + return $results; } @@ -134,7 +172,7 @@ class cbsearch * Category to query * fucntion used to covert category to query */ - function cat_to_query($input) + function cat_to_query($input,$multi=TRUE) { if(!empty($input)) { @@ -148,7 +186,11 @@ class cbsearch { if(!empty($query)) $query .=" OR "; - $query .=" category LIKE '%#$cat#%' "; + + if($multi) + $query .=" category LIKE '%#$cat#%' "; + else + $query .=" category = '$cat' "; } if(count($this->query_conds)>0) diff --git a/upload/includes/classes/user.class.php b/upload/includes/classes/user.class.php index 31b4af7c..277f4790 100644 --- a/upload/includes/classes/user.class.php +++ b/upload/includes/classes/user.class.php @@ -2610,7 +2610,7 @@ class userquery extends CBCategory{ 'Groups' =>array ( 'Manage Groups'=>'manage_groups.php', - 'Create new group'=>'create_group.php', + 'Create new group'=>cblink(array('name'=>'create_group')), 'Joined Groups'=>'manage_groups.php?mode=joined', ), 'Playlist'=>array @@ -3352,5 +3352,88 @@ class userquery extends CBCategory{ else return false; } + + /** + * Function used to use to initialize search object for video section + * op=>operator (AND OR) + */ + function init_search() + { + $this->search = new cbsearch; + $this->search->db_tbl = "users"; + $this->search->columns =array( + array('field'=>'username','type'=>'LIKE','var'=>'%{KEY}%'), + ); + $this->search->cat_tbl = $this->cat_tbl; + + $this->search->display_template = LAYOUT.'/blocks/user.html'; + $this->search->template_var = 'user'; + $this->search->multi_cat = false; + $this->search->date_added_colum = 'doj'; + + /** + * Setting up the sorting thing + */ + + $sorting = array( + 'doj' => lang("date_added"), + 'profile_hits' => lang("views"), + 'total_comments' => lang("comments"), + 'total_videos' => lang("videos"), + ); + + $this->search->sorting = array( + 'doj'=> " doj DESC", + 'profile_hits' => " profile_hits DESC", + 'total_comments' => " total_comments DESC ", + 'total_videos' => " total_videos DESC", + ); + /** + * Setting Up The Search Fields + */ + + $default = $_GET; + if(is_array($default['category'])) + $cat_array = array($default['category']); + $uploaded = $default['datemargin']; + $sort = $default['sort']; + + $this->search->search_type['users'] = array('title'=>'Users'); + + $fields = array( + 'keyword' => array( + 'title'=> lang('keywords'), + 'type'=> 'textfield', + 'name'=> 'keywords', + 'id'=> 'keywords', + 'value'=>cleanForm($default['keywords']) + ), + 'category' => array( + 'title' => lang('vdo_cat'), + 'type' => 'checkbox', + 'name' => 'category[]', + 'id' => 'category', + 'value' => array('category',$cat_array), + 'category_type'=>'user', + ), + 'date_margin' => array( + 'title' => lang('Joined'), + 'type' => 'dropdown', + 'name' => 'datemargin', + 'id' => 'datemargin', + 'value' => $this->search->date_margins(), + 'checked' => $uploaded, + ), + 'sort' => array( + 'title' => lang('sort_by'), + 'type' => 'dropdown', + 'name' => 'sort', + 'value' => $sorting, + 'checked' => $sort + ) + ); + + $this->search->search_type['users']['fields'] = $fields; + } } ?> \ No newline at end of file diff --git a/upload/includes/classes/video.class.php b/upload/includes/classes/video.class.php index dd51b01a..4f047e09 100644 --- a/upload/includes/classes/video.class.php +++ b/upload/includes/classes/video.class.php @@ -599,12 +599,15 @@ class CBvideo extends CBCategory function init_search() { $this->search = new cbsearch; - $this->search->db_tbl = "video"; + $this->search->db_tbl = "video";; $this->search->columns =array( array('field'=>'title','type'=>'LIKE','var'=>'%{KEY}%'), - array('field'=>'tags','type'=>'LIKE','var'=>'%{KEY}%','op'=>'OR') + array('field'=>'tags','type'=>'LIKE','var'=>'%{KEY}%','op'=>'AND') ); $this->search->cat_tbl = $this->cat_tbl; + + $this->search->display_template = LAYOUT.'/blocks/video.html'; + $this->search->template_var = 'video'; /** * Setting up the sorting thing @@ -635,7 +638,8 @@ class CBvideo extends CBCategory $uploaded = $default['datemargin']; $sort = $default['sort']; - $this->search->search_type['video'] = array('title'=>'Video'); + $this->search->search_type['videos'] = array('title'=>'Videos'); + $fields = array( 'keyword' => array( 'title'=> lang('keywords'), @@ -668,7 +672,7 @@ class CBvideo extends CBCategory ) ); - $this->search->search_type['video']['fields'] = $fields; + $this->search->search_type['videos']['fields'] = $fields; } diff --git a/upload/includes/common.php b/upload/includes/common.php index 0d69b8bd..f3f15877 100644 --- a/upload/includes/common.php +++ b/upload/includes/common.php @@ -437,13 +437,7 @@ $Smarty->register_modifier('get_age','get_age'); $Smarty->register_modifier('outgoing_link','outgoing_link'); $Smarty->register_modifier('nicetime','nicetime'); $Smarty->register_modifier('country','get_country'); - - - -/** - * Initializing Search - */ - $cbvideo->init_search(); +$Smarty->register_modifier('cbsearch',new cbsearch()); /* diff --git a/upload/includes/config.inc.php b/upload/includes/config.inc.php index 0dd8037a..66ecdb91 100644 --- a/upload/includes/config.inc.php +++ b/upload/includes/config.inc.php @@ -21,6 +21,7 @@ Assign('admtheme',BASEURL.'/'.ADMINDIR.'/'.TEMPLATEFOLDER.'/'.TEMPLATE.'/theme') Assign('template_dir',TEMPLATEDIR); Assign('style_dir',LAYOUT); + //Checking Website is closed or not if($row['closed'] == 1){ diff --git a/upload/includes/defined_links.php b/upload/includes/defined_links.php index 15fe03b9..ff42bef5 100644 --- a/upload/includes/defined_links.php +++ b/upload/includes/defined_links.php @@ -8,6 +8,7 @@ $Cbucket->links = array ( 'channels' =>array('channels.php','channels'), +'create_group'=>array('create_group.php','create_group'), 'groups' =>array('groups.php','groups'), 'inbox' =>array('private_message.php?mode=inbox','private_message.php?mode=inbox'), 'login' =>array('signup.php','login'), diff --git a/upload/plugins/cb_bbcodes/cb_bbcode.php b/upload/plugins/cb_bbcodes/cb_bbcode.php index 105bae00..7971e9a1 100644 --- a/upload/plugins/cb_bbcodes/cb_bbcode.php +++ b/upload/plugins/cb_bbcodes/cb_bbcode.php @@ -40,6 +40,7 @@ if(!function_exists('bb_to_html')) //Registering Action that will be applied while displaying comment and or description register_action(array('bb_to_html'=>array('comment','description','pm_compose_box','before_topic_post_box'))); + //Registerin Anchors , that will be displayed before compose boxes register_anchor("",'before_compose_box'); register_anchor("",'before_reply_compose_box'); diff --git a/upload/search_result.php b/upload/search_result.php index a05432bd..f6f567da 100644 --- a/upload/search_result.php +++ b/upload/search_result.php @@ -6,18 +6,20 @@ | @ Software : ClipBucket , © PHPBucket.com | **************************************************************************************************** */ -define('THIS_PAGE','search'); +define('THIS_PAGE','search_result'); require 'includes/config.inc.php'; $pages->page_redir(); $page = mysql_clean($_GET['page']); -$cbvid->search->key = $_GET['keywords']; -$cbvid->search->category = $_GET['category']; -$cbvid->search->date_margin = $_GET['datemargin']; -$cbvid->search->sort_by = $_GET['sort']; -$cbvid->search->limit = create_query_limit($page,VLISTPP); -$videos = $cbvid->search->search(); +$type = $_GET['type']; +$search = cbsearch::init_search($type); +$search->key = $_GET['keywords']; +$search->category = $_GET['category']; +$search->date_margin = $_GET['datemargin']; +$search->sort_by = $_GET['sort']; +$search->limit = create_query_limit($page,VLISTPP); +$results = $search->search(); //Collecting Data for Pagination $total_rows = $cbvid->search->total_results; @@ -25,7 +27,12 @@ $total_pages = count_pages($total_rows,VLISTPP); //Pagination $pages->paginate($total_pages,$page); -Assign('videos', $videos); + + +Assign('results',$results ); +Assign('template_var',$search->template_var); +Assign('display_template',$search->display_template); +Assign('search_type_title',$search->search_type[$type]['title']); //Displaying The Template diff --git a/upload/styles/cbv2new/layout/blocks/group.html b/upload/styles/cbv2new/layout/blocks/group.html new file mode 100644 index 00000000..18d3b09c --- /dev/null +++ b/upload/styles/cbv2new/layout/blocks/group.html @@ -0,0 +1,10 @@ +{assign var=owner value=$userquery->get_user_details($group.userid)} +
+ + {$group.group_name} + views : {$group.total_views|number_format} + total members :{$group.total_members|number_format} + total videos : {$group.total_videos|number_format} + discussions : {$group.total_topics|number_format} + owner : {$owner.username} +
diff --git a/upload/styles/cbv2new/layout/blocks/group/group_header.html b/upload/styles/cbv2new/layout/blocks/group/group_header.html index cde571da..93449d67 100644 --- a/upload/styles/cbv2new/layout/blocks/group/group_header.html +++ b/upload/styles/cbv2new/layout/blocks/group/group_header.html @@ -99,9 +99,11 @@ @@ -110,9 +112,11 @@ diff --git a/upload/styles/cbv2new/layout/create_group.html b/upload/styles/cbv2new/layout/create_group.html index f0675f68..f94615cb 100644 --- a/upload/styles/cbv2new/layout/create_group.html +++ b/upload/styles/cbv2new/layout/create_group.html @@ -3,50 +3,47 @@ {assign var='customFields' value=$cbgroup->custom_group_fields} - - - - - - - -
{$LANG.grp_crt_grp}
- - - - -
- - {foreach from=$requiredFields item=field} - - - - - {/foreach} - {foreach from=$customFields item=field} - - - - - {/foreach}{foreach from=$optionFields item=field} - - - - - {/foreach} - - - - -
{$field.title}* :{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)} -
- {$field.hint_2}
{$field.title}* :{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)} -
- {$field.hint_2}
{$field.title}* :{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)} -
- {$field.hint_2}
 
-
-
{$ads.ad_336x280}
+
+
+

Create Group Option

+
+ + +
+ required fields + {foreach from=$requiredFields item=field} +
+ + {if $field.hint_1}
{$field.hint_1}

{/if}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)} + {if $field.hint_2}
+
{$field.hint_2}
{/if} +
+ {/foreach} + +
+ + + + + More Options + + +
+
+
+
diff --git a/upload/styles/cbv2new/layout/groups.html b/upload/styles/cbv2new/layout/groups.html index 7ff1a512..df9fc97b 100644 --- a/upload/styles/cbv2new/layout/groups.html +++ b/upload/styles/cbv2new/layout/groups.html @@ -25,17 +25,12 @@ {/foreach} +
+CREATE NEW GROUP +
+ {section name=glist loop=$groups} -{assign var=owner value=$userquery->get_user_details($groups[glist].userid)} -
- - {$groups[glist].group_name} - views : {$groups[glist].total_views|number_format} - total members :{$groups[glist].total_views|number_format} - total videos : {$groups[glist].total_videos|number_format} - discussions : {$groups[glist].total_members|number_format} - owner : {$owner.username} -
+ {include file="$style_dir/blocks/group.html" video=$groups[glist]} {/section} diff --git a/upload/styles/cbv2new/layout/header.html b/upload/styles/cbv2new/layout/header.html index bcaeea8e..d30ec1d1 100644 --- a/upload/styles/cbv2new/layout/header.html +++ b/upload/styles/cbv2new/layout/header.html @@ -2,9 +2,8 @@