예제 #1
0
파일: Core.php 프로젝트: samsoncms/seo_tags
 /**
  * Create structures
  * @return bool
  */
 public function prepare()
 {
     $this->query = dbQuery('structure');
     $migrate = new \samson\cms\seo\Migrate($this->query);
     // Execute migrations
     $migrate->migrate();
     return parent::prepare();
 }
예제 #2
0
 public function init(array $params = array())
 {
     // Create top parent container
     $this->workspace = new Container($this);
     // Create main UI menu
     $menu = new Menu($this, $this->workspace);
     $menu->set('class', 'main-menu');
     // Create home item
     $homeItem = new MenuItem($menu);
     $homeItem->set('title', 'Home')->set('class', 'btn-home')->set('content', '<a href="/"><i class="sprite sprite-header_home" href="/"></i></a>');
     // Create site item
     $siteItem = new MenuItem($menu);
     $siteItem->set('title', t('Перейти на веб-сайт', true))->set('class', 'btn-site')->set('content', '<a href="/"><i class="sprite sprite-header_site" href="/"></i></a>');
     // Fire event that ui menu left container has been created
     Event::fire('cms_ui.mainmenu_leftcreated', array(&$menu, &$this));
     // Create exit item
     $exitItem = new MenuItem($menu);
     $exitItem->set('title', t('Выйти', true))->set('class', 'btn-icon-right btn-logout')->set('content', '<a href="signin/logout"><i class="sprite sprite-header_logout" href="/"></i></a>');
     // Create settings item
     $settingsItem = new MenuItem($menu);
     $settingsItem->set('title', t('Выйти', true))->set('class', 'btn-icon-right btn-settings')->set('content', '<a href="settings"><i class="sprite sprite-header_settings" href="/"></i></a>');
     // Create i18n menu
     $i18nMenu = new Menu($this, $menu);
     $i18nMenu->set('title', t('Выберите язык', true))->set('class', 'i18n-list');
     // Iterate all supported locales
     foreach (\samson\core\SamsonLocale::get() as $locale) {
         $localeItem = new MenuItem($i18nMenu);
         $url = $locale == DEFAULT_LOCALE ? '' : '/' . $locale;
         $localeItem->set('class', 'i18n_item-' . $locale . ' ' . ($locale == \samson\core\SamsonLocale::current() ? 'i18n-active' : ''))->set('content', '<a href="' . $url . '">' . $locale . '</a>');
     }
     // Fire event that ui menu container has been created
     Event::fire('cms_ui.mainmenu_created', array(&$menu, &$this));
     // Create main UI menu
     $subMenu = new Menu($this, $menu);
     $subMenu->set('class', 'sub-menu');
     // Fire event that ui sub-menu container has been created
     Event::fire('cms_ui.submenu_created', array(&$subMenu, &$this));
     // Create main-content panel
     $mainPanel = new Container($this, $this->workspace);
     $mainPanel->set('class', 'mainPanel ' . (sizeof($subMenu->children()) ? 'with-sub-menu' : ''));
     /*// Create form with tabs
             $form = new Form($this, $mainPanel);
     
             // Create form tab view
             $tabs = new TabView($form);
     
             // Add tab
             $tab = new Tab($tabs);
             $tab->header->set('content', '<span>Описание</span>');
     
             // Create localized tabs
             foreach (\samson\core\SamsonLocale::get() as $locale) {
                 (new Tab($tab))->header->set('content', '<span>'.$locale.'</span>');
             }*/
     // Fire event that ui workspace container has been created
     Event::fire('cms_ui.workspace_created', array(&$this->workspace, &$this));
     return parent::init($params);
 }
예제 #3
0
 /**
  * Initialize module
  * @param array $params Collection of module parameters
  * @return bool True if module successfully initialized
  */
 public function init(array $params = array())
 {
     if (!$this->loadExternalService($this->fileServiceClassName)) {
         // Signal error
         Event::fire('error', array($this, 'Cannot initialize file system adapter[' . $this->fileServiceClassName . ']'));
     }
     // Call parent initialization
     return parent::init($params);
 }
예제 #4
0
 public function init(array $params = array())
 {
     parent::init($params);
     if (isset($this->renderer)) {
         $this->renderer =& m($this->renderer);
     } else {
         $this->renderer =& $this;
     }
     Event::fire('commerce.init.module.commerce.core', array(&$this));
 }
