CREATE TABLE IF NOT EXISTS `resource` (
  `id_resource` int(11) NOT NULL AUTO_INCREMENT,
  `id_item` int(11) NOT NULL,
  `id_resource_type` int(11) NOT NULL,
  `parent_id` int(11) NOT NULL DEFAULT '0',
  `position` tinyint(3) NOT NULL DEFAULT '0',
  `private` tinyint(1) NOT NULL DEFAULT '0',
  `deleted` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id_resource`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=13 ;
INSERT INTO `resource` (`id_resource`, `id_item`, `id_resource_type`, `parent_id`, `position`, `private`, `deleted`) VALUES
(1, 1, 1, 0, 1, 1, 0),
(3, 2, 1, 0, 0, 0, 0),
(4, 3, 1, 0, 2, 0, 0),
(5, 1, 2, 1, 0, 0, 0),
(6, 1, 3, 3, 1, 0, 0),
(7, 1, 4, 6, 1, 0, 0),
(8, 2, 4, 4, 0, 0, 0),
(9, 2, 3, 3, 0, 0, 0),
(10, 3, 4, 9, 0, 0, 0);

CREATE TABLE IF NOT EXISTS `resource_type` (
  `id_resource_type` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(32) CHARACTER SET utf8 NOT NULL,
  `alias` varchar(32) CHARACTER SET utf8 NOT NULL,
  `icon` varchar(32) CHARACTER SET utf8 NOT NULL,
  `active` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id_resource_type`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
INSERT INTO `resource_type` (`id_resource_type`, `name`, `alias`, `icon`, `active`) VALUES
(1, 'folder', 'Каталог', 'icon-folder-open', 1),
(2, 'page_template', 'Шаблон страницы', 'icon-list-alt', 1),
(3, 'page', 'Страница', 'icon-book', 1),
(4, 'resource', 'Ресурс', 'icon-file', 1);

CREATE TABLE IF NOT EXISTS `resource_type_folder` (
  `id_resource_type_folder` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(32) CHARACTER SET utf8 NOT NULL,
  PRIMARY KEY (`id_resource_type_folder`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=4 ;
INSERT INTO `resource_type_folder` (`id_resource_type_folder`, `name`) VALUES
(1, 'Шаблоны страниц'),
(2, 'Страницы'),
(3, 'Инструменты');

CREATE TABLE IF NOT EXISTS `resource_type_page` (
  `id_resource_type_page` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(32) NOT NULL,
  `id_resource_type_page_template` int(11) NOT NULL,
  `alias` varchar(256) NOT NULL,
  `route` varchar(256) NOT NULL DEFAULT '.*',
  `cache` tinyint(1) NOT NULL DEFAULT '0',
  `active` tinyint(1) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id_resource_type_page`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
INSERT INTO `resource_type_page` (`id_resource_type_page`, `name`, `id_resource_type_page_template`, `alias`, `route`, `cache`, `active`) VALUES
(1, 'Домашняя', 1, 'home', '.*', 0, 1),
(2, '404', 1, '404', '', 0, 1);

CREATE TABLE IF NOT EXISTS `resource_type_page_data` (
  `id_resource_type_page_data` int(11) NOT NULL AUTO_INCREMENT,
  `id_resource_type_page` int(11) NOT NULL,
  `id_lan` int(11) NOT NULL,
  `seo_title` varchar(256) NOT NULL,
  `seo_keywords` varchar(256) NOT NULL,
  `seo_description` text NOT NULL,
  PRIMARY KEY (`id_resource_type_page_data`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=18 ;
INSERT INTO `resource_type_page_data` (`id_resource_type_page_data`, `id_resource_type_page`, `id_lan`, `seo_title`, `seo_keywords`, `seo_description`) VALUES
(5, 1, 2, '', '', '');

CREATE TABLE IF NOT EXISTS `resource_type_page_template` (
  `id_resource_type_page_template` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(32) NOT NULL,
  `mime_type` int(11) NOT NULL DEFAULT '1',
  PRIMARY KEY (`id_resource_type_page_template`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=2 ;
INSERT INTO `resource_type_page_template` (`id_resource_type_page_template`, `name`, `mime_type`) VALUES
(1, 'Основной', 1);

CREATE TABLE IF NOT EXISTS `resource_type_page_template_translate` (
  `id_resource_type_page_template_translate` int(11) NOT NULL AUTO_INCREMENT,
  `id_resource_type_page_template` int(11) NOT NULL,
  `id_lan` tinyint(1) NOT NULL,
  `content` mediumtext NOT NULL,
  PRIMARY KEY (`id_resource_type_page_template_translate`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=3 ;
INSERT INTO `resource_type_page_template_translate` (`id_resource_type_page_template_translate`, `id_resource_type_page_template`, `id_lan`, `content`) VALUES
(2, 1, 2, '<html>\r\n <head>\r\n </head>\r\n <body>\r\n  {id_content}\r\n </body>\r\n</html>');

CREATE TABLE IF NOT EXISTS `resource_type_resource` (
  `id_resource_type_resource` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(32) NOT NULL,
  `alias` varchar(32) NOT NULL,
  `editor` tinyint(1) NOT NULL DEFAULT '0',
  PRIMARY KEY (`id_resource_type_resource`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=5 ;
INSERT INTO `resource_type_resource` (`id_resource_type_resource`, `name`, `alias`, `editor`) VALUES
(1, 'Содержимое', 'content', 0),
(3, 'Содержимое', 'content', 0),
(2, 'Google analytics', '', 0);

CREATE TABLE IF NOT EXISTS `resource_type_resource_translate` (
  `id_resource_type_resource_translate` int(11) NOT NULL AUTO_INCREMENT,
  `id_resource_type_resource` int(11) NOT NULL,
  `id_lan` tinyint(3) NOT NULL,
  `content` mediumtext NOT NULL,
  PRIMARY KEY (`id_resource_type_resource_translate`)
) ENGINE=MyISAM  DEFAULT CHARSET=utf8 AUTO_INCREMENT=10 ;
INSERT INTO `resource_type_resource_translate` (`id_resource_type_resource_translate`, `id_resource_type_resource`, `id_lan`, `content`) VALUES
(9, 1, 2, 'home Page'),
(8, 3, 2, '404 Page'),
(3, 2, 2, '');