Added : Next and Previous Collection Item

Updated : Few things ........
This commit is contained in:
Fawaz 2010-11-04 07:53:16 +00:00
parent 1e7edb2a29
commit 73e3b39aa4
11 changed files with 381 additions and 71 deletions

View file

@ -654,11 +654,61 @@ if(!empty($mode))
}
break;
case "NePrItem":
{
$item_id = $_POST['item_id'];
$cid = $_POST['cid'];
$direc = mysql_clean($_POST['direction']);
$t = $_POST['type'];
switch($t)
{
case "videos":
case "v":
{
$N_item = $cbvideo->collection->get_next_prev_item($item_id,$cid,$direc);
}
break;
}
if($N_item)
{
$ajax['ci_id'] = $N_item[0]['ci_id'];
$ajax['cid'] = $N_item[0]['collection_id'];
echo json_encode($ajax);
} else {
return false;
}
}
break;
case "get_item":
{
$t = $_POST['type'];
$ci_id = $_POST['ci_id'];
$cid = $_POST['cid'];
switch($t)
{
case "videos":
case "v":
{
$item = $cbvideo->collection->get_next_prev_item($ci_id,$cid,NULL);
assign('type',$t);
assign('object',$item[0]);
}
}
if(!empty($item))
{
Template('blocks/view_item.html');
}
}
break;
default:
header('location:'.BASEURL);
}
}else
header('location:'.BASEURL);

88
upload/collections.php Normal file
View file

@ -0,0 +1,88 @@
<?php
/*
********************************************************************
| Copyright (c) 2007-2009 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
********************************************************************
*/
define("THIS_PAGE",'collections');
define("PARENT_PAGE",'collections');
require 'includes/config.inc.php';
$sort = $_GET['sort'];
$cond = array("category"=>mysql_clean($_GET['cat']),"date_span"=>$_GET['time']);
$type = mysql_clean($_GET['type']);
switch($sort)
{
case "most_recent":
default:
{
$cond['order'] = " date_added DESC";
}
break;
case "featured":
{
$cond['featured'] = "yes";
}
break;
case "most_viewed":
{
$cond['order'] = " views DESC";
}
break;
case "most_commented":
{
$cond['order'] = " total_comments DESC";
}
break;
case "most_items":
{
$cond['order'] = " total_objects DESC";
}
break;
}
switch($type)
{
case "videos":
{
$cond['type'] = "videos";
}
break;
case "pictures":
{
$cond['type'] = "pictures";
}
}
//Getting Collection List
$page = mysql_clean($_GET['page']);
$get_limit = create_query_limit($page,VLISTPP);
$clist = $cond;
$clist['limit'] = $get_limit;
$collections = $cbcollection->get_collections($clist);
Assign('collections', $collections);
//Collecting Data for Pagination
$ccount = $cond;
$ccount['count_only'] = true;
$total_rows = $cbcollection->get_collections($ccount);
$total_pages = count_pages($total_rows,VLISTPP);
//Pagination
$pages->paginate($total_pages,$page);
subtitle(lang('collections'));
//Displaying The Template
template_files('collections.html');
display_it();
?>

View file

