Файл: adultscript-2.0.3-pro/files/modules/video/components/tag.php
Строк: 52
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_video_tag extends VModule_video
{
public function __construct()
{
parent::__construct();
}
public function render()
{
$query = VUri::query();
$tag = (isset($query['1'])) ? $query['1'] : '';
if (strpos($tag, ' ') !== false) {
VF::redirect(BASE_URL.'/tag/'.prepare_string($tag, true).'/', 301);
}
$page = (isset($query['2']) && $query['2']) ? (int) $query['2'] : 1;
$url = 'tag/'.prepare_string($tag, true).'/';
if ($page !== 0 && $page !== 1) {
$url .= $page.'/';
}
if (!VUri::match($url)) {
VModule::load('404', true);
}
VLanguage::load('frontend.video');
$tag = str_replace('-', ' ', $tag);
$tag = utf8_strtolower($tag);
$sql_count = "SELECT COUNT(*) AS total_videos
FROM #__video_tags AS vt
WHERE vt.name = '".$this->db->escape($tag)."'";
$total_videos = $this->db->get_field($sql_count, 'total_videos');
$pagination = VPagination::get($page, $total_videos, VCfg::get('video.tag_per_page'));
$sql = "SELECT v.video_id, v.title, v.slug, v.likes, v.rating, v.rated_by, v.duration, v.thumb,
v.thumbs, v.total_views, v.add_time, v.ext, v.hd, v.premium, u.username
FROM #__video_tags AS vt
INNER JOIN #__video AS v ON (v.video_id = vt.video_id AND v.status = 1)
LEFT JOIN #__user AS u ON (u.user_id = v.user_id)
WHERE vt.name = '".$this->db->escape($tag)."'
ORDER BY v.video_id DESC
LIMIT ".$pagination['limit'];
if (!$videos = $this->cache->get($sql, 86400)) {
$this->db->query($sql);
if ($this->db->affected_rows()) {
$videos = $this->db->fetch_rows();
$this->cache->store($sql, $videos, 86400);
} else {
$videos = array();
}
}
$page_name = ($page > 1) ? ' - '.__('page').' '.$page : '';
$this->tpl->menu = 'video';
$this->tpl->title = __('tag-title', array($tag, $page_name));
$this->tpl->meta_title = __('tag-meta-title', array($tag, $page_name, $this->tpl->cfg['site_name']));
$this->tpl->meta_desc = $this->tpl->meta_title.'. '.$this->tpl->cfg['meta_desc'];
$this->tpl->meta_keys = $tag.', '.$this->tpl->cfg['meta_keys'];
$this->tpl->canonical = BASE_URL.'/'.$url;
$this->tpl->canonicalm = MOBILE_URL.'/'.$url;
if ($page > 1) {
$prev = ($page > 2) ? ($page-1).'/' : '';
$this->tpl->prev_url = BASE_URL.'/tag/'.$tag.'/'.$prev;
}
if ($page < $pagination['total_pages']) {
$this->tpl->next_url = BASE_URL.'/tag/'.$tag.'/'.($page+1).'/';
}
$this->tpl->order = null;
$this->tpl->slug = null;
$this->tpl->timeline = null;
$this->tpl->tag = $tag;
$this->tpl->videos = $videos;
$this->tpl->pagination = $pagination;
$this->tpl->load(array('header', 'video_browse', 'footer'));
$this->tpl->display();
}
}