예제 #5
0
 /**
  * Init module
  * @param array $params
  */
 public function init(array $params = array())
 {
     parent::init($params);
     //Save LiqPay library instance
     $this->gate = new \LiqPay($this->publicKey, $this->privateKey);
     //Base part of back url
     if (!isset($this->resultUrl)) {
         $this->resultUrl = url_build('/');
     }
     //Call event
     Event::fire('commerce.gateinited', array(&$this));
 }
예제 #6
0
 /**
  * Module initialization
  */
 public function init(array $params = array())
 {
     // Create default or users Request object
     $this->request = !isset($this->request) || !class_exists($this->request) ? new Request() : new $this->request();
     // If configuration for API Key is not set
     if (!isset($this->apiKey)) {
         // Signal error
         Event::fire('error', array($this, 'Cannot initialize Translate module - Google API Key does not exists'));
     } else {
         // Create default get url
         $this->get = 'https://www.googleapis.com/language/translate/v2?key=' . $this->apiKey;
     }
     // Call parent initialization
     return parent::init($params);
 }
예제 #7
0
 /**
  * Initialize module
  * @param array $params Collection of module parameters
  * @return bool True if module successfully initialized
  */
 public function init(array $params = array())
 {
     // If defined file service is not supported
     if (!class_exists($this->fileServiceClassName)) {
         // Signal error
         Event::fire('error', array($this, 'Cannot initialize file system adapter[' . $this->fileServiceClassName . ']'));
     } else {
         /** @var \samson\fs\AbstractFileService Create file service instance */
         $this->fileService = new $this->fileServiceClassName();
         // Set nested file service instance parameters
         foreach ($this->configuration as $key => $value) {
             $this->fileService->{$key} = $value;
         }
         // Initialize file service
         $this->fileService->initialize();
     }
     // Call parent initialization
     return parent::init($params);
 }
예제 #8
0
 /**
  * Init module
  * @param array $params
  */
 public function init(array $params = array())
 {
     // Call parent handler
     parent::init($params);
     // Subscribe to payment gate init event
     Event::subscribe('commerce.gateinited', array($this, 'addGate'));
     // Subscribe to commerce core initialization
     Event::subscribe('commerce.init.module.commerce.core', array($this, 'initCommerceCore'));
 }
예제 #9
0
 /**
  * Module initialization
  * @param array $params
  * @return bool
  */
 public function init(array $params = array())
 {
     // Create default or users Request object
     $this->request = !isset($this->request) ? new Request() : new $this->request();
     // If configuration for API Key is not set
     if (!isset($this->appId) || !isset($this->appSecret)) {
         // Signal error
         Event::fire('error', array($this, 'Cannot initialize Instagram module - API keys does not exists'));
     }
     // Call parent initialization
     return parent::init($params);
 }
