Вход Регистрация
Файл: adultscript-2.0.3-pro/files/modules/video/video.php
Строк: 85
<?php
defined
('_VALID') or die('Restricted Access!');
require 
'functions/url.php';
class 
VModule_video
{
    protected 
$db;
    protected 
$cache;
    protected 
$tpl;
    public function 
__construct()
    {
        
$this->db        VF::factory('database');
        
$this->cache    VF::factory('cache');
        
$this->tpl        VF::factory('template');
    }
    
    public function 
render()
    {
        
$component    VUri::request(0);
        
        
//temporary fix for the /video/tag/bug/
        
if ($component == 'video') {
            if (
VUri::request(1) == 'tag') {
                
$tag    str_replace(' ''-'htmlspecialchars(VUri::request(2)));
                if (
$tag != '') {
                    
VF::redirect(BASE_URL.'/tag/'.$tag.'/'301);
                }
            }
        }
        
        
$components    = array('tag' => 1'rss' => 1'search' => 1'upload' => 1'edit' => 1'download' => 1'related' => 1'playlist' => 1'playlists' => 1);
        
$orders        = array('recent' => 1'popular' => 1'discussed' => 1'rated' => 1'downloaded' => 1'longest' => 1'watched' => 1);
        
        if (!isset(
$components[$component])) {
            if (
is_numeric($component)) {
                
$component 'view';
            } else {
                if (isset(
$orders[$component])) {
                    
$component 'browse';
                } else {
                    
$component 'category';
                }
            }
        }
        
        
$component_class    'VComponent_video_'.$component;
        
        try {
            require 
MODULES_DIR.'/video/components/'.$component.'.php';
            
$obj = new $component_class();
            
$obj->render();
        } catch (
Exception $e) {
            throw new 
VException($e);
        }
    }

    protected function 
get_video_categories()
    {
        if (!
$categories $this->cache->get('categories'86400)) {
              
$this->db->query("SELECT cat_id, parent_id, name, slug, description, total_videos,
                                       title, meta_title, meta_desc, meta_keys
                                FROM #__video_categories
                                WHERE status = '1'
                                ORDER BY slug, parent_id ASC"
);
              if (
$this->db->affected_rows()) {
                  
$categories $this->db->fetch_rows();
                  if (
VCfg::get('video.subcategories') == '1') {
                      
$categories VArray::tree($categories);
                  }
                  
                  
$this->cache->store('categories'$categories86400);
              }
        }

        return 
$categories;
    }
    
    protected function 
get_query($slug=FALSE$start=0)
    {
          
$options     = array(
              
'slug'         => '',
              
'order'        => 'recent',
              
'timeline'    => NULL,
              
'page'        => 1
          
);
          
          
$orders        = array('recent' => 2'popular' => 1'rated' => 1'discussed' => 1'downloaded' => 1'longest' => 1'watched' => 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 {
                  
VModule::load('404'true);
              }
          }
          
          
$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 {
                          
VModule::load('404'true);
                      }
                  }
              }
          }
          
          if (isset(
$query['0']) && is_numeric($query['0'])) {
              
$options['page'] = (int) $query['0'];
          }
          
          if (
$options['page'] === 0) {
              
VModule::load('404'true);
          }
          
          return 
$options;
    }
}
Онлайн: 0
Реклама