[+] Install: new installer reworked from scratch
This commit is contained in:
@@ -0,0 +1,105 @@
|
||||
<?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)
|
||||
{
|
||||
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->synchronizeDatabase();
|
||||
|
||||
if ($this->type == 'demo')
|
||||
$this->loader->setFixturesPath();
|
||||
$this->displayTemplate('index');
|
||||
}
|
||||
|
||||
public function synchronizeDatabase()
|
||||
{
|
||||
if ($this->type == 'demo')
|
||||
{
|
||||
$this->loader->setDefaultPath();
|
||||
$this->loader->generateAllEntityFiles();
|
||||
$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();
|
||||
$images = isset($_POST['image']) ? (array)$_POST['image'] : 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($images[$table]) && $images[$table])
|
||||
$config['image'] = $images[$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,
|
||||
);
|
||||
}
|
||||
$this->loader->generateEntityFiles($entities);
|
||||
|
||||
if ($this->type != 'demo')
|
||||
{
|
||||
$this->loader->setFixturesPath();
|
||||
$this->loader->generateAllEntityFiles();
|
||||
$this->loader->setDefaultPath();
|
||||
}
|
||||
|
||||
$this->errors = $this->loader->getErrors();
|
||||
}
|
||||
}
|
||||
|
||||
new SynchronizeController('synchronize');
|
||||
@@ -0,0 +1,117 @@
|
||||
<html>
|
||||
<head>
|
||||
<title>The Synchronizator</title>
|
||||
<meta http-equiv="content-type" content="text/html; charset=UTF-8"/>
|
||||
<script type="text/javascript" src="../theme/js/jquery-1.4.4.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" media="all" href="style.css" />
|
||||
|
||||
<script type="text/javascript">
|
||||
$().ready(function()
|
||||
{
|
||||
$('.table_item .table_name').click(function()
|
||||
{
|
||||
var list = $(this).parent().find('.column_list');
|
||||
var check = $(this).parent().find('.table_item_checkbox');
|
||||
|
||||
if (list.css('display') == 'none')
|
||||
{
|
||||
list.show();
|
||||
check.attr('checked', true);
|
||||
}
|
||||
else
|
||||
{
|
||||
list.hide();
|
||||
check.attr('checked', false);
|
||||
}
|
||||
});
|
||||
|
||||
$('.table_item .table_item_checkbox').click(function()
|
||||
{
|
||||
var list = $(this).parent().find('.column_list');
|
||||
|
||||
if ($(this).attr('checked'))
|
||||
list.show();
|
||||
else
|
||||
list.hide();
|
||||
});
|
||||
});
|
||||
</script>
|
||||
</head>
|
||||
<body>
|
||||
<?php if ($this->errors): ?>
|
||||
<ul>
|
||||
<?php foreach ($this->errors as $error): ?>
|
||||
<li><?php echo $error ?></li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
<?php endif; ?>
|
||||
|
||||
<ul>
|
||||
<li><a href="index.php">Exporter les données</a></li>
|
||||
<li><a href="index.php?type=demo">Exporter les produits de démo</a></li>
|
||||
</ul>
|
||||
|
||||
<form action="" method="post">
|
||||
<ul class="table_list">
|
||||
<?php foreach ($this->loader->getTables() as $entity => $is_multilang): ?>
|
||||
<?php $entity_info = $this->loader->getEntityInfo($entity); ?>
|
||||
<li class="table_item" id="entity_<?php echo $entity ?>">
|
||||
<input type="checkbox" class="table_item_checkbox" name="tables[]" value="<?php echo $entity ?>" <?php if ($this->loader->entityExists($entity)): ?>checked="checked"<?php endif; ?> />
|
||||
<a href="#" onclick="return false" class="table_name"><?php echo $entity ?></a>
|
||||
<ul class="column_list" <?php if (!$this->loader->entityExists($entity)): ?>style="display: none"<?php endif; ?>>
|
||||
<li>
|
||||
Nom de l'ID
|
||||
<select name="id[<?php echo $entity ?>]">
|
||||
<option value="0">Normal (node_xx)</option>
|
||||
<?php foreach (array_merge($this->loader->getColumns($entity), $this->loader->getColumns($entity, true)) as $column => $is_text): ?>
|
||||
<option value="<?php echo $column ?>" <?php if (isset($entity_info['config']['id']) && $entity_info['config']['id'] == $column): ?>selected="selected"<?php endif; ?>>
|
||||
<?php echo $column ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
|
||||
Clef primaire
|
||||
<input type="text" name="primary[<?php echo $entity ?>]" value="<?php echo (isset($entity_info['config']['primary'])) ? $entity_info['config']['primary'] : '' ?>" />
|
||||
|
||||
Classe
|
||||
<select name="class[<?php echo $entity ?>]">
|
||||
<option value=""></option>
|
||||
<?php foreach ($this->loader->getClasses() as $class): ?>
|
||||
<option value="<?php echo $class ?>" <?php if (isset($entity_info['config']['class']) && $entity_info['config']['class'] == $class): ?>selected="selected"<?php endif; ?>><?php echo $class ?></option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
<br />
|
||||
Restriction SQL (WHERE ...)
|
||||
<input type="text" name="sql[<?php echo $entity ?>]" value="<?php echo (isset($entity_info['config']['sql'])) ? $entity_info['config']['sql'] : '' ?>" />
|
||||
<br />
|
||||
Dossier des images
|
||||
<input type="text" name="image[<?php echo $entity ?>]" value="<?php echo (isset($entity_info['config']['image'])) ? $entity_info['config']['image'] : '' ?>" />
|
||||
</li>
|
||||
<?php foreach ($this->loader->getColumns($entity) as $column => $is_text): ?>
|
||||
<li class="table_item_column" id="table_column_<?php echo $entity?>_<?php echo $column ?>">
|
||||
<label class="column_left">
|
||||
<input type="checkbox" name="columns[<?php echo $entity ?>][]" value="<?php echo $column ?>" <?php if (isset($entity_info['fields'][$column])): ?>checked="checked"<?php endif; ?> />
|
||||
<?php echo $column ?>
|
||||
</label>
|
||||
<div>
|
||||
Relation avec l'entité
|
||||
<select name="relations[<?php echo $entity ?>][<?php echo $column ?>]">
|
||||
<option value=""></option>
|
||||
<?php foreach ($this->loader->getTables() as $subentity => $bar): ?>
|
||||
<option value="<?php echo $subentity ?>" <?php if (isset($entity_info['fields'][$column]['relation']) && $entity_info['fields'][$column]['relation'] == $subentity): ?>selected="selected"<?php endif; ?>>
|
||||
<?php echo $subentity ?>
|
||||
</option>
|
||||
<?php endforeach; ?>
|
||||
</select>
|
||||
</div>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
</li>
|
||||
<?php endforeach; ?>
|
||||
</ul>
|
||||
|
||||
<input type="submit" name="submit" value="Enregistrer" />
|
||||
</form>
|
||||
</body>
|
||||
</html>
|
||||
@@ -0,0 +1,8 @@
|
||||
.clear{
|
||||
clear: both;
|
||||
}
|
||||
|
||||
.column_left{
|
||||
float: left;
|
||||
width: 250px;
|
||||
}
|
||||
Reference in New Issue
Block a user