Файл: adultscript-2.0.3-pro/files/modules/photo/components/tag.php
Строк: 41
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_photo_tag extends VModule_photo
{
public function __construct()
{
parent::__construct();
}
public function render()
{
$query = VUri::query();
$tag = (isset($query['2'])) ? $query['2'] : '';
$page = (isset($query['3']) && $query['3']) ? (int) $query['3'] : 1;
$url = 'photo/tag/'.prepare_string($tag, true).'/';
if ($page !== 0 && $page !== 1) {
$url .= $page.'/';
}
if (!VUri::match($url)) {
VModule::load('404', TRUE);
}
VLanguage::load('frontend.photo');
$tag = str_replace('-', ' ', $tag);
$sql_count = "SELECT COUNT(*) AS total_albums
FROM #__photo_tags
WHERE name = '".$this->db->escape($tag)."'";
$total_albums = $this->db->get_field($sql_count, 'total_albums');
$pagination = VPagination::get($page, $total_albums, VCfg::get('photo.tag_per_page'));
$sql = "SELECT a.album_id, a.title, a.slug, a.rating, a.rated_by, a.total_views,
a.total_photos, a.likes, a.rated_by, a.add_time, a.type, u.username
FROM #__photo_tags AS t
LEFT JOIN #__photo_albums AS a ON (a.album_id = t.album_id AND a.status = '1')
LEFT JOIN #__user AS u ON (u.user_id = a.user_id)
WHERE t.name = '".$this->db->escape($tag)."'
ORDER BY a.album_id DESC
LIMIT ".$pagination['limit'];
if (!$albums = $this->cache->get($sql, 3600)) {
$this->db->query($sql);
if ($this->db->affected_rows()) {
$albums = $this->db->fetch_rows();
$this->cache->store($sql, $albums, 3600);
}
}
$this->tpl->menu = 'photo';
$this->tpl->meta_title = __('tag-meta-title', array($tag, $page, $this->tpl->cfg['site_name']));
$this->tpl->css = array(TPL_REL.'/css/style_photo.css');
$this->tpl->canonical = BASE_URL.'/'.$url;
$this->tpl->canonicalm = MOBILE_URL.'/'.$url;
$this->tpl->url = REL_URL.'/photo/tag/'.prepare_string($tag, true).'/#PAGE#/';
$this->tpl->tag = $tag;
$this->tpl->albums = $albums;
$this->tpl->pagination = $pagination;
$this->tpl->load(array('header', 'photo_albums', 'footer'));
$this->tpl->display();
}
}