예제 #10
0
파일: CMS.php 프로젝트: rmolodyko/api
    /**
     * @see ModuleConnector::prepare()
     */
    public function prepare()
    {
        // Create cms_version
        $this->database->execute('
CREATE TABLE IF NOT EXISTS `cms_version`  (
  `version` varchar(15) NOT NULL DEFAULT \'30\'
) ENGINE=InnoDB DEFAULT CHARSET=utf8;');
        // Perform this migration and execute only once
        if ($this->migrator() != 40) {
            // Perform SQL table creation
            $path = __DIR__ . '/../sql/';
            foreach (array_slice(scandir($path), 2) as $file) {
                trace('Performing database script [' . $file . ']');
                foreach ($this->readSQL($path . $file, $this->tablePrefix) as $sql) {
                    $this->database->execute($sql);
                }
            }
            $this->migrator(40);
        }
        // Initiate migration mechanism
        $this->database->migration(get_class($this), array($this, 'migrator'));
        // Define permanent table relations
        new TableRelation('material', 'user', 'UserID', 0, 'user_id');
        new TableRelation('material', 'gallery', 'MaterialID', TableRelation::T_ONE_TO_MANY);
        new TableRelation('material', 'materialfield', 'MaterialID', TableRelation::T_ONE_TO_MANY);
        new TableRelation('material', 'field', 'materialfield.FieldID', TableRelation::T_ONE_TO_MANY);
        new TableRelation('material', 'structurematerial', 'MaterialID', TableRelation::T_ONE_TO_MANY);
        new TableRelation('material', 'structure', 'structurematerial.StructureID', TableRelation::T_ONE_TO_MANY);
        new TableRelation('materialfield', 'field', 'FieldID');
        new TableRelation('materialfield', 'material', 'MaterialID');
        new TableRelation('structurematerial', 'structure', 'StructureID');
        new TableRelation('structurematerial', 'materialfield', 'MaterialID', TableRelation::T_ONE_TO_MANY);
        new TableRelation('structurematerial', 'material', 'MaterialID', TableRelation::T_ONE_TO_MANY);
        new TableRelation('structure', 'material', 'structurematerial.MaterialID', TableRelation::T_ONE_TO_MANY, null, 'manymaterials');
        new TableRelation('structure', 'gallery', 'structurematerial.MaterialID', TableRelation::T_ONE_TO_MANY, null, 'manymaterials');
        /*new TableRelation( 'structure', 'material', 'MaterialID' );*/
        new TableRelation('structure', 'user', 'UserID', 0, 'user_id');
        new TableRelation('structure', 'materialfield', 'material.MaterialID', TableRelation::T_ONE_TO_MANY, 'MaterialID', '_mf');
        new TableRelation('structure', 'structurematerial', 'StructureID', TableRelation::T_ONE_TO_MANY);
        //new TableRelation('related_materials', 'material', 'first_material', TableRelation::T_ONE_TO_MANY, 'MaterialID');
        //new TableRelation('related_materials', 'materialfield', 'first_material', TableRelation::T_ONE_TO_MANY, 'MaterialID');
        new TableRelation('field', 'structurefield', 'FieldID');
        new TableRelation('field', 'structure', 'structurefield.StructureID');
        new TableRelation('structurefield', 'field', 'FieldID');
        new TableRelation('structurefield', 'materialfield', 'FieldID');
        new TableRelation('structurefield', 'material', 'materialfield.MaterialID');
        new TableRelation('structure', 'structure_relation', 'StructureID', TableRelation::T_ONE_TO_MANY, 'parent_id', 'children_relations');
        new TableRelation('structure', 'structure', 'children_relations.child_id', TableRelation::T_ONE_TO_MANY, 'StructureID', 'children');
        new TableRelation('structure', 'structure_relation', 'StructureID', TableRelation::T_ONE_TO_MANY, 'child_id', 'parents_relations');
        new TableRelation('structure', 'structure', 'parents_relations.parent_id', TableRelation::T_ONE_TO_MANY, 'StructureID', 'parents');
        new TableRelation('structurematerial', 'structure_relation', 'StructureID', TableRelation::T_ONE_TO_MANY, 'parent_id');
        new TableRelation('groupright', 'right', 'RightID', TableRelation::T_ONE_TO_MANY);
        // TODO: Should be removed
        m('activerecord')->relations();
        $classWriter = new GenericWriter($this->database, new Generator(), __NAMESPACE__ . '\\generated', [\samsoncms\api\generator\analyzer\RealAnalyzer::class => [\samsoncms\api\generator\RealEntity::class, \samsoncms\api\generator\RealQuery::class, \samsoncms\api\generator\RealCollection::class], \samsoncms\api\generator\analyzer\TableTraitAnalyzer::class => [\samsoncms\api\generator\TableTrait::class], \samsoncms\api\generator\analyzer\VirtualAnalyzer::class => [\samsoncms\api\generator\VirtualEntity::class, \samsoncms\api\generator\VirtualQuery::class, \samsoncms\api\generator\VirtualCollection::class], \samsoncms\api\generator\analyzer\GalleryAnalyzer::class => [\samsoncms\api\generator\Gallery::class], \samsoncms\api\generator\analyzer\TableAnalyzer::class => [\samsoncms\api\generator\TableVirtualEntity::class, \samsoncms\api\generator\TableVirtualQuery::class, \samsoncms\api\generator\TableVirtualCollection::class, \samsoncms\api\generator\Table::class, \samsoncms\api\generator\Row::class]], $this->cache_path);
        $classWriter->write();
        return parent::prepare();
    }
예제 #11
0
 /** Serialization handler */
 public function __sleep()
 {
     // Remove all unnecessary fields from serialization
     return array_diff(parent::__sleep(), array('authorized', 'user'));
 }
예제 #12
0
파일: CMS.php 프로젝트: rmolodyko/cms_api
 /**
  * @see ModuleConnector::prepare()
  */
 public function prepare()
 {
     // SQL команда на добавление таблицы пользователей
     $sql_user = "******" . dbMySQLConnector::$prefix . "user` (\n              `UserID` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `FName` varchar(255) NOT NULL,\n\t\t  `SName` varchar(255) NOT NULL,\n\t\t  `TName` varchar(255) NOT NULL,\n\t\t  `Email` varchar(255) NOT NULL,\n\t\t  `Password` varchar(255) NOT NULL,\n\t\t  `md5_email` varchar(255) NOT NULL,\n\t\t  `md5_password` varchar(255) NOT NULL,\n\t\t  `Created` datetime NOT NULL,\n\t\t  `Modyfied` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t  `GroupID` int(11) NOT NULL,\n\t\t  `Active` int(11) NOT NULL,\n\t\t  `Online` int(11) NOT NULL,\n\t\t  `LastLogin` datetime NOT NULL,\n\t\t  PRIMARY KEY (`UserID`)\n\t\t) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     // SQL команда на добавление таблицы пользователей
     $sql_gallery = "CREATE TABLE IF NOT EXISTS `" . dbMySQLConnector::$prefix . "gallery` (\n\t\t  `PhotoID` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `MaterialID` int(11) NOT NULL,\n\t\t  `Path` varchar(255) NOT NULL,\n\t\t  `Src` varchar(255) NOT NULL,\n\t\t  `Loaded` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t  `Description` text NOT NULL,\n\t\t  `Name` varchar(255) NOT NULL,\n\t\t  `Active` int(11) NOT NULL,\n\t\t  PRIMARY KEY (`PhotoID`)\n\t\t) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     // SQL команда на добавление таблицы групп пользователей
     $sql_group = "CREATE TABLE IF NOT EXISTS `" . dbMySQLConnector::$prefix . "group` (\n\t\t  `GroupID` int(20) NOT NULL AUTO_INCREMENT,\n\t\t  `Name` varchar(255) NOT NULL,\n\t\t  `Active` int(11) NOT NULL,\n\t\t  PRIMARY KEY (`GroupID`)\n\t\t) ENGINE=INNODB DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     // SQL команда на добавление таблицы связей пользователей и групп
     $sql_groupright = "CREATE TABLE IF NOT EXISTS `" . dbMySQLConnector::$prefix . "groupright` (\n\t\t  `GroupRightID` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `GroupID` int(10) NOT NULL,\n\t\t  `RightID` int(20) NOT NULL,\n\t\t  `Entity` varchar(100) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL DEFAULT '_',\n\t\t  `Key` varchar(50) CHARACTER SET utf8 COLLATE utf8_unicode_ci NOT NULL,\n\t\t  `Ban` int(10) NOT NULL,\n\t\t  `TS` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t  `Active` int(11) NOT NULL,\n\t\t  PRIMARY KEY (`GroupRightID`)\n\t\t) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0;";
     // SQL команда на добавление таблицы прав пользователей
     $sql_right = "CREATE TABLE IF NOT EXISTS `" . dbMySQLConnector::$prefix . "right` (\n\t\t  `RightID` int(20) NOT NULL AUTO_INCREMENT,\n\t\t  `Name` varchar(255) NOT NULL,\n\t\t  `Description` varchar(255) NOT NULL,\n\t\t  `Active` int(11) NOT NULL,\n\t\t  PRIMARY KEY (`RightID`)\n\t\t) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     // Related materials
     $sql_relation_material = "CREATE TABLE IF NOT EXISTS `" . dbMySQLConnector::$prefix . "related_materials` (\n\t\t  `related_materials_id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `first_material` int(11) NOT NULL,\n\t\t  `first_locale` varchar(10) NOT NULL,\n\t\t  `second_material` int(11) NOT NULL,\n\t\t  `second_locale` varchar(10) NOT NULL,\n\t\t  PRIMARY KEY (`related_materials_id`)\n\t\t) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     // SQL команда на добавление таблицы материалов
     $sql_material = "CREATE TABLE IF NOT EXISTS `" . dbMySQLConnector::$prefix . "material` (\n\t\t  `MaterialID` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `Name` varchar(555) NOT NULL,\n\t\t  `Content` text NOT NULL,\n\t\t  `Published` int(11) NOT NULL,\n\t\t  `Created` datetime NOT NULL,\n\t\t  `UserID` int(11) NOT NULL,\n\t\t  `Modyfied` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t  `Teaser` text NOT NULL,\n\t\t  `Url` varchar(255) NOT NULL,\n\t\t  `Keywords` varchar(255) NOT NULL,\n\t\t  `Description` varchar(255) NOT NULL,\n\t\t  `Title` varchar(255) NOT NULL,\n\t\t  `Draft` int(11) NOT NULL,\n\t\t  `Draftmaterial` int(11) NOT NULL,\n\t\t  `Active` int(11) NOT NULL DEFAULT '1',\n\t\t  `structure_id` int(11) NOT NULL,\n\t\tPRIMARY KEY (`MaterialID`),\n\t\tKEY `Url` (`Url`)\n\t\t) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     // SQL команда на добавление таблицы навигации
     $sql_structure = "CREATE TABLE IF NOT EXISTS `" . dbMySQLConnector::$prefix . "structure` (\n\t\t  `StructureID` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `ParentID` int(11) NOT NULL,\n\t\t  `Name` varchar(255) NOT NULL,\n\t\t  `Created` datetime NOT NULL,\n\t\t  `UserID` int(11) NOT NULL,\n\t\t  `Modyfied` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t  `Url` varchar(255) NOT NULL,\n\t\t  `MaterialID` int(11) NOT NULL,\n\t\t  `PriorityNumber` int(11) NOT NULL,\n\t\t  `Active` int(11) NOT NULL DEFAULT '1',\n\t\tPRIMARY KEY (`StructureID`),\n\t\tKEY `Url` (`Url`)\n\t\t) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     // SQL комманда на создание таблицы связей навигации и материалов
     $sql_structurematerial = "CREATE TABLE IF NOT EXISTS `" . dbMySQLConnector::$prefix . "structurematerial` (\n\t\t  `StructureMaterialID` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `StructureID` int(11) NOT NULL,\n\t\t  `MaterialID` int(11) NOT NULL,\n\t\t  `Modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t  `Active` int(11) NOT NULL DEFAULT '1',\n\t\t  PRIMARY KEY (`StructureMaterialID`),\n\t\t  KEY `StructureID` (`StructureID`),\n\t\t  KEY `MaterialID` (`MaterialID`)\n\t\t) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     // SQL команда на добавление таблицы полей
     $sql_field = "CREATE TABLE IF NOT EXISTS `" . dbMySQLConnector::$prefix . "field` (\n\t\t  `FieldID` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `ParentID` int(11) NOT NULL,\n\t\t  `Name` varchar(255) NOT NULL,\n\t\t  `Type` int(11) NOT NULL,\n\t\t  `Value` text NOT NULL,\n\t\t  `Description` text NOT NULL,\n\t\t  `UserID` int(11) NOT NULL,\n\t\t  `Created` datetime NOT NULL,\n\t\t  `Modyfied` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t  `Active` int(11) NOT NULL,\n\t\t  PRIMARY KEY (`FieldID`)\n\t\t) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     // SQL команда на добавление таблицы связей ЄНС с полями
     $sql_navfield = "CREATE TABLE IF NOT EXISTS `" . dbMySQLConnector::$prefix . "structurefield` (\n\t\t  `StructureFieldID` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `StructureID` int(11) NOT NULL,\n\t\t  `FieldID` int(11) NOT NULL,\n\t\t  `Modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,\n\t\t  `Active` int(11) NOT NULL,\n\t\t  PRIMARY KEY (`StructureFieldID`),\n\t\t  KEY `StructureID` (`StructureID`)\n\t\t) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     // SQL комманда на создание таблицы связей материалов и полей
     $sql_materialfield = "CREATE TABLE IF NOT EXISTS `" . dbMySQLConnector::$prefix . "materialfield` (\n\t\t  `MaterialFieldID` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `FieldID` int(11) NOT NULL,\n\t\t  `MaterialID` int(11) NOT NULL,\n\t\t  `Value` text NOT NULL,\n\t\t  `Active` int(11) NOT NULL,\n\t\t  PRIMARY KEY (`MaterialFieldID`),\n\t\t  KEY `MaterialID` (`MaterialID`)\n\t\t) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     // SQL комманда на создание таблицы связей между структурами
     $sql_structure_relation = "CREATE TABLE IF NOT EXISTS `" . dbMySQLConnector::$prefix . "structure_relation` (\n\t\t  `structure_relation_id` int(11) NOT NULL AUTO_INCREMENT,\n\t\t  `parent_id` int(11) NOT NULL,\n\t\t  `child_id` int(11) NOT NULL,\n\t\t  PRIMARY KEY (`structure_relation_id`)\n\t\t) ENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     // SQL table for storing database version
     $sql_version = " CREATE TABLE IF NOT EXISTS `" . dbMySQLConnector::$prefix . "cms_version` ( `version` varchar(15) not null default '1')\n\t\t\t\tENGINE=INNODB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=0 ;";
     // Выполним SQL комманды
     db()->query($sql_version);
     db()->query($sql_field);
     db()->query($sql_navfield);
     db()->query($sql_materialfield);
     db()->query($sql_material);
     db()->query($sql_structure);
     db()->query($sql_structurematerial);
     db()->query($sql_user);
     db()->query($sql_group);
     db()->query($sql_right);
     db()->query($sql_groupright);
     db()->query($sql_relation_material);
     db()->query($sql_gallery);
     db()->query($sql_structure_relation);
     // Initiate migration mechanism
     db()->migration(get_class($this), array($this, 'migrator'));
     // Define permanent table relations
     new TableRelation('material', 'user', 'UserID', 0, 'user_id');
     new TableRelation('material', 'gallery', 'MaterialID', TableRelation::T_ONE_TO_MANY);
     new TableRelation('material', 'materialfield', 'MaterialID', TableRelation::T_ONE_TO_MANY);
     new TableRelation('material', 'field', 'materialfield.FieldID', TableRelation::T_ONE_TO_MANY);
     new TableRelation('material', 'structurematerial', 'MaterialID', TableRelation::T_ONE_TO_MANY);
     new TableRelation('material', 'structure', 'structurematerial.StructureID', TableRelation::T_ONE_TO_MANY);
     new TableRelation('materialfield', 'field', 'FieldID');
     new TableRelation('materialfield', 'material', 'MaterialID');
     new TableRelation('structurematerial', 'structure', 'StructureID');
     new TableRelation('structurematerial', 'materialfield', 'MaterialID', TableRelation::T_ONE_TO_MANY);
     new TableRelation('structurematerial', 'material', 'MaterialID', TableRelation::T_ONE_TO_MANY);
     new TableRelation('structure', 'material', 'structurematerial.MaterialID', TableRelation::T_ONE_TO_MANY, null, 'manymaterials');
     new TableRelation('structure', 'gallery', 'structurematerial.MaterialID', TableRelation::T_ONE_TO_MANY, null, 'manymaterials');
     /*new TableRelation( 'structure', 'material', 'MaterialID' );*/
     new TableRelation('structure', 'user', 'UserID', 0, 'user_id');
     new TableRelation('structure', 'materialfield', 'material.MaterialID', TableRelation::T_ONE_TO_MANY, 'MaterialID', '_mf');
     new TableRelation('structure', 'structurematerial', 'StructureID', TableRelation::T_ONE_TO_MANY);
     new TableRelation('related_materials', 'material', 'first_material', TableRelation::T_ONE_TO_MANY, 'MaterialID');
     new TableRelation('related_materials', 'materialfield', 'first_material', TableRelation::T_ONE_TO_MANY, 'MaterialID');
     new TableRelation('field', 'structurefield', 'FieldID');
     new TableRelation('field', 'structure', 'structurefield.StructureID');
     new TableRelation('structurefield', 'field', 'FieldID');
     new TableRelation('structurefield', 'materialfield', 'FieldID');
     new TableRelation('structurefield', 'material', 'materialfield.MaterialID');
     new TableRelation('structure', 'structure_relation', 'StructureID', TableRelation::T_ONE_TO_MANY, 'parent_id', 'children_relations');
     new TableRelation('structure', 'structure', 'children_relations.child_id', TableRelation::T_ONE_TO_MANY, 'StructureID', 'children');
     new TableRelation('structure', 'structure_relation', 'StructureID', TableRelation::T_ONE_TO_MANY, 'child_id', 'parents_relations');
     new TableRelation('structure', 'structure', 'parents_relations.parent_id', TableRelation::T_ONE_TO_MANY, 'StructureID', 'parents');
     new TableRelation('structurematerial', 'structure_relation', 'StructureID', TableRelation::T_ONE_TO_MANY, 'parent_id');
     new TableRelation('groupright', 'right', 'RightID', TableRelation::T_ONE_TO_MANY);
     //elapsed('CMS:prepare');
     // Все прошло успешно
     return true && parent::prepare();
 }