Файл: adultscript-2.0.3-pro/files/admin/modules/language/components/files.php
Строк: 65
<?php
defined('_VALID') or die('Restricted Access!');
class VComponent_Admin_language_files extends VModule_Admin_language
{
public function __construct()
{
}
public function render()
{
$db = VF::factory('database');
$filter = VF::factory('filter');
$errors = array();
$messages = array();
$code = (isset($_GET['code'])) ? $filter->get('code', 'STRING', 'GET') : '';
$files = array();
$pagination = array();
$db->query("SELECT name FROM #__language WHERE code = '".$db->escape($code)."' LIMIT 1");
if ($db->affected_rows()) {
if (isset($_POST['action']) && isset($_POST['file_id'])) {
$action = trim($_POST['action']);
$file_id = (int) trim($_POST['file_id']);
if ($file_id) {
if ($action == 'delete') {
$db->query("SELECT type, name
FROM #__language_files
WHERE file_id = ".$file_id."
LIMIT 1");
if ($db->affected_rows()) {
$data = $db->fetch_assoc();
$db->query("DELETE FROM #__language_files WHERE file_id = ".$file_id." LIMIT 1");
VF::cache_del($code.'.'.$data['type'].'.'.$data['name'], 'language');
$messages[] = 'Language file deleted!';
} else {
$errors[] = 'Invalid language file id! Are you sure this language file exists!?';
}
} else {
$errors[] = 'Invalid action! What exactly did you click!?';
}
} else {
$errors[] = 'Invalid language file id! What exactly did you click!?';
}
}
$sql_count = "SELECT COUNT(*) AS total_files FROM #__language_files WHERE code = '".$db->escape($code)."'";
$total_files = $db->get_field($sql_count, 'total_files');
$pagination = VPagination::get(1, $total_files, 50);
$sql = "SELECT file_id, name, description, type
FROM #__language_files
WHERE code = '".$db->escape($code)."'
ORDER BY name ASC
LIMIT ".$pagination['limit'];
$files = $db->get_rows($sql);
}
$tpl = VF::factory('template');
$tpl->menu = 'main';
$tpl->submenu = 'extend';
$tpl->extramenu = 'language_manage';
$tpl->meta_title = 'Admin::Language::Files';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->code = $code;
$tpl->files = $files;
$tpl->pagination = $pagination;
$tpl->load(array('header', 'language_files_manage', 'footer'));
$tpl->display();
}
}