Вход Регистрация
Файл: adultscript-2.0.3-pro/files/admin/modules/template/components/manage.php
Строк: 54
<?php
defined
('_VALID') or die('Restricted Access!');
class 
VComponent_Admin_template_manage
{
    private 
$db;
    public function 
__construct()
    {
        
$this->db VF::factory('database');
    }
    
    public function 
render()
    {
        
$errors        = array();
        
$messages    = array();
        
$type        = (VUri::request(2) != '') ? VUri::request(2) : 'frontend';
        
$types        = array('frontend''backend');
        if (!
in_array($type$types)) {
            throw new 
VException('Invalid templates type specified!');
        }
        
        if (isset(
$_POST['default'])) {
            
$option = ($type == 'frontend') ? 'template' 'template_admin';
            
$value    VF::factory('filter')->get('default');
            
$this->update_config($option$value);
            
$messages[] = 'Template marked active!';
        }
        
        
$this->db->query("SELECT tpl_id, name, description, version, provider, type, config, config_cache
                          FROM #__template
                          WHERE type = '"
.$this->db->escape($type)."'
                          ORDER BY name ASC"
);
        
        
$templates $this->db->fetch_rows();
        
        
$tpl VF::factory('template');
        
$tpl->cfg            VF::cfg('core.config'TRUETRUE);
        
$tpl->menu            'home';
        
$tpl->submenu        'extend';
        
$tpl->extramenu        $type;
        
$tpl->meta_title    'Admin::Templates::'.ucfirst($type);
        
$tpl->errors        $errors;
        
$tpl->messages        $messages;
        
$tpl->tpls            $templates;
        
$tpl->providers        = require BASE_DIR.'/config/providers.php';
        
$tpl->load(array('header''template_manage_'.$type'footer'));
        
$tpl->display();
    }
    
    private function 
update_config($option$value)
    {
        
$cfg         VF::cfg('config.config');
        
$cfg_file    = require BASE_DIR.'/config.php';
        foreach (
$cfg_file as $key => $val) {
            if (isset(
$cfg[$key])) {
                unset(
$cfg['key']);
            }
        }
        
        
$cfg[$option] = $value;
        
        
$this->db->query("UPDATE #__config
                          SET config_cache = '"
.$this->db->escape(serialize($cfg))."'
                          WHERE name = '"
.$this->db->escape($cfg_file['default'])."'
                          LIMIT 1"
);
        
        
VF::cache_set('config'$cfg'');
    }
}
Онлайн: 1
Реклама