Вход Регистрация
Файл: adultscript-2.0.3-pro/files/modules/channel/components/browse.php
Строк: 119
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_channel_browse extends VModule_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') ? 'channels/'.$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_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." 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     __('most-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->css            = array(TPL_REL.'/css/style_channel.css');
          
          
$this->tpl->title        $order_name.' '.__('channels').$letter_name;
          
$this->tpl->meta_title    $this->tpl->title.$page_name.' - '.VF::cfg_item('site_name');
          
$this->tpl->meta_desc    $this->tpl->title.$page_name.'. '.VF::cfg_item('meta_desc');
          
$this->tpl->meta_keys    '';
          
          
$this->tpl->canonical    BASE_URL.'/'.$url;
          
$this->tpl->canonicalm    MOBILE_URL.'/'.$url;
          
          
$this->tpl->order        $order;
          
$this->tpl->letter        $letter;
          
$this->tpl->page        $page;
          
          
$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'name' => 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 (
ctype_digit($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 ''$letter ''$page 1)
{
    
$url RELATIVE_URL.'/channels/';
    if (
$letter != '' && $letter != 'all') {
        
$url .= $letter.'/';
    }

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

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

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