Вход Регистрация
Файл: adultscript-2.0.3-pro/files/modules/photo/components/albums.php
Строк: 87
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_photo_albums extends VModule_photo
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
          
$args       $this->get_query(FALSE1);
        
$order      $args['order'];
        
$timeline   $args['timeline'];
        
$page       $args['page'];
        
        if (
$order == 'recent' && VUri::request(1) == '') {
              
VF::redirect(BASE_URL.'/photo/recent/''301');
        }
        
        
$url 'photo/'.$order.'/';
        if (
$timeline) {
              
$url .= $timeline.'/';
        }
                                                                    
        if (
$page 1) {
              
$url .= $page.'/';
        }
                                                                                                
        if (!
VUri::match($url)) {
              
VModule::load('404'true);
        }
        
        
VLanguage::load('frontend.photo');
        
        
$sql        "SELECT a.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 #__photo_albums AS a
                       LEFT JOIN #__user AS u ON (u.user_id = a.user_id)
                       WHERE a.status = '1'"
;
        
$sql_count    "SELECT COUNT(*) AS total_albums
                       FROM #__photo_albums AS a
                       WHERE a.status = '1'"
;
        
        
$time_name    '';
        if (
$timeline) {
              switch (
$timeline) {
                case 
'today':
                    
$start_time  strtotime('today');
                    
$end_time    $start_time+86400;
                    
$sql        .= " AND a.add_time > ".$start_time." AND a.add_time < ".$end_time;
                    
$sql_count  .= " AND a.add_time > ".$start_time." AND a.add_time < ".$end_time;
                    
$time_name   __('todays').' ';
                    break;
                case 
'yesterday':
                    
$start_time  strtotime('yesterday');
                    
$end_time    $start_time+86400;
                    
$sql        .= " AND a.add_time > ".$start_time." AND a.add_time < ".$end_time;
                    
$sql_count  .= " AND a.add_time > ".$start_time." AND a.add_time < ".$end_time;
                    
$time_name   __('yesterdays').' ';
                    break;
                case 
'week':
                    
$now         time();
                    
$start_time = (date('w'$now) === 1) ? strtotime('today'$now) : strtotime('last Monday'$now);
                    
$sql        .= " AND a.add_time > ".$start_time;
                    
$sql_count  .= " AND a.add_time > ".$start_time;
                    
$time_name   __('this-weeks').' ';
                    break;
                case 
'month':
                    
$start_time strtotime('first day of '.date('F Y'));
                    
$sql        .= " AND a.add_time > ".$start_time;
                    
$sql_count  .= " AND a.add_time > ".$start_time;
                    
$time_name   __('this-months').' ';
                    break;
                case 
'year':
                    
$start_time strtotime('first day of '.date('Y'));
                    
$sql        .= " AND a.add_time > ".$start_time;
                    
$sql_count  .= " AND a.add_time > ".$start_time;
                    
$time_name   __('this-years').' ';
                    break;
            }
        }
        
        switch (
$order) {
            case 
'recent':
                  
$sql           .= ' ORDER BY a.album_id DESC';
                
$order_name  ' '.__('most-recent');
                break;
            case 
'popular':
                
$sql       .= ' ORDER BY a.total_views DESC';
                
$order_name ' '.__('popular');
                break;
            case 
'discussed':
                
$sql        .= ' ORDER BY a.total_comments DESC';
                
$order_name  ' '.__('most-discussed');
                break;
            case 
'rated':
                
$sql       .= ' ORDER BY (a.rating+a.rated_by) DESC';
                
$order_name ' '.__('top-rated');
                break;
            case 
'favorited':
                
$sql       .= ' ORDER BY a.total_favorites DESC';
                
$order_name ' '.__('most-favorites');
                break;
            default:
                
VModule::load('404'TRUE);
        }
        
        
$total_albums   $this->db->get_field($sql_count'total_albums');
        
$pagination     VPagination::get($page$total_albumsVCfg::get('photo.browse_per_page'));
        
$sql            $sql' LIMIT '.$pagination['limit'];
        if (!
$albums $this->cache->get($sql3600)) {
              
$albums     $this->db->get_rows($sql);
            
$this->cache->store($sql$albums3600);
        }
        
        
$this->tpl->menu            'photo';
        
        
$this->tpl->css             = array(TPL_REL.'/css/style_photo.css');

        
$this->tpl->title           __('albums-title', array($time_name.$order_name));
        
$this->tpl->meta_title      __('albums-meta-title', array($time_name.$order_name$page$this->tpl->cfg['site_name']));

        
$this->tpl->canonical        BASE_URL.'/'.$url;
        
$this->tpl->canonicalm        MOBILE_URL.'/'.$url;
        
        
$this->tpl->url                build_url($order$timelinenulltrue);
          
        
$this->tpl->order           $order;
        
$this->tpl->timeline        $timeline;
        
$this->tpl->timename        $time_name;
        
$this->tpl->page            $page;

        
$this->tpl->albums          $albums;
        
$this->tpl->pagination      $pagination;

        
$this->tpl->load(array('header''photo_albums''footer'));
        
$this->tpl->display();
    }
}
Онлайн: 1
Реклама