@ -39,30 +39,35 @@ class Collections extends CBCategory
$this->section_tbl = "collections";
$this->types = array('videos' => lang("Videos"),'pictures' => lang("Pictures"));
ksort($this->types);
$this->set_user_links();
$this->search_type();
$this->setting_up_collections();
}
/**
* Setting links up in my account
*/
function set_user_links()
function setting_up_collections()
{
global $userquery;
global $userquery,$Cbucket;
// Adding My Account Links
$links = array();
$links[lang('Collections')] = array(
lang('Add New Collection') => "manage_collections.php?mode=add_new",
lang('Manage Collections') => "manage_collections.php"
);
$userquery->user_account = $links;
}
function search_type()
{
global $Cbucket;
$types = $Cbucket->search_types;
$types['collections'] = "cbcollection";
$Cbucket->search_types = $types;
// Adding Search Type
$Cbucket->search_types['collections'] = "cbcollection";
// Adding Collection links in Cbucket Class
$Cbucket->links['manage_collections'] = array('manage_collections.php','manage_collections');
$Cbucket->links['edit_collection'] = array('manage_collections.php?mode=edit_collection&amp;cid=',
'manage_collections.php?mode=edit_collection&amp;cid=');
$Cbucket->links['manage_items'] = array('manage_collections.php?mode=manage_items&amp;cid=%s&amp;type=%s',
'manage_collections.php?mode=manage_items&amp;cid=%s&amp;type=%s');
}
/**
@ -363,6 +368,42 @@ class Collections extends CBCategory
return false;
}
/**
* Function used to get next / previous collection item
*/
function get_next_prev_item($ci_id,$cid,$item="prev",$limit=1)
{
global $db;
$iTbl = tbl($this->items);
$oTbl = tbl($this->objTable);
$uTbl = tbl('users');
$tbls = $iTbl.",".$oTbl.",".$uTbl;
if($item == "prev")
{
$op = ">";
$order = '';
}
elseif($item == "next")
{
$op = "<";
$order = $iTbl.".ci_id DESC";
}
elseif($item == NULL)
{
$op = "=";
$order = '';
}
$result = $db->select($tbls,"$iTbl.*,$oTbl.*,$uTbl.username", " $iTbl.collection_id = $cid AND $iTbl.ci_id $op $ci_id AND $iTbl.object_id = $oTbl.".$this->objFieldID." AND $oTbl.userid = $uTbl.userid",$limit,$order);
//echo $db->db_query;
if($result)
return $result;
else
return false;
}
/**
* Function used to get collection items with details
*/
@ -975,7 +1016,7 @@ class Collections extends CBCategory
/**
* Function used get collection thumb
*/
function get_thumb($cdetails,$size=NULL)
function get_thumb($cdetails,$size=NULL,$return_c_thumb=FALSE)
{
if(is_numeric($cdetails))
{
@ -985,7 +1026,7 @@ class Collections extends CBCategory
$cid = $cdetails['collection_id'];
$exts = array("jpg","png","gif","jpeg");
if($cdetails['total_objects'] == 0)
if($cdetails['total_objects'] == 0 || $return_c_thumb)
{
foreach($exts as $ext)
{
@ -1103,46 +1144,13 @@ class Collections extends CBCategory
if(SEO == yes)
return BASEURL."/view-collection/".$cdetails['collection_id']."/".$cdetails['type']."/".SEO(clean(str_replace(' ','-',$cdetails['collection_name'])))."";
else
return BASEURL."/view_collection.php?cid=".$cdetails['collection_id']."&amp;type=".$cdetails['type'];
return BASEURL."/view_collection.php?cid=".$cdetails['collection_id'];
}
} else {
return BASEURL;
}
}
/**
* Function used generate collection link
*/
/*function collection_links($details,$mode="main")
{
if(!is_array($details))
$details = $this->get_collection($details);
switch($mode)
{
case "main":
default:
{
if(SEO==yes)
return BASEURL."/collections";
else
return BASEURL."/collections.php";
}
break;
case "view":
case "view_collection":
case "vc":
{
if(SEO==yes)
return BASEURL."/view-collection/".$details['collection_id']."/".SEO(clean(str_replace(' ','-',$details['collection_name'])))."";
else
return BASEURL."/view_collection.php?cid=".$details['collection_id'];
}
break;
}
}*/
}
?>

View file

@ -868,3 +868,46 @@ function collection_actions(form,mode,objID,result_con,type,cid)
return false;
}
function get_collection_item(obj,ci_id,cid,type,direction)
{
var btn_text = $(obj).text();
$(obj).text('Working ...');
$.post(page,
{
mode : 'NePrItem',
item_id : ci_id,
cid : cid,
type : type,
direction: direction
},
function(data)
{
if(!data)
{
alert("No "+btn_text+" "+type+" Found");
$(obj).text(btn_text);
} else {
//alert(data);
get_item(data.ci_id,data.cid,type);
}
},'json')
}
function get_item(ci_id,cid,type)
{
$("#collectionItemsList div").removeClass('selected');
$("#item_"+ci_id).addClass('selected');
$.post(page,
{
mode : 'get_item',
ci_id: ci_id,
cid : cid,
type: type
},
function(data)
{
$("#collectionItemView").html(data);
},'text')
}

View file

@ -12,7 +12,7 @@ require 'includes/config.inc.php';
$userquery->logincheck();
$udetails = $userquery->get_user_details(userid());
assign('user',$udetails);
$order = tbl("collection_items").".date_added DESC";
$mode = $_GET['mode'];
$cid = mysql_clean($_GET['cid']);
@ -32,6 +32,17 @@ switch($mode)
$cbcollection->delete_collection($cid);
}
if($_POST['delete_selected'])
{
$count = count($_POST['check_col']);
for($i=0;$i<$count;$i++)
{
$cbcollection->delete_collection($_POST['check_col'][$i]);
}
$eh->flush();
e("selected_collects_del","m");
}
$usr_collections = $cbcollection->get_collections(array('user'=>userid()));
assign('usr_collects',$usr_collections);
}
@ -82,22 +93,23 @@ switch($mode)
{
case "videos":
{
$objs = array();
$items = $cbvideo->collection->get_collection_items($cid);
if($items)
if(isset($_POST['delete_selected']))
{
foreach($items as $item)
$count = count($_POST['check_item']);
for($i=0;$i<$count;$i++)
{
$objs[] = $cbvideo->get_video_details($item['object_id']);
$cbvideo->collection->remove_item($_POST['check_item'][$i],$cid);
}
$eh->flush();
e(sprintf("selected_items_removed","videos"),"m");
}
$objs = $cbvideo->collection->get_collection_items_with_details($cid,$order);
}
break;
}
$collection = $cbcollection->get_collection($cid);
assign('c',$collection);
assign('items',$items);
assign('objs',$objs);
}
break;

