browse_videos.tpl
PHP:
{include file='header.tpl'}
{* $Id: browse_videos.tpl 13 2009-01-11 06:04:29Z john $ *}
<div class='page_header'>{lang_print id=5500029}</div>
<div style='padding: 7px 10px 7px 10px; background: #F2F2F2; border: 1px solid #BBBBBB; margin: 10px 0px 10px 0px; font-weight: bold;'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td>
{lang_print id=5500071}
</td>
<td>
<select class='small' name='v' onchange="window.location.href='browse_videos.php?s={$s}&v='+this.options[this.selectedIndex].value;">
<option value='0'{if $v == "0"} SELECTED{/if}>{lang_print id=5500072}</option>
{if $user->user_exists}<option value='1'{if $v == "1"} SELECTED{/if}>{lang_print id=5500073}</option>{/if}
</select>
</td>
<td style='padding-left: 20px;'>
{lang_print id=5500074}
</td>
<td>
<select class='small' name='s' onchange="window.location.href='browse_videos.php?v={$v}&s='+this.options[this.selectedIndex].value;">
<option value='video_datecreated DESC'{if $s == "video_dateupdated DESC"} SELECTED{/if}>{lang_print id=5500075}</option>
<option value='video_views DESC'{if $s == "video_views DESC"} SELECTED{/if}>{lang_print id=5500144}</option>
<option value='video_cache_rating_weighted DESC'{if $s == "video_cache_rating_weighted DESC"} SELECTED{/if}>{lang_print id=5500156}</option>
</select>
</td>
</tr>
</table>
</div>
{* DISPLAY PAGINATION MENU IF APPLICABLE *}
{if $maxpage > 1}
<div style='text-align: center; padding-bottom: 10px;'>
{if $p != 1}<a href='browse_videos.php?s={$s}&v={$v}&p={math equation='p-1' p=$p}'>« {lang_print id=182}</a>{else}« {lang_print id=182}{/if}
|
{if $p_start == $p_end}
<b>{lang_sprintf id=184 1=$p_start 2=$total_videos}</b>
{else}
<b>{lang_sprintf id=185 1=$p_start 2=$p_end 3=$total_videos}</b>
{/if}
|
{if $p != $maxpage}<a href='browse_videos.php?s={$s}&v={$v}&p={math equation='p+1' p=$p}'>{lang_print id=183} »</a>{else}{lang_print id=183} »{/if}
</div>
{/if}
<div>
{section name=video_loop loop=$videos}
{* ENSURE VIDEO TITLE ISN'T BLANK *}
{if $videos[video_loop].video_title == ""}{capture assign="video_title"}{lang_print id=589}{/capture}{else}{assign var="video_title" value=$videos[video_loop].video_title}{/if}
<div class='videoTab' style='width: 275px;'>
<table cellpadding='0' cellspacing='0'>
<tr>
<td style='vertical-align: top;'>
<a href='{$url->url_create("video", $videos[video_loop].video_author->user_info.user_username, $videos[video_loop].video_id)}'><img src='{if $videos[video_loop].video_thumb}{$videos[video_loop].video_dir}{$videos[video_loop].video_id}_thumb.jpg{else}./images/video_placeholder.gif{/if}' border='0' width='{$setting.setting_video_thumb_width}' height='{$setting.setting_video_thumb_height}'></a>
</td>
<td style='vertical-align: top; padding-left: 5px;'>
<div class='video_row_title'><a href='{$url->url_create("video", $videos[video_loop].video_author->user_info.user_username, $videos[video_loop].video_id)}'>{$video_title|truncate:55:'...':true}</a></div>
<div class='video_row_info'>{lang_sprintf id=5500023 1=$videos[video_loop].total_comments} - {lang_sprintf id=5500070 1=$videos[video_loop].video_views}</div>
<div>
{section name=full_loop start=0 loop=$videos[video_loop].video_rating_full}
<img src='./images/icons/video_rating_full_small.gif' border='0'>
{/section}
{if $videos[video_loop].video_rating_part}<img src='./images/icons/video_rating_part_small.gif' border='0'>{/if}
{section name=none_loop start=0 loop=$videos[video_loop].video_rating_none}
<img src='./images/icons/video_rating_none_small.gif' border='0'>
{/section}
</div>
</td>
</tr>
</table>
</div>
{cycle values=",,<div style='clear: both; height: 0px;'></div>"}
{/section}
<div style='clear: both; height: 0px;'></div>
</div>
{include file='footer.tpl'}
browse_videos.php
PHP:
[B][/B]
<?php
/* $Id: browse_videos.php 22 2009-01-16 05:50:49Z john $ */
$page = "browse_videos";
include "header.php";
// DISPLAY ERROR PAGE IF USER IS NOT LOGGED IN AND ADMIN SETTING REQUIRES REGISTRATION
if( !$user->user_exists && !$setting['setting_permission_video'] )
{
$page = "error";
$smarty->assign('error_header', 639);
$smarty->assign('error_message', 656);
$smarty->assign('error_submit', 641);
include "footer.php";
}
// PARSE GET/POST
if(isset($_POST['p'])) { $p = $_POST['p']; } elseif(isset($_GET['p'])) { $p = $_GET['p']; } else { $p = 1; }
if(isset($_POST['s'])) { $s = $_POST['s']; } elseif(isset($_GET['s'])) { $s = $_GET['s']; } else { $s = "video_datecreated DESC"; }
if(isset($_POST['v'])) { $v = $_POST['v']; } elseif(isset($_GET['v'])) { $v = $_GET['v']; } else { $v = 0; }
// ENSURE SORT/VIEW ARE VALID
if($s != "video_datecreated DESC" && $s != "video_views DESC" && $s != "video_cache_rating_weighted DESC") { $s = "video_dateupdated DESC"; }
if($v != "0" && $v != "1") { $v = 0; }
// SET WHERE CLAUSE
$where = "video_search='1' AND video_is_converted='1' AND
(CASE
WHEN se_videos.video_user_id='{$user->user_info['user_id']}'
THEN TRUE
WHEN ((se_videos.video_privacy & @SE_PRIVACY_REGISTERED) AND '{$user->user_exists}'<>0)
THEN TRUE
WHEN ((se_videos.video_privacy & @SE_PRIVACY_ANONYMOUS) AND '{$user->user_exists}'=0)
THEN TRUE
WHEN ((se_videos.video_privacy & @SE_PRIVACY_FRIEND) AND (SELECT TRUE FROM se_friends WHERE friend_user_id1=se_videos.video_user_id AND friend_user_id2='{$user->user_info['user_id']}' AND friend_status='1' LIMIT 1))
THEN TRUE
WHEN ((se_videos.video_privacy & @SE_PRIVACY_SUBNET) AND '{$user->user_exists}'<>0 AND (SELECT TRUE FROM se_users WHERE user_id=se_videos.video_user_id AND user_subnet_id='{$user->user_info['user_subnet_id']}' LIMIT 1))
THEN TRUE
WHEN ((se_videos.video_privacy & @SE_PRIVACY_FRIEND2) AND (SELECT TRUE FROM se_friends AS friends_primary LEFT JOIN se_users ON friends_primary.friend_user_id1=se_users.user_id LEFT JOIN se_friends AS friends_secondary ON friends_primary.friend_user_id2=friends_secondary.friend_user_id1 WHERE friends_primary.friend_user_id1=se_videos.video_user_id AND friends_secondary.friend_user_id2='{$user->user_info['user_id']}' AND se_users.user_subnet_id='{$user->user_info['user_subnet_id']}' LIMIT 1))
THEN TRUE
ELSE FALSE
END)";
// ONLY MY FRIENDS' VIDEOS
if($v == "1" && $user->user_exists) {
// SET WHERE CLAUSE
$where .= " AND (SELECT TRUE FROM se_friends WHERE friend_user_id1='{$user->user_info['user_id']}' AND friend_user_id2=se_videos.video_user_id AND friend_status=1)";
}
// CREATE VIDEO OBJECT
$video = new se_video();
// GET TOTAL VIDEOS
$total_videos = $video->video_total($where);
// MAKE ENTRY PAGES
$videos_per_page = 21;
$page_vars = make_page($total_videos, $videos_per_page, $p);
// GET VIDEO ARRAY
$video_array = $video->video_list($page_vars[0], $videos_per_page, $s, $where, 1);
// ASSIGN SMARTY VARIABLES AND DISPLAY VIDEOS PAGE
$smarty->assign('videos', $video_array);
$smarty->assign('total_videos', $total_videos);
$smarty->assign('p', $page_vars[1]);
$smarty->assign('maxpage', $page_vars[2]);
$smarty->assign('p_start', $page_vars[0]+1);
$smarty->assign('p_end', $page_vars[0]+count($video_array));
$smarty->assign('s', $s);
$smarty->assign('v', $v);
include "footer.php";
?>