Файл: adultscript-2.0.3-pro/files/mobile/components/users_videos_favorites.php
Строк: 49
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_mobile_users_videos_favorites extends VComponent_mobile_users
{
public function __construct()
{
parent::__construct(true);
}
public function render()
{
$errors = array();
$messages = array();
$user_id = (int) $this->user['user_id'];
$page = (VUri::request(4)) ? (int) VUri::request(4) : 1;
$url = 'users/'.$this->username.'/videos/favorites/';
if ($page !== 1) {
$url .= $page.'/';
}
if (!VUri::match($url)) {
$this->notfound();
}
$this->update_views($user_id);
$sql_count = "SELECT COUNT(*) AS total_videos
FROM #__video_favorites AS vf
INNER JOIN #__video AS v ON (v.video_id = vf.video_id AND v.mobile = '1')
WHERE vf.user_id = ".$user_id;
$total_videos = $this->db->get_field($sql_count, 'total_videos');
$pagination = VPagination::get($page, $total_videos, 4);
$sql = "SELECT v.video_id, v.title, v.slug, v.rating, v.rated_by, v.thumb, v.thumbs, v.duration,
v.total_views, v.add_time, u.username
FROM #__video_favorites AS vf
LEFT JOIN #__video AS v ON (v.video_id = vf.video_id AND v.mobile = '1' AND v.status = 1)
LEFT JOIN #__user AS u ON (u.user_id = v.user_id)
WHERE vf.user_id = ".$user_id."
LIMIT ".$pagination['limit'];
if (!$videos = $this->cache->get($sql, 3600)) {
$this->db->query($sql);
if ($this->db->affected_rows()) {
$videos = $this->db->fetch_rows();
$this->cache->store($sql, $videos, 3600);
} else {
$videos = array();
}
}
$this->tpl->menu = 'community';
$this->tpl->submenu = 'videos';
$this->tpl->meta_title = __('favorites-meta-title', array($this->user['username'], $this->tpl->mcfg['site_name']));
$this->tpl->meta_desc = __('favorites-meta-desc', array($this->user['username'], $this->tpl->mcfg['meta_desc']));
$this->tpl->meta_keys = $this->mcfg['meta_keys'];
$this->tpl->canonical = BASE_URL.'/'.$url;
$this->tpl->errors = $errors;
$this->tpl->messages = $messages;
$this->tpl->user = $this->user;
$this->tpl->username = e($this->user['username']);
$this->tpl->is_subscribed = $this->is_subscribed;
$this->tpl->is_friend = $this->is_friend;
$this->tpl->is_self = $this->is_self;
$this->tpl->is_moderator = $this->is_moderator;
$this->tpl->is_loggedin = $this->is_loggedin;
$this->tpl->is_blocked = $this->is_blocked;
$this->tpl->videos = $videos;
$this->tpl->pagination = $pagination;
$this->tpl->load(array('header', 'users_videos_favorites', 'footer'));
$this->tpl->display();
}
}