View file

@ -9,3 +9,17 @@
</div>
</div>
{/if}
{if $display_type == "view_collection"}
{if $type == "videos"}
<div class="moveL collect_grid{if $smarty.section.o_list.first} selected{/if}" onclick="get_item('{$object.ci_id}','{$object.collection_id}','{$type}')" id="item_{$object.ci_id}">
<div class="vid_thumb">
<a href="{videoLink vdetails=$object}"><img src="{getThumb vdetails=$object}" alt="{$object.title}" /></a>
</div>
<div style="height:4px;"></div>
<span class="obj_title"><a href="{videoLink vdetails=$object}" target="_blank" title="Go to video page" style="font:bold 11px Tahoma;">{$object.title|truncate:26}</a></span>
<div style="height:5px;"></div>
{show_rating class='rating' rating=$object.rating ratings=$object.rated_by total='10'}
</div> <!-- collection_{$collection.collection_id} end -->
{/if}
{/if}

View file

@ -26,7 +26,7 @@
<div id="collectionItem_{$collection.videoid}" class="account_vid_list" style="background-color:#{$bg}">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td width="25"><input type="checkbox" name="check_vid[]" id="check_vid-{$collection.videoid}" value="{$collection.videoid}" />
<td width="25"><input type="checkbox" name="check_item[]" id="check_item-{$collection.videoid}" value="{$collection.videoid}" />
<label for="checkbox"></label></td>
<td valign="middle">
<div style="padding-left:10px; float:left;width:300px">

View file

