Updated : 2.4~2.4.5.txt
Updated : Rating system from Stars to Likes Added : New function update_user_voted un userquery Added : New styles for like system Fixed : Disable button problem while saving video
This commit is contained in:
parent
dbe78e3ec9
commit
8a38ac9872
13 changed files with 193 additions and 26 deletions
|
@ -17,3 +17,5 @@ UPDATE `clipbucket_svn`.`cb_pages` SET `page_order` = '4' WHERE `cb_pages`.`page
|
|||
UPDATE `clipbucket_svn`.`cb_pages` SET `page_order` = '5' WHERE `cb_pages`.`page_id` =5 LIMIT 1 ;
|
||||
|
||||
UPDATE `clipbucket_svn`.`cb_pages` SET `page_order` = '6' WHERE `cb_pages`.`page_id` =6 LIMIT 1 ;
|
||||
|
||||
ALTER TABLE `cb_users` ADD `voted` TEXT NOT NULL AFTER `last_commented`
|
||||
|
|
|
@ -1338,9 +1338,9 @@ class Collections extends CBCategory
|
|||
{
|
||||
global $db,$json;
|
||||
|
||||
if(!is_numeric($rating) || $rating < 1)
|
||||
$rating = 1;
|
||||
if($rating > 10)
|
||||
if(!is_numeric($rating) || $rating <= 9)
|
||||
$rating = 0;
|
||||
if($rating >= 10)
|
||||
$rating = 10;
|
||||
|
||||
$c_rating = $this->current_rating($id);
|
||||
|
@ -1381,7 +1381,16 @@ class Collections extends CBCategory
|
|||
$db->update(tbl('collections'),array('rating','rated_by','voters'),
|
||||
array("$new_rate","$rated_by","|no_mc|$voters"),
|
||||
" collection_id = ".$id."");
|
||||
|
||||
$userDetails = array(
|
||||
"object_id" => $id,
|
||||
"type" => "collection",
|
||||
"time" => now(),
|
||||
"rating" => $rating,
|
||||
"userid" => userid(),
|
||||
"username" => username()
|
||||
);
|
||||
/* Updating user details */
|
||||
update_user_voted($userDetails);
|
||||
e(lang("thnx_for_voting"),"m");
|
||||
}
|
||||
|
||||
|
|
|
@ -2204,9 +2204,9 @@ class CBPhotos
|
|||
{
|
||||
global $db,$json;
|
||||
|
||||
if(!is_numeric($rating) || $rating < 1)
|
||||
$rating = 1;
|
||||
if($rating > 10)
|
||||
if(!is_numeric($rating) || $rating <= 9)
|
||||
$rating = 0;
|
||||
if($rating >= 10)
|
||||
$rating = 10;
|
||||
|
||||
$c_rating = $this->current_rating($id);
|
||||
|
@ -2243,6 +2243,16 @@ class CBPhotos
|
|||
$rated_by = $c_rating['rated_by'] + 1;
|
||||
$new_rate = ($t + $rating) / $rated_by;
|
||||
$db->update(tbl('photos'),array('rating','rated_by','voters'),array("$new_rate","$rated_by","|no_mc|$voters")," photo_id = ".$id."");
|
||||
$userDetails = array(
|
||||
"object_id" => $id,
|
||||
"type" => "photo",
|
||||
"time" => now(),
|
||||
"rating" => $rating,
|
||||
"userid" => userid(),
|
||||
"username" => username()
|
||||
);
|
||||
/* Updating user details */
|
||||
update_user_voted($userDetails);
|
||||
e(lang("thnx_for_voting"),"m");
|
||||
}
|
||||
|
||||
|
|
|
@ -4875,9 +4875,9 @@ function getSubscriptionsUploadsWeek($uid,$limit=20,$uploadsType="both",$uploads
|
|||
{
|
||||
global $db,$json;
|
||||
|
||||
if(!is_numeric($rating) || $rating < 1)
|
||||
$rating = 1;
|
||||
if($rating > 10)
|
||||
if(!is_numeric($rating) || $rating <= 9)
|
||||
$rating = 0;
|
||||
if($rating >= 10)
|
||||
$rating = 10;
|
||||
|
||||
$c_rating = $this->current_rating($id);
|
||||
|
@ -4916,7 +4916,16 @@ function getSubscriptionsUploadsWeek($uid,$limit=20,$uploadsType="both",$uploads
|
|||
$db->update(tbl('user_profile'),array('rating','rated_by','voters'),
|
||||
array("$new_rate","$rated_by","|no_mc|$voters"),
|
||||
" userid = ".$id."");
|
||||
|
||||
$userDetails = array(
|
||||
"object_id" => $id,
|
||||
"type" => "user",
|
||||
"time" => now(),
|
||||
"rating" => $rating,
|
||||
"userid" => userid(),
|
||||
"username" => username()
|
||||
);
|
||||
/* Updating user details */
|
||||
update_user_voted($userDetails);
|
||||
e(lang("thnx_for_voting"),"m");
|
||||
}
|
||||
|
||||
|
@ -5045,6 +5054,37 @@ function getSubscriptionsUploadsWeek($uid,$limit=20,$uploadsType="both",$uploads
|
|||
return $new_sessions;
|
||||
}
|
||||
|
||||
|
||||
function update_user_voted($array,$userid=NULL)
|
||||
{
|
||||
global $db;
|
||||
//$voted = array();
|
||||
if(!$userid)
|
||||
$userid = userid();
|
||||
if(phpversion < '5.2.0')
|
||||
{
|
||||
global $json;
|
||||
$js = $json;
|
||||
}
|
||||
if(is_array($array))
|
||||
{
|
||||
$votedDetails = $db->select(tbl("users"),"voted"," userid = '$userid'");
|
||||
if(!empty($votedDetails))
|
||||
if(!empty($js))
|
||||
$voted = $js->json_decode($votedDetails[0]['voted'],TRUE);
|
||||
else
|
||||
$voted = json_decode($votedDetails[0]['voted'],TRUE);
|
||||
|
||||
//$votedArray = $voted;
|
||||
$voted[] = $array;
|
||||
|
||||
if(!empty($js))
|
||||
$votedEncode = $js->json_encode($voted);
|
||||
else
|
||||
$votedEncode = json_encode($voted);
|
||||
|
||||
if(!empty($votedEncode))
|
||||
$db->update(tbl("users"),array("voted"),array("|no_mc|$votedEncode")," userid='$userid'");
|
||||
}
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -1186,7 +1186,7 @@ class CBvideo extends CBCategory
|
|||
$rating = $params['rating'];
|
||||
$ratings = $params['ratings'];
|
||||
$total = $params['total'];
|
||||
$id = $params['id'];
|
||||
$id = $params['id'];
|
||||
$type = $params['type'];
|
||||
|
||||
//Checking Percent
|
||||
|
@ -1200,6 +1200,8 @@ class CBvideo extends CBCategory
|
|||
}
|
||||
|
||||
$perc = $perc.'%';
|
||||
$disperc = 100 - $perc.'%';
|
||||
$likes = floor($ratings*$perc/100); // get lowest integer
|
||||
|
||||
if($params['is_rating'])
|
||||
{
|
||||
|
@ -1216,10 +1218,13 @@ class CBvideo extends CBCategory
|
|||
}
|
||||
|
||||
assign('perc',$perc);
|
||||
assign('disperc',$disperc);
|
||||
assign('id',$id);
|
||||
assign('type',$type);
|
||||
assign('id',$id);
|
||||
assign('rating_msg',$rating_msg);
|
||||
assign("likes",$likes);
|
||||
assign("dislikes",($ratings-$likes));
|
||||
assign('disable',$params['disable']);
|
||||
|
||||
Template('blocks/rating.html');
|
||||
|
@ -1233,10 +1238,10 @@ class CBvideo extends CBCategory
|
|||
function rate_video($id,$rating)
|
||||
{
|
||||
global $db;
|
||||
|
||||
if(!is_numeric($rating) || $rating <1)
|
||||
$rating = 1;
|
||||
if($rating>10)
|
||||
|
||||
if(!is_numeric($rating) || $rating <= 9)
|
||||
$rating = 0;
|
||||
if($rating >= 10)
|
||||
$rating = 10;
|
||||
|
||||
$rating_details = $this->get_video_rating($id);
|
||||
|
@ -1244,7 +1249,62 @@ class CBvideo extends CBCategory
|
|||
|
||||
$new_by = $rating_details['rated_by'];
|
||||
$newrate = $rating_details['rating'];
|
||||
if(phpversion < '5.2.0')
|
||||
global $json; $js = $json;
|
||||
|
||||
if(!empty($js))
|
||||
$voters = $js->json_decode($voter_id,TRUE);
|
||||
else
|
||||
$voters = json_decode($voter_id,TRUE);
|
||||
|
||||
if(!empty($voters))
|
||||
$already_voted = array_key_exists(userid(),$voters);
|
||||
|
||||
if(!userid())
|
||||
e(lang("please_login_to_rate"));
|
||||
elseif(userid()==$rating_details['userid'] && !config('own_video_rating'))
|
||||
e(lang("you_cant_rate_own_video"));
|
||||
elseif(!empty($already_voted))
|
||||
e(lang("you_hv_already_rated_vdo"));
|
||||
elseif(!config('video_rating') || $rating_details['allow_rating'] !='yes' )
|
||||
e(lang("vid_rate_disabled"));
|
||||
else
|
||||
{
|
||||
$voters[userid()] = array(
|
||||
"userid" => userid(),
|
||||
"username" => username(),
|
||||
"time" => now(),
|
||||
"rating" => $rating
|
||||
);
|
||||
|
||||
if(!empty($js))
|
||||
$voters = $js->json_encode($voters);
|
||||
else
|
||||
$voters = json_encode($voters);
|
||||
|
||||
$t = $rating_details['rated_by'] * $rating_details['rating'];
|
||||
$new_by = $rating_details['rated_by'] + 1;
|
||||
$newrate = ($t + $rating) / $new_by;
|
||||
$db->update(tbl($this->dbtbl['video']),array("rating","rated_by","voter_ids"),array($newrate,$new_by,"|no_mc|$voters")," videoid='$id'");
|
||||
$userDetails = array(
|
||||
"object_id" => $id,
|
||||
"type" => "video",
|
||||
"time" => now(),
|
||||
"rating" => $rating,
|
||||
"userid" => userid(),
|
||||
"username" => username()
|
||||
);
|
||||
/* Updating user details */
|
||||
update_user_voted($userDetails);
|
||||
e(lang("thnx_for_voting"),"m");
|
||||
}
|
||||
|
||||
$result = array('rating'=>$newrate,'ratings'=>$new_by,'total'=>10,'id'=>$id,'type'=>'video','disable'=>'disabled');
|
||||
return $result;
|
||||
|
||||
|
||||
/*
|
||||
Following code is unused
|
||||
$niddle = "|";
|
||||
$niddle .= userid();
|
||||
$niddle .= "|";
|
||||
|
@ -1277,6 +1337,7 @@ class CBvideo extends CBCategory
|
|||
|
||||
$result = array('rating'=>$newrate,'ratings'=>$new_by,'total'=>10,'id'=>$id,'type'=>'video','disable'=>'disabled');
|
||||
return $result;
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -5576,4 +5576,10 @@
|
|||
|
||||
if($assign) assign($assign,$array); else return $array;
|
||||
}
|
||||
|
||||
function update_user_voted($array,$userid=NULL)
|
||||
{
|
||||
global $userquery;
|
||||
return $userquery->update_user_voted($array,$userid);
|
||||
}
|
||||
?>
|
|
@ -8,10 +8,12 @@
|
|||
*/
|
||||
|
||||
define("IN_MODULE",true);
|
||||
define("THIS_PAGE",$_GET["p"]);
|
||||
define("PARENT_PAGE",$_GET["s"]);
|
||||
define("PARENT_PAGE",$_GET['s']);
|
||||
define("THIS_PAGE",$_GET['p']);
|
||||
|
||||
require 'includes/config.inc.php';
|
||||
|
||||
|
||||
$pages->page_redir();
|
||||
|
||||
/*if(is_installed('editorspick'))
|
||||
|
|
BIN
upload/styles/cbv2new/images/thumbs.png
Normal file
BIN
upload/styles/cbv2new/images/thumbs.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 1.8 KiB |
|
@ -1,4 +1,4 @@
|
|||
<div id="rating_container">
|
||||
<!-- <div id="rating_container">
|
||||
<ul class="big_stars {$disable}" id="rating_container_{$id}">
|
||||
<li class="current-rating" style="width:{$perc}"></li>
|
||||
<li>
|
||||
|
@ -19,4 +19,16 @@
|
|||
</li>
|
||||
</ul>
|
||||
<div id="rating_result_container" align="center">{if $rating_msg}{$rating_msg}{else}Rate this {$type}{/if}</div>
|
||||
</div> -->
|
||||
|
||||
<div id="rating_container">
|
||||
<div class="newRating clearfix">
|
||||
<div{if !$disable} onclick="rate('{$id}','5','{$type}')"{/if} onMouseOver="rating_over('Like this {$type}','{$disable}')" onmouseout="rating_out('Rate this {$type}','{$disable}')" class="newLike">Like</div>
|
||||
<div style="width:88px; float:left; height:14px; margin-top:8px">
|
||||
<div class="greenBar" style="width:{$perc}"></div>
|
||||
<div class="redBar" style="width:{$disperc}"></div>
|
||||
</div>
|
||||
<div{if !$disable} onclick="rate('{$id}','1','{$type}')"{/if} onMouseOver="rating_over('Dislike this {$type}','{$disable}')" onmouseout="rating_out('Rate this {$type}','{$disable}')" class="newDislike">Dislike</div>
|
||||
</div>
|
||||
<div id="rating_result_container" style="margin-top:4px;" align="center">{if $rating_msg}{$rating_msg}{else}{$likes} Likes, {$dislikes} Dislikes{/if}</div>
|
||||
</div>
|
|
@ -461,7 +461,7 @@ ul.sub_categories ul.sub_categories{border:none}
|
|||
-moz-border-radius:5px;
|
||||
border-radius: 5px;
|
||||
-webkit-border-radius: 5px;
|
||||
display:inline-block; width:18px; height:18px; line-height:18px; text-align:center; background-image:url(../images/nav_grads.png); background-position:-0px -223px; border:1px solid #CCC; text-decoration:none}
|
||||
display:inline-block; padding:0 3px; height:18px; line-height:18px; text-align:center; background-image:url(../images/nav_grads.png); background-position:-0px -223px; border:1px solid #CCC; text-decoration:none}
|
||||
|
||||
.pagination .selected{ background-position:-0px -241px; color:#fff; border-color:#0066cc}
|
||||
|
||||
|
|
|
@ -63,8 +63,35 @@
|
|||
.big_stars .current-rating{
|
||||
z-index:1;
|
||||
background-position: left top;
|
||||
}
|
||||
}
|
||||
|
||||
.disabled a:hover{
|
||||
background: url(../images/big_stars.png) left -1000px repeat-x;!important width:inherit;!important
|
||||
}
|
||||
|
||||
/* Following is styles of new like and dislike buttons*/
|
||||
.newRating { border:1px solid #ccc; border-radius:4px; -moz-border-radius:4px; -webkit-border-radius:4px; background-color:#f3f3f3;
|
||||
background-image: -webkit-gradient(linear,left bottom,left top,from(#eeeeee),to(#ffffff));
|
||||
background-image: -moz-linear-gradient(bottom, #eeeeee, #ffffff);
|
||||
background-image: -o-linear-gradient(bottom, #eeeeee, #ffffff);
|
||||
filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr=#ffffff, endColorStr=#eeeeee); }
|
||||
.newLike, .newDislike { background:none; border:0px; padding:0px; margin:0px; text-indent:-90000px; width:14px; height:14px; padding:5px; display:block;}
|
||||
.newLike { background:url(../images/thumbs.png) -1px 1px no-repeat; float:left; border-right:1px solid #ccc; }
|
||||
.newLike:hover { cursor:pointer; background-position:-1px -21px; }
|
||||
.newLike:active { background-position:-1px -20px; }
|
||||
|
||||
.newDislike { background:url(../images/thumbs.png) -31px 0px no-repeat; float:right; border-left:1px solid #ccc; }
|
||||
.newDislike:hover { cursor:pointer; background-position:-31px -22px; }
|
||||
.newDislike:active { background-position:-31px -21px; }
|
||||
.greenBar { height:50%; background-color:#156200;
|
||||
background-image: -webkit-gradient(linear,left bottom,left top,from(#156200),to(#1e8c01));
|
||||
background-image: -moz-linear-gradient(bottom, #156200, #1e8c01);
|
||||
background-image: -o-linear-gradient(bottom, #156200, #1e8c01);
|
||||
filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr=#1e8c01, endColorStr=#156200); float:left; position:relative; border-right:1px solid white; }
|
||||
|
||||
|
||||
.redBar { height:50%; background-color:#990000;
|
||||
background-image: -webkit-gradient(linear,left bottom,left top,from(#990000),to(#c40000));
|
||||
background-image: -moz-linear-gradient(bottom, #990000, #c40000);
|
||||
background-image: -o-linear-gradient(bottom, #990000, #c40000);
|
||||
filter: progid:DXImageTransform.Microsoft.Gradient(startColorStr=#c40000, endColorStr=#990000); float:left; position:relative; margin-right:-1px; }
|
||||
|
|
|
@ -102,7 +102,7 @@ function doUpdateVideo(formId,ID)
|
|||
show_error(data.error,ID,true);
|
||||
$('#updateVideoDataLoading').empty();
|
||||
$('#cbSubmitUpload'+ID)
|
||||
.attr("disabled","")
|
||||
.removeAttr("disabled")
|
||||
.attr("value",lang.saveData)
|
||||
.attr("onClick","doUpdateVideo('#uploadForm"+ID+"','"+ID+"')")
|
||||
},"json"
|
||||
|
@ -169,7 +169,7 @@ $(document).ready(function()
|
|||
.after('<input type="hidden" name="updateVideo" value="yes" id="updateVideo" />');
|
||||
$('#cbSubmitUpload'+ID)
|
||||
.before('<span id="updateVideoDataLoading" style="margin-right:5px"></span>')
|
||||
.attr("disabled","")
|
||||
.removeAttr("disabled")
|
||||
.attr("value",lang.saveData)
|
||||
.attr("onClick","doUpdateVideo('#uploadForm"+ID+"','"+ID+"')");
|
||||
|
||||
|
|
|
@ -13,8 +13,6 @@ define("PARENT_PAGE","upload");
|
|||
|
||||
require 'includes/config.inc.php';
|
||||
|
||||
|
||||
|
||||
$pages->page_redir();
|
||||
subtitle('upload');
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue