Вход Регистрация
Файл: adultscript-2.0.3-pro/files/mobile/components/channel_browse.php
Строк: 118
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_mobile_channel_browse extends VComponent_mobile_channel
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        
$args       $this->get_query();
        
$letter     $args['letter'];
        
$order      $args['order'];
        
$page       $args['page'];

        
$url        = ($letter != 'all') ? 'channes/'.$letter.'/' 'channels/';

        if (
$order != 'recent' or $page 1) {
            
$url    .= $order.'/';
        }

        if (
$page 1) {
            
$url    .= $page.'/';
        }

        if (!
VUri::match($url)) {
            
VModule::load('404'true);
        }

        
VLanguage::load('frontend.channel');

        
$sql        "SELECT channel_id, name, slug, thumb, total_views,
                              total_videos, total_likes, total_votes
                       FROM #__channel"
;
        
$sql_count  "SELECT COUNT(*) AS total_channels
                       FROM #__channel"
;
        
$sql_delim  " WHERE";

        
$letter_name '';
        if (
$letter != 'all') {
            
$sql        .= $sql_delim." slug LIKE '".$letter."%'";
            
$sql_count  .= $sql_delim." AND slug LIKE '".$letter."%'";
            
$sql_delim  " AND";
            
$letter_name ' '.__('with-letter', array(strtoupper($letter)));
        }

        
$order_name '';
        if (
$order == 'recent') {
            
$sql        .= " ORDER BY add_time DESC";
            
$order_name  __('recent');
        } elseif (
$order == 'popular') {
            
$sql        .= " ORDER BY total_likes+total_subscribers DESC";
            
$order_name  __('popular');
        } elseif (
$order == 'videos') {
            
$sql        .= " ORDER BY total_videos DESC";
            
$order_name  __('videos');
        }
        
        
$total_channels $this->db->get_field($sql_count'total_channels');
        
$pagination     VPagination::get($page$total_channelsVF::cfg_item('module.channel.channels_per_page'));

        
$channels       $this->db->get_rows($sql.' LIMIT '.$pagination['limit']);
    
        
$page_name        = ($page 1) ? ' - '.__('page').' '.$page '';

        
$this->tpl->menu        'channel';
        
        
$this->tpl->title        $order_name.' '.__('channels').$letter_name.$page_name;
        
$this->tpl->meta_title    $this->tpl->title.' - '.$this->mcfg['site_name'];
        
$this->tpl->meta_desc    $this->tpl->title.'. '.$this->mcfg['meta_desc'];
        
$this->tpl->meta_keys    __('channels-meta-keys');
        
        
$this->tpl->order        $order;
        
$this->tpl->letter        $letter;
        
$this->tpl->page        $page;
        
        
$this->tpl->canonical    BASE_URL.'/'.$url;
        
        
$this->tpl->channels    $channels;
        
$this->tpl->pagination    $pagination;
        
        
$this->tpl->load(array('header''channel_browse''footer'));
        
$this->tpl->display();
    }

    protected function 
get_query()
    {
        
$options = array(
            
'order'     => 'recent',
            
'letter'    => 'all',
            
'page'      => 1,
            
'clean'     => false
        
);

        
$query      array_slice(VUri::query(), 1);
        
$orders     = array('recent' => 1'videos' => 1'popular' => 1);
        
$letters    range('a''z');
            
        
$arg        = (isset($query['0']) && $query['0'] != '') ? $query['0'] : null;
        if (isset(
$arg) && strlen($arg) === && ctype_alpha($arg)) {
            
$options['letter'] = $arg;
            
array_shift($query);
        }
        
        
$arg        = (isset($query['0']) && $query['0'] != '') ? $query['0'] : null;
        if (isset(
$arg)) {
            if (isset(
$orders[$arg])) {
                
$options['order'] = $arg;
                
array_shift($query);
            } else {
                
VModule::load('404'true);
            }
        }

        
$arg        = (isset($query['0']) && $query['0'] != '') ? $query['0'] : null;
        if (isset(
$arg)) {
            if (
is_numeric($arg)) {
                
$options['page'] = (int) $arg;
            } else {
                
VModule::load('404'true);
            }
        } else {
            
$options['clean'] = true;
        }
        
        if (
$options['page'] === 0) {
            
VModule::load('404'true);
        }
        
        return 
$options;
    }    
}

function 
build_url($order=''$page=1$letter='')
{
    
$url MOBILE_REL.'/channels/';
    if (
$letter != '' && $letter != 'all') {
        
$url .= $letter.'/';
    }

    if (
$order != 'recent' or $page 1) {
        
$url .= $order.'/';
    }

    if (
$page === true) {
        
$url .= '#PAGE#/';
    } elseif (
$page !== 1) {
        
$url .= $page.'/';
    }

    return 
$url;
}
Онлайн: 2
Реклама