Файл: adultscript-2.0.3-pro/files/admin/modules/menu/components/edit.php
Строк: 73
<?php
defined('_VALID') or die('Restricted Acces!');
class VComponent_Admin_menu_edit
{
public function __construct()
{
}
public function render()
{
$db = VF::factory('database');
$errors = array();
$messages = array();
$id = (isset($_GET['id']) && is_numeric($_GET['id'])) ? (int) trim($_GET['id']) : 0;
$item = array();
$db->query("SELECT menu_id FROM #__menu WHERE menu_id = ".$id." LIMIT 1");
if ($db->affected_rows()) {
if (isset($_POST['submit_edit_menu'])) {
$filter = &VF::factory('filter');
$name = $filter->get('name');
$title = $filter->get('title');
$status = $filter->get('status', 'INTEGER');
if ($name == '') {
$errors[] = 'Please enter menu name (identifier)!';
} elseif (!VValid::length($name, 1, 99)) {
$errors[] = 'Menu name can contain maximum 99 characters!';
} elseif (!VValid::alunderscore($name)) {
$errors[] = 'Menu name can contain only alphanumeric characters and underscores!';
} else {
$db->query("SELECT menu_id FROM #__menu WHERE name = '".$db->escape($name)."' AND menu_id != ".$id." LIMIT 1");
if ($db->affected_rows()) {
$errors[] = 'Menu name is already used by another menu!';
}
}
if ($title == '') {
$errors[] = 'Please enter menu title!';
} elseif (!VValid::length($title, 1, 255)) {
$errors[] = 'Menu title can contain maximum 255 characters!';
}
if (!$errors) {
$db->query("UPDATE #__menu
SET name = '".$db->escape($name)."',
title = '".$db->escape($title)."',
status = '".$status."'
WHERE menu_id = ".$id."
LIMIT 1");
$messages[] = 'Menu updated!';
}
}
$db->query("SELECT * FROM #__menu WHERE menu_id = ".$id." LIMIT 1");
$item = $db->fetch_assoc();
}
$tpl = &VF::factory('template');
$tpl->menu = 'main';
$tpl->submenu = 'menu';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->meta_title = 'Admin::Menu::Edit';
$tpl->item = $item;
$tpl->load(array('header', 'menu_edit', 'footer'));
$tpl->display();
}
}