Added : Sub-categories
Fixed : Featured Channels on Channels page Fixed : autoPlay typo in player.html Fixed : Made CBv2 Template compatible with Sub-Categories Fixed : Related Videos Fixed : HQ Videos with other players
This commit is contained in:
parent
2fec544140
commit
0448cc4d69
12 changed files with 344 additions and 28 deletions
|
@ -7,3 +7,17 @@ INSERT INTO cb_config (name,value) VALUES
|
|||
('smtp_pass','password'),
|
||||
('smtp_auth','yes'),
|
||||
('smtp_port','26');
|
||||
|
||||
|
||||
ALTER TABLE `cb_video_categories` ADD `parent_id` INT( 5 ) NOT NULL DEFAULT '0' AFTER `category_id`
|
||||
|
||||
|
||||
|
||||
INSERT INTO `clipbucket_svn`.`cb_config` (
|
||||
`configid` ,
|
||||
`name` ,
|
||||
`value`
|
||||
)
|
||||
VALUES (
|
||||
NULL , 'use_subs', '0'
|
||||
);
|
|
@ -42,6 +42,12 @@ if(isset($_GET['delete_category'])){
|
|||
|
||||
|
||||
$cats = $cbvid->get_categories();
|
||||
$pid = $cbvid->get_category_field($_GET['category'],'parent_id');
|
||||
|
||||
if($pid)
|
||||
$selected = $pid;
|
||||
|
||||
$parent_cats = $cbvid->admin_area_cats($selected);
|
||||
|
||||
|
||||
//Updating Category Order
|
||||
|
@ -62,6 +68,7 @@ if(isset($_POST['update_order']))
|
|||
|
||||
//Assing Category Values
|
||||
assign('category',$cats);
|
||||
assign('parent_cats',$parent_cats);
|
||||
assign('total',$cbvid->total_categories());
|
||||
|
||||
subtitle("Video Category Manager");
|
||||
|
|
|
@ -55,6 +55,7 @@ if(isset($_POST['update'])){
|
|||
'default_country_iso2',
|
||||
'default_time_zone',
|
||||
'disallowed_usernames',
|
||||
'use_subs',
|
||||
|
||||
'embedUpload',
|
||||
'email_verification',
|
||||
|
|
|
@ -28,6 +28,15 @@
|
|||
<td valign="top" class="td_body">Category Description*</td>
|
||||
<td class="td_body"><textarea name="desc" id="desc" cols="33" rows="5">{'desc'|post_form_val}</textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" class="td_body">Parent Category</td>
|
||||
<td class="td_body">
|
||||
<select name="parent_cat" id="parent_cat">
|
||||
<option value="0">None</option>
|
||||
{$parent_cats}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" class="td_body">Make Default Category</td>
|
||||
<td class="td_body"><p>
|
||||
|
@ -71,6 +80,15 @@
|
|||
<tr>
|
||||
<td valign="top" class="td_body">Category Description*</td>
|
||||
<td class="td_body"><textarea name="desc" id="desc" cols="33" rows="5">{$cat_details.category_desc}</textarea></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" class="td_body">Parent Category</td>
|
||||
<td class="td_body">
|
||||
<select name="parent_cat" id="parent_cat">
|
||||
<option value="0">None</option>
|
||||
{$parent_cats}
|
||||
</select>
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td valign="top" class="td_body">Make Default Category</td>
|
||||
|
|
|
@ -139,6 +139,21 @@ $(document).ready(function(){
|
|||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Use Sub-Categories</td>
|
||||
<td><select name="use_subs" id="use_subs">
|
||||
<option value="1"
|
||||
{if $row.use_subs == 1}
|
||||
selected="selected"
|
||||
{/if}
|
||||
>Yes</option>
|
||||
<option value="0"
|
||||
{if $row.use_subs == 0}
|
||||
selected="selected"
|
||||
{/if}
|
||||
>No</option>
|
||||
</select></td>
|
||||
</tr>>
|
||||
<tr>
|
||||
<td> </td>
|
||||
<td> </td>
|
||||
</tr>
|
||||
|
|
|
@ -32,7 +32,7 @@ switch($sort)
|
|||
break;
|
||||
case "featured":
|
||||
{
|
||||
$u_cond['order'] = "yes";
|
||||
$u_cond['featured'] = "yes";
|
||||
}
|
||||
break;
|
||||
case "top_rated":
|
||||
|
|
|
@ -74,6 +74,7 @@ abstract class CBCategory
|
|||
$name = ($array['name']);
|
||||
$desc = ($array['desc']);
|
||||
$default = mysql_clean($array['default']);
|
||||
$parent_id = mysql_clean($array['parent_cat']);
|
||||
|
||||
if($this->get_cat_by_name($name))
|
||||
{
|
||||
|
@ -84,8 +85,8 @@ abstract class CBCategory
|
|||
e(lang("add_cat_no_name_err"));
|
||||
}else{
|
||||
$cid = $db->insert(tbl($this->cat_tbl),
|
||||
array("category_name","category_desc","date_added"),
|
||||
array($name,$desc,now())
|
||||
array("parent_id","category_name","category_desc","date_added"),
|
||||
array($parent_id,$name,$desc,now())
|
||||
);
|
||||
$cid = $db->insert_id();
|
||||
if($default=='yes' || !$this->get_default_category())
|
||||
|
@ -127,6 +128,75 @@ abstract class CBCategory
|
|||
return $select;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to list of categories
|
||||
*/
|
||||
function cb_list_categories($type,$with_all=false)
|
||||
{
|
||||
global $db;
|
||||
if($type == 'video' || $type == 'vid' || $type == 'v')
|
||||
$cond = " parent_id = 0";
|
||||
else
|
||||
$cond = NULL;
|
||||
|
||||
//Getting List of categories
|
||||
$cats = $db->select(tbl($this->cat_tbl),"*",$cond,NULL," category_order ASC");
|
||||
|
||||
if($with_all)
|
||||
array_unshift($cats,array("category_id"=>"all","category_name"=>"All"));
|
||||
|
||||
$html = '';
|
||||
for($i=0;$i<count($cats);$i++)
|
||||
{
|
||||
if($_GET['cat'] == $cats[$i]['category_id'] || (empty($_GET['cat']) && $cats[$i]['category_id'] == 'all'))
|
||||
$selected = "selected";
|
||||
else
|
||||
$selected = "";
|
||||
|
||||
$html .= "<li class='".$selected."'>";
|
||||
$html .= "<a href='".category_link($cats[$i],$type)."' title='".$cats[$i]['category_name']."'>".$cats[$i]['category_name']."</a>";
|
||||
if($this->is_parent($cats[$i]['category_id']))
|
||||
{
|
||||
$html .= $this->cb_list_subs($cats[$i]['category_id'],$type);
|
||||
}
|
||||
$html .= "</li>";
|
||||
}
|
||||
return $html;
|
||||
|
||||
}
|
||||
|
||||
function cb_list_subs($cid,$type)
|
||||
{
|
||||
global $db;
|
||||
$html = "";
|
||||
$query = mysql_query("SELECT * FROM ".tbl($this->cat_tbl)." WHERE parent_id = $cid");
|
||||
|
||||
if(!empty($query))
|
||||
{
|
||||
|
||||
$html .= "<ul id='".$cid."_subs' class='sub_categories'>";
|
||||
while($result = mysql_fetch_array($query))
|
||||
{
|
||||
if($_GET['cat'] == $result['category_id'])
|
||||
$selected = "selected";
|
||||
else
|
||||
$selected = "";
|
||||
|
||||
$html .= "<li class='".$selected."'>";
|
||||
$html .= "<a href='".category_link($result,$type)."' title='".$result['category_name']."'>".$result['category_name']."</a>";
|
||||
if($this->is_parent($result['category_id']))
|
||||
{
|
||||
$html .= $this->cb_list_subs($result['category_id'],$type);
|
||||
}
|
||||
$html .= "</li>";
|
||||
}
|
||||
|
||||
$html .= "</ul>";
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Function used to count total number of categoies
|
||||
|
@ -147,12 +217,35 @@ abstract class CBCategory
|
|||
$cat_details = $this->category_exists($cid);
|
||||
if(!$cat_details)
|
||||
e(lang("cat_exist_error"));
|
||||
|
||||
//CHecking if category is default or not
|
||||
elseif($cat_details['isdefault'] == 'yes')
|
||||
e(lang("cat_default_err"));
|
||||
else{
|
||||
//Moving all contents to default category
|
||||
$this->change_category($cid);
|
||||
|
||||
$pcat = $this->has_parent($cid,true);
|
||||
|
||||
//Checking if category is both parent and child
|
||||
if($pcat && $this->is_parent($cid))
|
||||
{
|
||||
$to = $pcat[0]['category_id'];
|
||||
$has_child = TRUE;
|
||||
}
|
||||
elseif($pcat && !$this->is_parent($cid)) //Checking if category is only child
|
||||
{
|
||||
$to = $pcat[0]['category_id'];
|
||||
$has_child = TRUE;
|
||||
}
|
||||
elseif(!$pcat && $this->is_parent($cid)) //Checking if category is only parent
|
||||
{
|
||||
$to = NULL;
|
||||
$has_child = NULL;
|
||||
$db->update(tbl($this->cat_tbl),array('parent_id'),array('0')," parent_id = $cid");
|
||||
}
|
||||
|
||||
//Moving all contents to parent OR default category
|
||||
$this->change_category($cid,$to,$has_child);
|
||||
|
||||
//Removing Category
|
||||
$db->execute("DELETE FROM ".tbl($this->cat_tbl)." WHERE category_id='$cid'");
|
||||
e(lang("class_cat_del_msg"),'m');
|
||||
|
@ -187,12 +280,19 @@ abstract class CBCategory
|
|||
/**
|
||||
* Function used to move contents from one section to other
|
||||
*/
|
||||
function change_category($from,$to=NULL,$check_multiple=false)
|
||||
function change_category($from,$to=NULL,$has_child=NULL,$check_multiple=false)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if(!$this->category_exists($to))
|
||||
$to = $this->get_default_cid();
|
||||
|
||||
if($has_child) {
|
||||
$db->update(tbl($this->cat_tbl),array('parent_id'),array($to)," parent_id = $from");
|
||||
}
|
||||
|
||||
$db->execute("UPDATE ".tbl($this->section_tbl)." SET category = replace(category,'#".$from."#','#".$to."#') WHERE category LIKE '%#".$from."#%'");
|
||||
|
||||
$db->execute("UPDATE ".tbl($this->section_tbl)." SET category = replace(category,'#".$to."# #".$to."#','#".$to."#') WHERE category LIKE '%#".$to."#%'");
|
||||
}
|
||||
|
||||
|
@ -207,22 +307,25 @@ abstract class CBCategory
|
|||
$name = ($array['name']);
|
||||
$desc = ($array['desc']);
|
||||
$default = mysql_clean($array['default']);
|
||||
$pcat = mysql_clean($array['parent_cat']);
|
||||
|
||||
$cur_name = mysql_clean($array['cur_name']);
|
||||
$cid = mysql_clean($array['cid']);
|
||||
$cur_parent = mysql_clean($array['cur_parent']);
|
||||
|
||||
|
||||
if($this->get_cat_by_name($name) && $cur_name !=$name )
|
||||
{
|
||||
e(lang("add_cat_erro"));
|
||||
|
||||
}elseif(empty($name))
|
||||
{
|
||||
}elseif(empty($name)){
|
||||
e(lang("add_cat_no_name_err"));
|
||||
} elseif($pcat == $cid){
|
||||
e(lang("You can not make category parent of itself"));
|
||||
}else{
|
||||
$db->update(tbl($this->cat_tbl),
|
||||
array("category_name","category_desc"),
|
||||
array($name,$desc),
|
||||
array("parent_id","category_name","category_desc"),
|
||||
array($pcat,$name,$desc),
|
||||
" category_id='$cid' "
|
||||
);
|
||||
if($default=='yes' || !$this->get_default_category())
|
||||
|
@ -349,6 +452,155 @@ abstract class CBCategory
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used get parent cateogry
|
||||
*/
|
||||
function get_parent_category($pid)
|
||||
{
|
||||
global $db;
|
||||
$result = $db->select(tbl($this->cat_tbl),"*"," category_id = $pid");
|
||||
if($db->num_rows>0)
|
||||
return $result;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to check category is parent or not
|
||||
*/
|
||||
function is_parent($cid)
|
||||
{
|
||||
global $db;
|
||||
$result = $db->count(tbl($this->cat_tbl),"category_id"," parent_id = $cid");
|
||||
|
||||
if($result > 0)
|
||||
return true;
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to check wheather category has parent or not
|
||||
*/
|
||||
function has_parent($cid,$return_parent=false)
|
||||
{
|
||||
global $db;
|
||||
$result = $db->select(tbl($this->cat_tbl),"*"," category_id = $cid AND parent_id != 0");
|
||||
|
||||
if($result > 0) {
|
||||
if($return_parent)
|
||||
{
|
||||
$pid = $this->get_parent_category($result[0]['parent_id']);
|
||||
return $pid;
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to get parent categories
|
||||
*/
|
||||
function get_parents($count=false) {
|
||||
global $db;
|
||||
|
||||
if($count) {
|
||||
$result = $db->count(tbl($this->cat_tbl),"*"," parent_id = 0");
|
||||
} else {
|
||||
$result = $db->select(tbl($this->cat_tbl),"*"," parent_id = 0");
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to list categories in admin area
|
||||
* with indention
|
||||
*/
|
||||
function admin_area_cats($selected)
|
||||
{
|
||||
global $db;
|
||||
$html = '';
|
||||
$pcats = $this->get_parents();
|
||||
|
||||
if(!empty($pcats))
|
||||
{
|
||||
foreach($pcats as $key=>$pcat)
|
||||
{
|
||||
if($selected == $pcat['category_id'])
|
||||
$select = "selected='selected'";
|
||||
else
|
||||
$select = NULL;
|
||||
|
||||
$html .= "<option value='".$pcat['category_id']."' $select>";
|
||||
$html .= $pcat['category_name'];
|
||||
$html .= "</option>";
|
||||
if($this->is_parent($pcat['category_id']))
|
||||
$html .= $this->get_sub_subs($pcat['category_id'],$selected);
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to get child categories
|
||||
*/
|
||||
function get_sub_categories($cid)
|
||||
{
|
||||
global $db;
|
||||
$result = $db->select(tbl($this->cat_tbl),"*"," parent_id = $cid");
|
||||
//echo $db->db_query;
|
||||
if($result > 0){
|
||||
return $result;
|
||||
}else{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Function used to get child child categories
|
||||
*/
|
||||
function get_sub_subs($cid,$selected,$space=" - ")
|
||||
{
|
||||
global $db;
|
||||
$html = '';
|
||||
$subs = $this->get_sub_categories($cid);
|
||||
if(!empty($subs))
|
||||
{
|
||||
foreach($subs as $sub_key=>$sub)
|
||||
{
|
||||
if($selected == $sub['category_id'])
|
||||
$select = "selected='selected'";
|
||||
else
|
||||
$select = NULL;
|
||||
|
||||
$html .= "<option value='".$sub['category_id']."' $select>";
|
||||
$html .= $space.$sub['category_name'];
|
||||
$html .= "</option>";
|
||||
if($this->is_parent($sub['category_id']))
|
||||
$html .= $this->get_sub_subs($sub['category_id'],$selected,$space." - ");
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
|
||||
function get_category_field($cid,$field)
|
||||
{
|
||||
global $db;
|
||||
$result = $db->select(tbl($this->cat_tbl),"$field"," category_id = $cid");
|
||||
//echo $db->db_query;
|
||||
if($result)
|
||||
return $result[0][$field];
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
?>
|
|
@ -922,6 +922,8 @@
|
|||
*/
|
||||
function getCategoryList($type='video',$with_all=false,$return_html=false)
|
||||
{
|
||||
$use_subs = config('use_subs');
|
||||
|
||||
switch ($type)
|
||||
{
|
||||
case "video":
|
||||
|
@ -929,7 +931,7 @@
|
|||
{
|
||||
global $cbvid;
|
||||
|
||||
if($return_html) {
|
||||
if($return_html && $use_subs == "1") {
|
||||
$cats = $cbvid->cb_list_categories($type,$with_all);
|
||||
} else {
|
||||
if($with_all)
|
||||
|
@ -948,7 +950,7 @@
|
|||
global $userquery;
|
||||
|
||||
|
||||
if($return_html) {
|
||||
if($return_html && $use_subs == "1") {
|
||||
$cats = $userquery->cb_list_categories($type,$with_all);
|
||||
} else {
|
||||
if($with_all)
|
||||
|
@ -969,7 +971,7 @@
|
|||
global $cbgroup;
|
||||
|
||||
|
||||
if($return_html) {
|
||||
if($return_html && $use_subs == "1") {
|
||||
$cats = $cbgroup->cb_list_categories($type,$with_all);
|
||||
} else {
|
||||
if($with_all)
|
||||
|
|
|
@ -80,7 +80,7 @@ flowplayer("the_Video_Player", "{$pak_player_url}/pak_player.swf", {literal}{
|
|||
,
|
||||
clip:{
|
||||
{/literal}
|
||||
autoPlay:{$player_data.autoplay},
|
||||
autoplay:'{$player_data.autoplay}',
|
||||
|
||||
{if $youtube}
|
||||
url : 'api:{$ytcode}',
|
||||
|
|
|
@ -1,15 +1,17 @@
|
|||
<div class="category_list">
|
||||
<span class="cat_heading">{lang code='categories'}</span>
|
||||
{assign var='category_list' value=func->getCategoryList($type,true)}
|
||||
{assign var='category_list' value=func->getCategoryList($type,true,true)}
|
||||
{assign var='use_subs' value=func->config(use_subs)}
|
||||
|
||||
<div class="categories">
|
||||
{if $category_list}
|
||||
<ul>
|
||||
{if $use_subs == "1"}
|
||||
{$category_list}
|
||||
{else}
|
||||
{foreach from=$category_list item=cat}
|
||||
<li {if $smarty.get.cat==$cat.category_id || ($smarty.get.cat=="" && $cat.category_id=='all')} class="selected"{/if}><a href="{link name='category' data=$cat type=$type}">{$cat.category_name}</a></li>
|
||||
{/foreach}
|
||||
</ul>
|
||||
{else}
|
||||
No Category
|
||||
{/if}
|
||||
</ul>
|
||||
</div>
|
||||
</div>
|
|
@ -22,6 +22,11 @@
|
|||
{FlashPlayer vdetails = $vdo}
|
||||
</div>
|
||||
|
||||
{if has_hq($vdo)}
|
||||
<div id="hd_player_cont" style="display:none">
|
||||
{FlashPlayer vdetails =$vdo player_div='hd_div' hq=true}
|
||||
</div>
|
||||
{/if}
|
||||
<!-- Actions -->
|
||||
<div class="video_actions_cont clearfix">
|
||||
<div class="rating_container">
|
||||
|
@ -163,9 +168,9 @@
|
|||
|
||||
<!-- Getting Related videos -->
|
||||
{assign var=videos_items_columns value=func->config(videos_items_columns)}
|
||||
{get_videos nonuser=$vdo.userid exclude=$vdo.videoid limit=$videos_items_columns order="date_added ASC" assign=related_vids}
|
||||
{get_videos nonuser=$vdo.userid exclude=$vdo.videoid limit=$videos_items_columns order="date_added ASC" assign=related_vids show_related=yes title=$vdo.title}
|
||||
<!-- Related Videos based on category, please remove * and also above smarty function -->
|
||||
{* get_videos category=$vid_cat nonuser=$vdo.userid exclude=$vdo.videoid limit=$videos_items_columns order="date_added ASC" assign=related_vids *}
|
||||
{* get_videos category=$vid_cat nonuser=$vdo.userid exclude=$vdo.videoid limit=$videos_items_columns order="date_added ASC" assign=related_vids show_related=yes title=$vdo.title*}
|
||||
|
||||
|
||||
{if $related_vids}
|
||||
|
|
|
@ -385,8 +385,8 @@ span.remember { font-size:10px; }
|
|||
.categories ul li:last-child{border-bottom:none}
|
||||
.categories .selected { background-color:#efefef; display:block;border-radius:5px;-moz-border-radius:5px;-webkit-border-radius:5px}
|
||||
.categories ul a{font:bold 14px arial;color:#0066cc; text-decoration:none; display:block; padding:2px 2px 2px 6px; }
|
||||
.categories ul.sub_categories { padding:0px; margin:0px 0 0 5px; }
|
||||
.categories ul.sub_categories li { padding:2px; margin:0px; }
|
||||
.categories ul.sub_categories { padding:0px; margin:0px 0px 0px 5px; }
|
||||
.categories ul.sub_categories li { padding:1px; margin:0px; }
|
||||
.categories ul.sub_categories li a { font:bold 11px Tahoma; }
|
||||
.time_cont{border-bottom:1px solid #CCC; margin-bottom:5px; padding:5px; font-size:10px}
|
||||
.time_cont a{ font-size:10px; color:#666; text-decoration:none}
|
||||
|
|
Loading…
Add table
Reference in a new issue