// install-new renamed to install-dev
This commit is contained in:
@@ -0,0 +1,127 @@
|
||||
<?php
|
||||
include_once('../init.php');
|
||||
include_once(_PS_ROOT_DIR_.'/config/settings.inc.php');
|
||||
include_once(_PS_INSTALL_PATH_.'classes/controllerHttp.php');
|
||||
|
||||
class SynchronizeController extends InstallControllerHttp
|
||||
{
|
||||
public function validate(){}
|
||||
public function display(){}
|
||||
public function processNextStep(){}
|
||||
|
||||
/**
|
||||
* @var InstallXmlLoader
|
||||
*/
|
||||
protected $loader;
|
||||
|
||||
public function displayTemplate($template, $get_output = false, $path = null)
|
||||
{
|
||||
parent::displayTemplate($template, false, _PS_INSTALL_PATH_.'dev/');
|
||||
}
|
||||
|
||||
public function init()
|
||||
{
|
||||
$this->type = Tools::getValue('type');
|
||||
$this->loader = new InstallXmlLoader();
|
||||
$languages = array();
|
||||
foreach (Language::getLanguages(false) as $language)
|
||||
$languages[$language['id_lang']] = $language['iso_code'];
|
||||
$this->loader->setLanguages($languages);
|
||||
|
||||
if (Tools::getValue('submit'))
|
||||
$this->generateSchemas();
|
||||
else if (Tools::getValue('synchronize'))
|
||||
$this->synchronizeEntities();
|
||||
|
||||
if ($this->type == 'demo')
|
||||
$this->loader->setFixturesPath();
|
||||
else
|
||||
$this->loader->setDefaultPath();
|
||||
$this->displayTemplate('index');
|
||||
}
|
||||
|
||||
public function generateSchemas()
|
||||
{
|
||||
if ($this->type == 'demo')
|
||||
$this->loader->setFixturesPath();
|
||||
|
||||
$tables = isset($_POST['tables']) ? (array)$_POST['tables'] : array();
|
||||
$columns = isset($_POST['columns']) ? (array)$_POST['columns'] : array();
|
||||
$relations = isset($_POST['relations']) ? (array)$_POST['relations'] : array();
|
||||
$ids = isset($_POST['id']) ? (array)$_POST['id'] : array();
|
||||
$primaries = isset($_POST['primary']) ? (array)$_POST['primary'] : array();
|
||||
$classes = isset($_POST['class']) ? (array)$_POST['class'] : array();
|
||||
$sqls = isset($_POST['sql']) ? (array)$_POST['sql'] : array();
|
||||
$orders = isset($_POST['order']) ? (array)$_POST['order'] : array();
|
||||
$images = isset($_POST['image']) ? (array)$_POST['image'] : array();
|
||||
$nulls = isset($_POST['null']) ? (array)$_POST['null'] : array();
|
||||
|
||||
$entities = array();
|
||||
foreach ($tables as $table)
|
||||
{
|
||||
$config = array();
|
||||
if (isset($ids[$table]) && $ids[$table])
|
||||
$config['id'] = $ids[$table];
|
||||
|
||||
if (isset($primaries[$table]) && $primaries[$table])
|
||||
$config['primary'] = $primaries[$table];
|
||||
|
||||
if (isset($classes[$table]) && $classes[$table])
|
||||
$config['class'] = $classes[$table];
|
||||
|
||||
if (isset($sqls[$table]) && $sqls[$table])
|
||||
$config['sql'] = $sqls[$table];
|
||||
|
||||
if (isset($orders[$table]) && $orders[$table])
|
||||
$config['ordersql'] = $orders[$table];
|
||||
|
||||
if (isset($images[$table]) && $images[$table])
|
||||
$config['image'] = $images[$table];
|
||||
|
||||
if (isset($nulls[$table]) && $nulls[$table])
|
||||
$config['null'] = $nulls[$table];
|
||||
|
||||
$fields = array();
|
||||
if (isset($columns[$table]))
|
||||
{
|
||||
foreach ($columns[$table] as $column)
|
||||
{
|
||||
$fields[$column] = array();
|
||||
if (isset($relations[$table][$column]['check']))
|
||||
$fields[$column]['relation'] = $relations[$table][$column];
|
||||
}
|
||||
}
|
||||
|
||||
$entities[$table] = array(
|
||||
'config' => $config,
|
||||
'fields' => $fields,
|
||||
);
|
||||
}
|
||||
|
||||
foreach ($entities as $entity => $info)
|
||||
$this->loader->generateEntitySchema($entity, $info['fields'], $info['config']);
|
||||
|
||||
$this->errors = $this->loader->getErrors();
|
||||
}
|
||||
|
||||
public function synchronizeEntities()
|
||||
{
|
||||
$entities = Tools::getValue('entities');
|
||||
if (isset($entities['common']))
|
||||
{
|
||||
$this->loader->setDefaultPath();
|
||||
$this->loader->generateEntityFiles($entities['common']);
|
||||
}
|
||||
|
||||
if (isset($entities['fixture']))
|
||||
{
|
||||
$this->loader->setFixturesPath();
|
||||
$this->loader->generateEntityFiles($entities['fixture']);
|
||||
}
|
||||
|
||||
$this->errors = $this->loader->getErrors();
|
||||
$this->loader->setDefaultPath();
|
||||
}
|
||||
}
|
||||
|
||||
new SynchronizeController('synchronize');
|
||||
Reference in New Issue
Block a user