Вход Регистрация
Файл: adultscript-2.0.3-pro/files/modules/pornstar/components/albums.php
Строк: 102
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_pornstar_albums extends VModule_pornstar
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        if (!
VModule::enabled('photo')) {
            
VModule::load('404'TRUE);
        }
    
        
$query VUri::query();
        
$slug  $query['1'];
        if (!
$pornstar $this->cache->get('pornstar_'.$slug3600)) {
            
$sql    "SELECT m.model_id, m.name, m.slug, m.description, m.ext, m.likes, m.rating, m.rated_by,
                              m.total_views, m.total_videos, m.total_albums, m.total_comments,
                              m.total_favorites, m.gender, mb.aliases, mb.birth_date, mb.birth_location,
                              mb.birth_name, mb.eye_color, mb.hair_color, mb.weight, mb.height,
                              mb.measurements, mb.ethnicity, mb.nationality, mb.natural_bust,
                              mb.performs, mb.links, mb.url, m.adv
                       FROM #__model AS m
                       LEFT JOIN #__model_bio AS mb ON (m.model_id = mb.model_id)
                       WHERE m.slug = '"
.$this->db->escape($slug)."'
                       AND m.status = '1'
                       LIMIT 1"
;
            
$this->db->query($sql);
            if (
$this->db->affected_rows()) {
                
$pornstar $this->db->fetch_assoc();
                
$this->cache->store('pornstar_'.$slug$pornstar3600);
            } else {
                
VModule::load('404'TRUE);
            }
        }
        
        
$page = (isset($query['3']) && is_numeric($query['3'])) ? (int) $query['3'] : 1;
        
$url  'pornstar/'.$pornstar['slug'].'/albums/';
        if (
$page !== 1) {
            
$url .= $page.'/';
        }
        
        if (!
VUri::match($url)) {
            
VModule::load('404'TRUE);
        }
        
        
VLanguage::load('frontend.pornstar');
        
        
$page       = (isset($_GET['page'])) ? (int) trim($_GET['page']) : 1;
        
$order      = (isset($_GET['o'])) ? trim($_GET['o']) : 'recent';
        
$orders     = array('recent' => __('recent'), 'popular' => __('popular'), 'rated' => __('rated'));
        if (!isset(
$orders[$order])) {
            
VModule::load('404'true);
        }
        
        if (
$order == 'recent') {
            
$sort   'a.add_time';
            
$title  __('recent');
        } elseif (
$order == 'popular') {
            
$sort   'a.total_views';
            
$title  __('popular');
        } elseif (
$order == 'rated') {
            
$sort   'a.likes';
            
$title  __('rated');
        }        
        
        
$model_id        = (int) $pornstar['model_id'];
        
$sql_count        "SELECT COUNT(*) AS total_albums
                             FROM #__model_albums
                             WHERE model_id = "
.$model_id;
        
$total_albums   $this->db->get_field($sql_count'total_albums');
        
$pagination        VPagination::get($page$total_albumsVCfg::get('pornstar.albums_per_page'));
        
$sql            "SELECT ma.album_id, a.title, a.slug, a.likes, a.rating, a.rated_by, a.total_views,
                                  a.total_photos, a.add_time, a.type, u.username
                           FROM #__model_albums AS ma
                           INNER JOIN #__photo_albums AS a ON (a.album_id = ma.album_id AND a.status = '1')
                           INNER JOIN #__user AS u ON (u.user_id = a.user_id)
                           WHERE ma.model_id = "
.$model_id."
                           ORDER BY "
.$sort." DESC
                           LIMIT "
.$pagination['limit'];
        if (!
$albums $this->cache->get($sql3600)) {
            
$this->db->query($sql);
            if (
$this->db->affected_rows()) {
                
$albums    $this->db->fetch_rows();
                
$this->cache->store($sql$albums3600);
            } else {
                
$albums    = array();
            }
        }

        
$title                  $title.' '.__('albums');
        
$title_add              = ($page 1) ? ' - '.$title.' '.__('page').' '.$page ' - '.$title;

        
$this->tpl->menu        'pornstar';

        
$this->tpl->title       $pornstar['name'].' '.$title;
        
$this->tpl->meta_title  __('pornstar-albums-meta-title', array($pornstar['name'].$title_addVF::cfg_item('site_name')));
        
$this->tpl->meta_desc   $this->tpl->meta_title.'. '.VF::cfg_item('meta_desc');
        
$this->tpl->meta_keys   strtolower($pornstar['name']).', '.VF::cfg_item('meta_keys');
        
        
$this->tpl->css            = array(TPL_REL.'/css/style_photo.css'TPL_REL.'/css/style_model.css');
        
        
$this->tpl->canonical    BASE_URL.'/'.$url;
        
$this->tpl->canonicalm    MOBILE_URL.'/'.$url;

        
$this->tpl->pornstar    $pornstar;
        
$this->tpl->order        $order;
        
$this->tpl->albums        $albums;
        
$this->tpl->pagination    $pagination;
        
        
$this->tpl->videos        $this->count_model_videos($model_id);
        
$this->tpl->comments    $this->count_model_comments($model_id);

        
$this->tpl->load(array('header''pornstar_albums''footer'));
        
$this->tpl->display();
    }
    
    private function 
count_model_videos($model_id)
    {
        
$sql_count                  "SELECT COUNT(*) AS total_videos
                                       FROM #__model_videos
                                       WHERE model_id = "
.$model_id;

        return 
$this->db->get_field($sql_count'total_videos');
    }

    private function 
count_model_comments($model_id)
    {
        
$sql_count              "SELECT COUNT(*) AS total_comments
                                   FROM #__model_comments
                                   WHERE model_id = "
.$model_id;
        return 
$this->db->get_field($sql_count'total_comments');
    }    
}
Онлайн: 2
Реклама