Файл: adultscript-2.0.3-pro/files/admin/modules/language/components/manage.php
Строк: 93
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_language_manage extends VModule_Admin_language
{
public function __construct()
{
parent::__construct();
}
public function render()
{
$filter = VF::factory('filter');
$errors = array();
$messages = array();
if (isset($_POST['default'])) {
$default = $filter->get('default');
$this->update_config('language', $default);
$messages[] = 'Default language set to '.$default.'!';
}
if (isset($_POST['action']) && isset($_POST['code'])) {
$action = $filter->get('action');
$code = $filter->get('code');
if ($code) {
if ($action == 'enable' OR $action == 'disable') {
$status = ($action == 'enable') ? 1 : 0;
$msg = ($action == 'enable') ? 'enabled' : 'disabled';
$this->db->query("UPDATE #__language
SET status = '".$status."'
WHERE code = '".$this->db->escape($code)."'
LIMIT 1");
VF::cache_del('languages', 'config');
$messages[] = 'Language '.$msg.'!';
} elseif ($action == 'delete') {
$this->db->query("DELETE FROM #__language WHERE code = '".$this->db->escape($code)."' LIMIT 1");
$this->db->query("DELETE FROM #__language_files WHERE code = '".$this->db->escape($code)."'");
VF::cache_del('languages', 'config');
$messages[] = 'Language deleted!';
} else {
$errors[] = 'Invalid action! What exactly did you click!?';
}
} else {
$errors[] = 'Invalid language code! What exactly did you click!?';
}
}
$sql_count = "SELECT COUNT(*) AS total_languages FROM #__language";
$total_languages = $this->db->get_field($sql_count, 'total_languages');
$pagination = VPagination::get(1, $total_languages, 50);
$sql = "SELECT code, name, flag, status
FROM #__language
ORDER BY name ASC
LIMIT ".$pagination['limit'];
$tpl = VF::factory('template');
$tpl->cfg = VF::cfg('core.config', TRUE, TRUE);
$tpl->menu = 'main';
$tpl->submenu = 'extend';
$tpl->extramenu = 'language_manage';
$tpl->meta_title = 'Admin::Language::Manage';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->languages = $this->db->get_rows($sql);
$tpl->pagination = $pagination;
$tpl->load(array('header', 'language_manage', '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, '');
}
}