Файл: adultscript-2.0.3-pro/files/modules/pornstar/components/browse.php
Строк: 69
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_pornstar_browse extends VModule_pornstar
{
public function __construct()
{
parent::__construct();
}
public function render()
{
// special case here...
if (CURRENT_URL == BASE_URL.'/pornstar/recent/') {
VF::redirect(BASE_URL.'/pornstar/', 301);
}
$args = $this->get_query();
$letter = $args['letter'];
$order = $args['order'];
$page = $args['page'];
$url = ($letter != 'all') ? 'pornstar/'.$letter.'/' : 'pornstar/';
if ($order != 'recent') {
$url .= $order.'/';
}
if ($page > 1) {
$url .= $page.'/';
}
if (!VUri::match($url)) {
VModule::load('404', true);
}
VLanguage::load('frontend.pornstar');
$sql = "SELECT model_id, name, slug, ext, likes, rating, rated_by, total_videos, total_views, total_albums
FROM #__model
WHERE status = '1'";
$sql_count = "SELECT COUNT(*) AS total_models
FROM #__model
WHERE status = '1'";
$letter_name = '';
if ($letter != 'all') {
$sql .= " AND slug LIKE '".$letter."%'";
$sql_count .= " AND slug LIKE '".$letter."%'";
$letter_name = ' '.__('with-letter', array(strtoupper($letter)));
}
$order_name = '';
switch ($order) {
case 'recent':
$sql .= " ORDER BY model_id DESC";
$order_name = __('most-recent');
break;
case 'popular':
$sql .= " ORDER BY total_views DESC";
$order_name = __('most-popular');
break;
case 'name':
$sql .= " ORDER BY slug ASC";
$order_name = __('alphabetically');
break;
case 'favorites':
$sql .= " ORDER BY total_favorites DESC";
$order_name = __('most-favorites');
break;
case 'rated':
$sql .= " ORDER BY (rating*rated_by) DESC";
$order_name = __('top-rated');
break;
case 'discussed':
$sql .= " ORDER BY total_comments DESC";
$order_name = __('most-discussed');
break;
default:
VModule::load('404', TRUE);
}
$total_models = $this->db->get_field($sql_count, 'total_models');
$pagination = VPagination::get($page, $total_models, VCfg::get('pornstar.models_per_page'));
$sql = $sql.' LIMIT '.$pagination['limit'];
if (!$models = $this->cache->get($sql, 3600)) {
$models = $this->db->get_rows($sql);
if ($models) {
$this->cache->store($sql, $models, 3600);
}
}
$sql = "SELECT name, slug
FROM #__model
WHERE status = '1'
ORDER BY total_views DESC
LIMIT 10";
if (!$popular = $this->cache->get($sql, 3600)) {
$popular = $this->db->get_rows($sql);
if ($popular) {
$this->cache->store($sql, $popular, 3600);
}
}
$this->tpl->menu = 'pornstar';
$this->tpl->title = $order_name.' '.__('pornstars').$letter_name;
$this->tpl->meta_title = __('browse-meta-title', array($order_name, $letter_name, $page));
$this->tpl->css = array(TPL_REL.'/css/style_model.css');
$this->tpl->canonical = BASE_URL.'/'.$url;
$this->tpl->canonicalm = MOBILE_URL.'/'.$url;
$this->tpl->order = $order;
$this->tpl->letter = $letter;
$this->tpl->letters = range('a', 'z');
$this->tpl->page = $page;
$this->tpl->popular = $popular;
$this->tpl->models = $models;
$this->tpl->pagination = $pagination;
$this->tpl->load(array('header', 'pornstar_browse', 'footer'));
$this->tpl->display();
}
}