Вход Регистрация
Файл: adultscript-2.0.3-pro/files/mobile/components/photo_view.php
Строк: 58
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_mobile_photo_view extends VComponent_mobile_photo
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        
$photo_id VUri::request(1);
        
$cache_id 'photo_'.$photo_id;
        if (!
$photo $this->cache->get($cache_id7200)) {
            
$this->db->query("SELECT p.photo_id, p.album_id, p.caption, p.ext,
                                     p.rating, p.rated_by, p.allow_rating, p.allow_comment,
                                     p.total_views, p.total_favorites, a.title, a.slug, a.user_id,
                                     GROUP_CONCAT(t.name) AS tags
                              FROM #__photo AS p
                              INNER JOIN #__photo_albums AS a ON (a.album_id = p.album_id AND a.mobile = '1' AND a.status = '1')
                              INNER JOIN #__photo_tags AS t ON (t.album_id = a.album_id)
                              WHERE p.photo_id = "
.$photo_id."
                              LIMIT 1"
);
            if (!
$this->db->affected_rows()) {
                  
$this->notfound();
            }
            
            
$photo $this->db->fetch_assoc();
            
$this->cache->store($cache_id$photo7200);
        }
        
        
$album_id   = (int) $photo['album_id'];
        
$prev_photo NULL;
        
$this->db->query("SELECT photo_id
                          FROM #__photo
                          WHERE album_id = "
.$album_id."
                          AND photo_id != "
.$photo_id."
                          AND photo_id < "
.$photo_id."
                          ORDER BY photo_id DESC
                          LIMIT 1"
);
        if (
$this->db->affected_rows()) {
              
$prev_photo    $this->db->fetch_field('photo_id');
        }
        
        
$next_photo NULL;
        
$this->db->query("SELECT photo_id
                          FROM #__photo
                          WHERE album_id = "
.$album_id."
                          AND photo_id != "
.$photo_id."
                          AND photo_id > "
.$photo_id."
                          ORDER BY photo_id ASC
                          LIMIT 1"
);
        if (
$this->db->affected_rows()) {
              
$next_photo    $this->db->fetch_field('photo_id');
        }

        
$this->db->query("UPDATE #__photo
                          SET total_views = total_views+1
                          WHERE photo_id = "
.$photo_id."
                          LIMIT 1"
);
                          
        if (
$this->mcfg['view_comments']) {
            
$this->tpl->comments        $this->get_comments($photo_id);
            
$this->tpl->comments_total  $this->get_total_comments($photo_id);
        }

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

        
$this->tpl->share        = ($this->mcfg['share_enabled']) ? TRUE FALSE;
        
$this->tpl->title       $photo['title'];
        
$this->tpl->meta_title    __('photo-meta-title', array($photo['photo_id'], $this->mcfg['site_name']));
        
$this->tpl->meta_desc    __('photo-meta-desc', array($photo['photo_id'], $this->mcfg['meta_desc']));
        
$this->tpl->meta_keys    $photo['tags'].', '.$this->mcfg['meta_keys'];

        
$this->tpl->canonical    BASE_URL.'/photo/'.$photo['photo_id'].'/';

        
$this->tpl->photo       $photo;
        
$this->tpl->prev_photo    $prev_photo;
        
$this->tpl->next_photo    $next_photo;
        
$this->tpl->load(array('header''photo_view''footer'));
        
$this->tpl->display();        
    }

    private function 
get_total_comments($photo_id)
    {
        
$this->db->query("SELECT COUNT(*) AS total_comments
                          FROM #__photo_comments
                          WHERE photo_id = "
.$photo_id."
                          AND status = '1'"
);
 
        return 
$this->db->fetch_field('total_comments');
    }
    
    private function 
get_comments($photo_id)
    {
        
$this->db->query("SELECT c.comment_id, c.parent_id, c.user_id,
                                c.comment, c.add_time, c.nickname,
                                u.username, u.gender, u.avatar
                          FROM #__photo_comments AS c
                          LEFT JOIN #__user AS u ON (u.user_id = c.user_id)
                          WHERE c.photo_id = "
.$photo_id."
                          AND c.status = '1'
                          ORDER BY c.comment_id DESC
                          LIMIT "
.$this->mcfg['comments_per_page']);
        
        return 
$this->db->fetch_rows();
    }    
}
Онлайн: 2
Реклама