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
This commit is contained in:
Arslan Hassan 2009-12-23 13:06:42 +00:00
parent 7888c52e44
commit 20c728949d
20 changed files with 377 additions and 108 deletions

View file

@ -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

View file

@ -41,7 +41,7 @@ switch($sort)
break;
case "most_commented":
{
$g_cond['order'] = " total_posts DESC";
$g_cond['order'] = " total_topics DESC";
}
break;
}

View file

@ -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

View file

@ -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;
}
}
?>

View file

@ -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;

View file

@ -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)

View file

@ -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;
}
}
?>

View file

@ -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;
}

View file

@ -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());
/*

View file

@ -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){

View file

@ -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'),

View file

@ -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("<script>edToolbar('comment_box'); </script>",'before_compose_box');
register_anchor("<script>edToolbar('comment_box-reply'); </script>",'before_reply_compose_box');

View file

@ -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

View file

@ -0,0 +1,10 @@
{assign var=owner value=$userquery->get_user_details($group.userid)}
<div class="group_block">
<a href="{group_link details=$group}"><img src="{$cbgroup->get_group_thumb($group)}" class="group_thumb" /></a>
<span class="group_name"><strong><a href="{group_link details=$group}">{$group.group_name}</a></strong></span>
<span> views : <strong>{$group.total_views|number_format}</strong></span>
<span>total members :<strong>{$group.total_members|number_format}</strong></span>
<span>total videos : <strong>{$group.total_videos|number_format}</strong></span>
<span>discussions : <strong>{$group.total_topics|number_format}</strong></span>
<span>owner : <strong><a href="{$userquery->profile_link($owner)}">{$owner.username}</a></strong></span>
</div>

View file

@ -99,9 +99,11 @@
<!-- Group members-->
<div id="members" class="grp_info" style="display:none">
{assign var=members value=$cbgroup->get_members($group.group_id)}
{if $members}
{foreach from=$members item=member}
{include file="$style_dir/blocks/user.html" user=$member block_type='medium'}
{/foreach}
{/if}
<div class="clearfix"></div>
<div align="right"><a href="{group_link details=$group type='view_members'}">View All Members</a></div>
</div>
@ -110,9 +112,11 @@
<!-- Group videos-->
<div id="videos" class="grp_info" style="display:none">
{assign var=gpvids value=$cbgroup->get_group_videos($group.group_id,'yes',6)}
{if $gpvids}
{foreach from=$gpvids item=video}
{include file="$style_dir/blocks/video.html" video=$video}
{/foreach}
{/if}
<div class="clearfix"></div>
<div align="right"><a href="{group_link details=$group type='view_videos'}">View All Videos</a></div>
</div>

View file

@ -3,50 +3,47 @@
{assign var='customFields' value=$cbgroup->custom_group_fields}
<table width="950" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td class="header1">{$LANG.grp_crt_grp}</td>
</tr>
<tr>
<td><table width="98%" border="0" align="center" cellpadding="0" cellspacing="0">
<tr>
<td width="66%" valign="top"><form name="form1" method="post" action="">
<table width="90%" border="0" cellspacing="0" cellpadding="5">
{foreach from=$requiredFields item=field}
<tr>
<td width="117" align="right" valign="top" class="header3">{$field.title}* :</td>
<td class="tips">{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)}
<br>
{$field.hint_2}</td>
</tr>
{/foreach}
{foreach from=$customFields item=field}
<tr>
<td width="117" align="right" valign="top" class="header3">{$field.title}* :</td>
<td class="tips">{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)}
<br>
{$field.hint_2}</td>
</tr>
{/foreach}{foreach from=$optionFields item=field}
<tr>
<td width="117" align="right" valign="top" class="header3">{$field.title}* :</td>
<td class="tips">{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)}
<br>
{$field.hint_2}</td>
</tr>
{/foreach}
<tr>
<td align="right" valign="top" class="header2">&nbsp;</td>
<td><label>
<input type="submit" name="create_group" value="{$LANG.grp_crt_grp}" id="button">
</label></td>
</tr>
</table>
</form>
</td>
<td width="34%" align="center" valign="top">{$ads.ad_336x280}</td>
</tr>
</table></td>
</tr>
</table>
<div class="upload_left" style="margin-bottom:10px">
<div class="upload_info">
<h2>Create Group Option</h2>
<form name="upload_form" class="upload_form" method="post" action="">
<!-- Required Fields -->
<fieldset>
<span class="form_head">required fields</span>
{foreach from=$requiredFields item=field}
<div class="field">
<label for="{$field.id}" class="label">{$field.title}</label>
{if $field.hint_1}<div class="hint">{$field.hint_1}</div><br>{/if}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)}
{if $field.hint_2}<br>
<div class="hint">{$field.hint_2}</div>{/if}
</div>
{/foreach}
</fieldset>
<!-- Required Fields -->
<div id="more_fields" style="display:none">
<!-- MORE Fields -->
<fieldset>
<span class="form_head">more options</span>
{foreach from=$optionFields item=field}
<div class="field">
<label for="{$field.id}" class="label">{$field.title}</label>
{if $field.hint_1}<div class="hint">{$field.hint_1}</div><br>{/if}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)}
{if $field.hint_2}<br>
<div class="hint">{$field.hint_2}</div>{/if}
</div>
{/foreach}
</fieldset>
<!-- MORE Fields -->
</div>
<span class="more_button"><a href="javascript:void()" onClick="$('#more_fields').slideToggle();$('.more_button').toggleClass('more_button_up');">More Options</a></span>
<div align="right" style="margin-top:10px"><input type="submit" name="create_group" value="{$LANG.grp_crt_grp}" class="cb_button_2"></div>
</form>
</div>
</div>

View file

@ -25,17 +25,12 @@
{/foreach}
</div>
<div class="time_cont" align="right">
<span class="cb_fb_style_button"><a href="{link name='create_group'}">CREATE NEW GROUP</a></span>
</div>
{section name=glist loop=$groups}
{assign var=owner value=$userquery->get_user_details($groups[glist].userid)}
<div class="group_block">
<a href="{group_link details=$groups[glist]}"><img src="{$cbgroup->get_group_thumb($groups[glist])}" class="group_thumb" /></a>
<span class="group_name"><strong><a href="{group_link details=$groups[glist]}">{$groups[glist].group_name}</a></strong></span>
<span> views : <strong>{$groups[glist].total_views|number_format}</strong></span>
<span>total members :<strong>{$groups[glist].total_views|number_format}</strong></span>
<span>total videos : <strong>{$groups[glist].total_videos|number_format}</strong></span>
<span>discussions : <strong>{$groups[glist].total_members|number_format}</strong></span>
<span>owner : <strong><a href="{$userquery->profile_link($owner)}">{$owner.username}</a></strong></span>
</div>
{include file="$style_dir/blocks/group.html" video=$groups[glist]}
{/section}
</div>

View file

@ -2,9 +2,8 @@
<div id="quicklist_box" class="quicklist_box"></div>
<div id="header">
<div class="logo">
<img src="{$imageurl}/dot.gif" id="logo_icon" alt="{$title} Logo" title="{$title}" >
</div> <!--LOGO END-->
<div class="logo"> <a href="{$baseurl}"><img src="{$imageurl}/dot.gif" alt="{$title} Logo" name="logo_icon" border="0" id="logo_icon" title="{$title}" ></a>
</div> <!--LOGO END-->
<div class="login_con clearfix">
<div class="user_login clearfix">
{if !$userquery->login_check('',true)}

View file

@ -1,24 +1,60 @@
<h2>Search</h2>
{assign var='types' value=$cbvid->search->search_type}
{foreach from=$types key=k item=search}
<h2> Search For {$search.title}</h2>
<div>
<form name="search-form-{$search.title}" method="get" action="">
{foreach from=$search.fields item=field}
{$field.title}* :{$field.hint_1}{ANCHOR place=$field.anchor_before}{$formObj->createField($field)}
<br>
{$field.hint_2}
{/foreach}
</form>
<div style="width:98%; margin:auto">
<h2>ClipBucket Search</h2>
<div id="simple_search" class="simple_container" style="border:none">
<div class="search_type">
<div>
<form name="search-form" method="get" action="">
<div>
<label class="label">Kewords</label>
<input type="text" name="keywords" value="{$smarty.get.keywords|form_val}" id="keywords" />
</div>
<input type="submit" name="cbsearch" id="cbsearch" value="Search" class="cb_button" />
</form>
</div>
</div>
<div class="clearfix"></div>
</div>
{/foreach}
<div style="width:600px; float:left" >
<div class="heading">Videos</div>
{section name=v_list loop=$videos}
{include file="$style_dir/blocks/video.html" video=$videos[v_list]}
{/section}
<div class="clear"></div>
<div class="simple_container" style="height:400px; overflow:visible; display:none" id="advance_search">
{foreach from=$Cbucket->search_types item=search_type key=search_type_key}
{if $search_type}
{assign var='type' value=$cbsearch->init_search($search_type_key)}
{if $type}
{assign var='types' value=$type->search_type}
{foreach from=$types key=stype item=search}
<div class="search_type">
<h2> Search For {$search.title}</h2>
<div>
<form name="search-form-{$search.title}" method="get" action="">
<input type="hidden" name="type" value="{$stype}" />
{foreach from=$search.fields item=field}
<div>
<label class="label">{$field.title}</label>
{ANCHOR place=$field.anchor_before}{$formObj->createField($field)}
</div>
{/foreach}
<label for="button"></label>
<input type="submit" name="cbsearch" id="cbsearch" value="Search" class="cb_button" />
</form>
</div>
</div>
{/foreach}
{/if}
{/if}
{/foreach}
<div class="clearfix"></div>
</div>
<span class="more_button" style="margin-bottom:10px"><a href="javascript:void(0)" onClick="$('#advance_search').toggle();$('.more_button').toggleClass('more_button_up');$('#simple_search').toggle()">More Options</a></span>
<div>
<div class="heading">{$search_type_title}</div>
{if $results}
{foreach item=result from=$results}
{assign var=$template_var value =$result}
{include file="$display_template" }
{/foreach}
{/if}
<div class="clearfix"></div>
</div>
{include file="$style_dir/blocks/pagination.html"}
{include file="$style_dir/blocks/pagination.html"}
</div>

View file

@ -714,4 +714,10 @@ display:inline-block; width:18px; height:18px; line-height:18px; text-align:cent
.group_block .group_thumb{width:110px; height:80px; border:1px solid #333; padding:1px; display:block; float:left; margin-right:10px}
.group_block,.group_block a{font-size:10px; font-family:tahoma }
.group_block span{display:block;}
.group_block .group_name,.group_block .group_name a{font-size:12px; text-decoration:none}
.group_block .group_name,.group_block .group_name a{font-size:12px; text-decoration:none}
.search_type{display:block; float:left; width:31%; border-right:1px dotted #0099cc; padding-right:10px; margin-right:10px; height:100%; overflow:visible; position:relative}
.search_type:nth-child(3){border-right:none; margin-right:0px}
.search_type .label{display:block; font-size:11px; font:tahoma; font-weight:bold}
.search_type div{margin-bottom:10px}
.search_type input[type='textfied'],.search_type input[type='text'],.search_type select{width:200px; border:1px solid #999}