@ -5,6 +5,9 @@
<form action="" method="post" class="upload_form" name="form1" enctype="multipart/form-data">
{if $mode == "manage" || $mode == ""}
<h2>{lang code='manage_collections'}</h2>
<div style="margin-bottom:10px;">
<img src="{$imageurl}/dot.gif" class="arrow_pointing" style="margin-right:10px;" /><input type="submit" name="delete_selected" id="delete_selected" value="{lang code='delete'}" class="small_button" />
</div>
<div class="account_table">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
@ -33,7 +36,7 @@
<div class="field clearfix">
<label for="colleciton_thumb" class="label">{lang code=collection_thumb"}</label>
<div style="width:140px; float:left" align="center">
<img src="{$cbcollection->get_thumb($c)}" />
<img src="{$cbcollection->get_thumb($c,NULL,TRUE)}" />
</div>
<div style="width:500px; float:left; margin-left:15px;">
<li>{lang code='grp_must_be'} JPG | GIF | PNG</li>
@ -102,6 +105,9 @@
{if $mode == "manage_items" || $mode == "collection_items"}
<h2>{lang code='manage_items'} - {$c.collection_name}</h2>
<div style="margin-bottom:10px;">
<img src="{$imageurl}/dot.gif" class="arrow_pointing" style="margin-right:10px;" /><input type="submit" name="delete_selected" id="delete_selected" value="{lang code='delete'}" class="small_button" />
</div>
<div class="account_table">
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>

View file

@ -1,16 +1,29 @@
<div style="width:750px; margin:0px auto">
<div style="width:880px; margin:0px auto">
<div class="video_title" style="padding-bottom:5px; margin-bottom:5px; border-bottom:1px solid #ccc;">{$c.collection_name}</div>
<div style="font:normal 10px Tahoma; color:#333; padding-bottom:5px; margin-bottom:5px; border-bottom:1px solid #ccc;">{lang code="by"|capitalize} <a href="{$userquery->profile_link($c)}">{$c.username|capitalize}</a> - <a href="{link name='user_videos'}{$c.username}">{lang code="view"|capitalize} {$c.username|capitalize} {lang code="videos"|capitalize}</a></div>
<div style="font:normal 10px Tahoma; color:#333; padding-bottom:5px; margin-bottom:5px; border-bottom:1px solid #ccc;">{lang code="by"|capitalize} <a href="{$userquery->profile_link($c)}">{$c.username|capitalize}</a> - <a href="{link name='user_videos'}{$c.username}">{lang code="view"|capitalize} {$c.username|capitalize} {lang code="videos"|capitalize}</a> {if $c.userid == $userquery->userid} - <a href="{link name='edit_collection'}{$c.collection_id}">{lang code="edit_collection"}</a> - {link name='manage_items' assign='miLink'} <a href="{$miLink|sprintf:$c.collection_id:$c.type}">{lang code="manage_items"}</a>{/if}</div>
<div id="collectionItemView">
{section name=item loop=$objects max=1}
{include file="$style_dir/blocks/view_item.html" object=$objects[item]}
{/section}
</div>
<div style="clear:both;"></div>
<div style="height:1px; border-bottom:1px solid #ccc; margin:5px 0;"></div>
<div class="video_title" style="font-size:14px;">{$c.type|capitalize} ({$c.total_objects})</div>
<div style="height:1px; border-bottom:1px solid #ccc; margin:5px 0;"></div>
<div id="collectionItemsList">
{section name=o_list loop=$objects}
{if $c.type == "videos"}
{include file="$style_dir/blocks/video.html" video=$objects[o_list] video_view="grid_view"}
{/if}
{include file="$style_dir/blocks/collection.html" object=$objects[o_list] display_type="view_collection" type=$c.type}
{sectionelse}
<div align="center" style="font:bold 11px Tahoma">{$c.collection_name} has 0 {$c.type}</div>
{/section}
</div>
<div class="clear"></div>
{include file="$style_dir/blocks/pagination.html"}
<!-- {include file="$style_dir/blocks/pagination.html"} -->
<div style="padding-bottom:5px; height:1px; margin-bottom:5px; border-bottom:1px solid #ccc;"></div>
<div class="moveL" style="width:200px; font:normal 11px Tahoma;">
<span style="color:#333; font-weight:bold;">{lang code="date_added"}</span>

View file

@ -765,3 +765,10 @@ ul.upload_opts li.selected { cursor:pointer; background:none; border:1px solid;
.subsription a{text-decoration:none; font-size:14px; font-family:Arial, Helvetica, sans-serif; display:block; border-bottom:1px solid #CCC; padding-bottom:5px; margin-bottom:5px; color:#06c; font-weight:bold}
/* COLLECTION */
.collect_grid { padding:5px; border:1px solid #FFF; height:120px; margin:0 0 10px -1px; position:relative; -moz-border-radius:6px; }
.collect_grid:hover { border-color:#CCC; background:#fafafa; z-index:50; cursor:pointer; }
.collect_grid.selected { background:url(../images/simple_gradient.png) bottom repeat-x; border:1px solid #aaa; z-index:51; }
.collect_grid:first-child { margin-left:none; }
.obj_title { width:110px; display:inline-block; }
.obj_title a { text-decoration:none; }

View file

@ -0,0 +1,69 @@
<?php
/*
******************************************************************
| Copyright (c) 2007-2008 Clip-Bucket.com. All rights reserved.
| @ Author : ArslanHassan
| @ Software : ClipBucket , © PHPBucket.com
******************************************************************
*/
define("THIS_PAGE",'view_collection');
define("PARENT_PAGE",'collections');
require 'includes/config.inc.php';
$pages->page_redir();
$c = mysql_clean($_GET['cid']);
$cdetails = $cbcollection->get_collection($c);
$page = mysql_clean($_GET['page']);
$get_limit = create_query_limit($page,VLISTPP);
$order = tbl("collection_items").".ci_id DESC";
if($cdetails)
{
$type = $cdetails['type'];
switch($type)
{
case "videos":
{
$items = $cbvideo->collection->get_collection_items_with_details($cdetails['collection_id'],$order);
}
break;
case "pictures":
{
// Following to two lines will be un-commented once we have written picture.class
//$items = $cbpicture->collection->get_collection_items_with_details($cdetails['collection_id'],NULL,$get_limit);
//$total_rows = $cbpicture->collection->get_collection_items_with_details($cdetails['collection_id'],NULL,NULL,true);
}
}
// Calling nesscary function for view collection
call_view_collection_functions($cdetails);
$total_pages = count_pages($total_rows,VLISTPP);
//Pagination
$pages->paginate($total_pages,$page);
assign("c",$cdetails);
assign("type",$type);
assign("objects",$items);
subtitle($cdetails['collection_name']);
} else {
e(lang("collect_not_exist"));
$Cbucket->show_page = false;
}
// Getting ready for Pagination
$page = mysql_clean($_GET['page']);
if($Cbucket->show_page)
{
template_files('view_collection.html');
}
display_it();
?>