Файл: adultscript-2.0.3-pro/files/admin/modules/menu/components/add.php
Строк: 71
<?php
defined('_VALID') or die('Restricted Acces!');
class VComponent_Admin_menu_add
{
public function __construct()
{
}
public function render()
{
$db = VF::factory('database');
$errors = array();
$messages = array();
$item = array('name' => '', 'title' => '', 'status' => '1');
if (isset($_POST['submit_add_menu'])) {
$filter = &VF::factory('filter');
$name = $filter->get('name');
$title = $filter->get('title');
$status = $filter->get('status', 'INTEGER');
if ($name == '') {
$errors[] = 'Menu name cannot be left blank!';
} 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)."' LIMIT 1");
if ($db->affected_rows()) {
$errors[] = 'Menu name is already used for another menu!';
} else {
$item['name'] = $name;
}
}
if ($title == '') {
$errors[] = 'Menu title field cannot be left blank!';
} elseif (!VValid::length($title, 1, 255)) {
$errors[] = 'Menu title can contain maximum 255 characters!';
} else {
$item['title'] = $title;
}
if (!$errors) {
$db->query("INSERT INTO #__menu
SET name = '".$db->escape($name)."',
title = '".$db->escape($title)."',
status = '".$status."'");
if ($db->affected_rows()) {
$messages[] = 'Menu Added';
} else {
$errors[] = 'Failed to add menu!';
}
}
}
$tpl = &VF::factory('template');
$tpl->menu = 'main';
$tpl->submenu = 'menu_add';
$tpl->errors = $errors;
$tpl->messages = $messages;
$tpl->meta_title = 'Admin::Menu::Add';
$tpl->item = $item;
$tpl->load(array('header', 'menu_add', 'footer'));
$tpl->display();
}
}