Вход Регистрация
Файл: adultscript-2.0.3-pro/files/mobile/components/photo.php
Строк: 99
<?php
class VComponent_mobile_photo extends VMobile
{
    public function 
__construct()
    {
        
parent::__construct();
    }
    
    public function 
render()
    {
        if (!
VModule::enabled('photo')) {
            
$this->notfound();
        }
    
        
$segment      VUri::request(1);
        
$components = array('tag' => 1'rss' => 1'search' => 1'upload' => 1'edit' => 1'add' => 1);
        
$orders     = array('recent' => 1'popular' => 1'rated' => 1'discussed' => 1'favorited' => 1);
        
        if (!
$segment) {        
            
$component 'browse';
        } elseif (isset(
$components[$segment])) {
            
$component    $segment;
        } else {
            if (
ctype_digit($segment)) {
                if (
VUri::request(2) != '') {
                    if (
VUri::request(3) != '' && VUri::request(3) == 'slideshow') {
                        
$component 'slideshow';
                    } else {
                        
$component 'album';
                    }
                } else {
                    
$component 'view';
                }
            } else {
                
$component    = (isset($orders[$segment])) ? 'browse' 'category';
            }
        }
        
        
$component_class    'VComponent_mobile_photo_'.$component;

        try {
            require 
BASE_DIR.'/mobile/components/photo_'.$component.'.php';
            
            
$obj = new $component_class();
            
$obj->render();
        } catch (
Exception $e) {
            throw new 
VException($e);
        }        
    }

    protected function 
get_query($slug=FALSE$start=0)
    {
        
$options    = array(
            
'slug'      => '',
            
'order'     => 'recent',
            
'timeline'  => NULL,
            
'page'      => 1
        
);

        
$orders     = array('recent' => 1'popular' => 1'rated' => 1'discussed' => 1'favorited' => 1);
        
$timelines  = array('today' => 1'yesterday' => 1'week' => 1'month' => 1'year' => 1);

        
$query      VUri::query();
        if (
$start !== 0) {
            
$query array_slice($query$start);
        }

        if (
$slug !== FALSE) {
            if (isset(
$query['0']) && $query['0'] != '') {
                if (!isset(
$orders[$query['0']])) {
                    
$options['slug'] = $query['0'];
                    
array_shift($query);
                }
            }
        }

        
$arg    = (isset($query['0']) && $query['0'] != '') ? $query['0'] : NULL;
        if (isset(
$arg)) {
            if (isset(
$orders[$arg])) {
                
$options['order']   = $arg;
                
$type               $orders[$arg];
                
array_shift($query);
            } else {
                  
$this->notfound();
            }
        }
        
        
$arg    = (isset($query['0']) && $query['0'] != '') ? $query['0'] : NULL;
        if (isset(
$arg)) {
            if (
$type === 2) {
                
$options['page'] = (int) $arg;
            } else {
                if (
is_numeric($arg)) {
                    
$options['page'] = (int) $arg;
                } else {
                    if (isset(
$timelines[$arg])) {
                        
$options['timeline'] = $arg;
                        
array_shift($query);
                    } else {
                          
$this->notfound();
                    }
                }
            }
        }
        
        if (isset(
$query['0']) && is_numeric($query['0'])) {
            
$options['page'] = (int) $query['0'];
        }
        
        if (
$options['page'] === 0) {
              
$this->notfound();
        }
        
        return 
$options;
    }    
}

function 
build_url($order=''$timeline=''$slug=''$page=1$pagination=false)
{
    
$url MOBILE_REL.'/photo/';
    if (
$slug != '') {
        
$url .= $slug.'/';
    }
    
    if (
$order != '') {
        
$url .= $order.'/';
    }
    
    if (
$timeline != '') {
        
$url .= $timeline.'/';
    }
    
    if (
$page === true) {
        
$url .= '#PAGE#/';
    } elseif (
$page !== 1) {
        
$url .= $page.'/';
    }
    
    return 
$url;
}

function 
build_rss_url($order=''$timeline=''$slug='')
{
    
$url MOBILE_REL.'/photo/rss/';
    if (
$slug != '') {
        
$url .= $slug.'/';
    }
    
    if (
$order != '') {
        
$url .= $order.'/';
    }
    
    if (
$timeline != '') {
        
$url .= $timeline.'/';
    }
    
    return 
$url;
}
Онлайн: 2
Реклама