Element import: lot of improvements

parent 15abc316
...@@ -34,12 +34,12 @@ ...@@ -34,12 +34,12 @@
.bs-callout-warning { border-left-color: #f39c12; } .bs-callout-warning { border-left-color: #f39c12; }
.btn i { margin-right: 6px; } .btn i { margin-right: 6px; }
.btn i + i { margin-left: -4px; } .btn i + i { margin-left: -4px; }
.markItUpHeader ul li { .markItUpHeader ul li {
padding-right: 5px; padding-right: 5px;
padding-bottom: 5px; padding-bottom: 5px;
} }
.markItUpHeader ul .markItUpSeparator .markItUpHeader ul .markItUpSeparator
{ {
...@@ -47,17 +47,17 @@ ...@@ -47,17 +47,17 @@
color: transparent; color: transparent;
border-right: 1px solid #b9b9b9; border-right: 1px solid #b9b9b9;
margin: 0 15px 0 5px; margin: 0 15px 0 5px;
} }
.markItUpEditor { .markItUpEditor {
font-size: 15px; font-size: 15px;
padding: 10px; padding: 10px;
font-family: 'Source Sans Pro','Helvetica Neue',Helvetica,Arial,sans-serif; font-family: 'Source Sans Pro','Helvetica Neue',Helvetica,Arial,sans-serif;
} }
.markItUpButton4, .markItUpButton5, .markItUpButton6, .markItUpButton12 + .markItUpSeparator, .markItUpButton13, .markItUpButton14 { display: none; } .markItUpButton4, .markItUpButton5, .markItUpButton6, .markItUpButton12 + .markItUpSeparator, .markItUpButton13, .markItUpButton14 { display: none; }
.box-body > .alert:last-child { margin-bottom: 0 } .box-body > .alert:last-child { margin-bottom: 0 }
label[title]:hover { label[title]:hover {
cursor: help; cursor: help;
...@@ -69,7 +69,7 @@ ...@@ -69,7 +69,7 @@
margin-left: 5px; margin-left: 5px;
} }
.box-body .iframe-container { text-align: center; margin-top: -20px; } .box-body .iframe-container { text-align: center; margin-top: -20px; }
.box-body .iframe-container-aside { .box-body .iframe-container-aside {
float: left; float: left;
margin: -20px 20px 20px 0; margin: -20px 20px 20px 0;
} }
...@@ -80,14 +80,19 @@ ...@@ -80,14 +80,19 @@
.main-header .logo { width: auto; } .main-header .logo { width: auto; }
.main-header .logo label:hover { cursor: pointer; } .main-header .logo label:hover { cursor: pointer; }
.main-header .navbar { flex: auto; margin-left: 0; } .main-header .navbar { flex: auto; margin-left: 0; }
pre {
font-size: 11px;
line-height: 13px;
}
</style> </style>
{% endblock %} {% endblock %}
{% block javascripts %} {% block javascripts %}
{{ parent() }} {{ parent() }}
{# CKEDITOR FORMATTER #} {# CKEDITOR FORMATTER #}
<script src="//cdn.ckeditor.com/4.7.3/full/ckeditor.js"></script> <script src="//cdn.ckeditor.com/4.7.3/full/ckeditor.js"></script>
...@@ -95,7 +100,7 @@ ...@@ -95,7 +100,7 @@
<script src="{{ asset('bundles/sonataformatter/markitup/sets/markdown/set.js') }}" type="text/javascript"></script> <script src="{{ asset('bundles/sonataformatter/markitup/sets/markdown/set.js') }}" type="text/javascript"></script>
<script src="{{ asset('bundles/sonataformatter/markitup/sets/html/set.js') }}" type="text/javascript"></script> <script src="{{ asset('bundles/sonataformatter/markitup/sets/html/set.js') }}" type="text/javascript"></script>
<script src="{{ asset('bundles/sonataformatter/markitup/sets/textile/set.js') }}" type="text/javascript"></script> <script src="{{ asset('bundles/sonataformatter/markitup/sets/textile/set.js') }}" type="text/javascript"></script>
<script> <script>
// bootstrap-ckeditor-modal-fix.js // bootstrap-ckeditor-modal-fix.js
// hack to fix ckeditor/bootstrap compatiability bug when ckeditor appears in a bootstrap modal dialog // hack to fix ckeditor/bootstrap compatiability bug when ckeditor appears in a bootstrap modal dialog
...@@ -105,13 +110,13 @@ ...@@ -105,13 +110,13 @@
modal_this = this; modal_this = this;
console.log("enforce focus"); console.log("enforce focus");
$(document).on('focusin.modal', function (e) { $(document).on('focusin.modal', function (e) {
if (modal_this.$element[0] !== e.target && !modal_this.$element.has(e.target).length if (modal_this.$element[0] !== e.target && !modal_this.$element.has(e.target).length
&& !$(e.target.parentNode).hasClass('cke_dialog_ui_input_select') && !$(e.target.parentNode).hasClass('cke_dialog_ui_input_select')
&& !$(e.target.parentNode).hasClass('cke_dialog_ui_input_text')) { && !$(e.target.parentNode).hasClass('cke_dialog_ui_input_text')) {
modal_this.$element.focus() modal_this.$element.focus()
} }
}) })
}; };
// CONFIGURATION ADMIN, disable the whole feature box according to checkbox "feature active" // CONFIGURATION ADMIN, disable the whole feature box according to checkbox "feature active"
$(document).ready(function() { $(document).ready(function() {
...@@ -121,7 +126,7 @@ ...@@ -121,7 +126,7 @@
$('.gogo-feature').each(function() { $('.gogo-feature').each(function() {
checkGoGoFeatureActivated(this); checkGoGoFeatureActivated(this);
}); });
$('.gogo-feature .sonata-ba-field.sonata-ba-field-inline-natural > .form-group:first-child .icheckbox_square-blue .iCheck-helper').click(function() { $('.gogo-feature .sonata-ba-field.sonata-ba-field-inline-natural > .form-group:first-child .icheckbox_square-blue .iCheck-helper').click(function() {
var that = this; var that = this;
setTimeout(function() { checkGoGoFeatureActivated($(that).closest('.gogo-feature'));  }, 10); setTimeout(function() { checkGoGoFeatureActivated($(that).closest('.gogo-feature'));  }, 10);
}); });
...@@ -133,13 +138,13 @@ ...@@ -133,13 +138,13 @@
$('.collaborative-moderation-box').css('opacity', opacity); $('.collaborative-moderation-box').css('opacity', opacity);
} }
function checkGoGoFeatureActivated(object) { function checkGoGoFeatureActivated(object) {
console.log("feature", object); console.log("feature", object);
var featureActive = $(object).find('.sonata-ba-field.sonata-ba-field-inline-natural > .form-group:first-child .icheckbox_square-blue').hasClass('checked'); var featureActive = $(object).find('.sonata-ba-field.sonata-ba-field-inline-natural > .form-group:first-child .icheckbox_square-blue').hasClass('checked');
var opacity = featureActive ? '1' : '0.5'; var opacity = featureActive ? '1' : '0.5';
$(object).css('opacity', opacity); $(object).css('opacity', opacity);
} }
// Helpers // Helpers
var formBuilder; var formBuilder;
var formBuilderInitialized = false; var formBuilderInitialized = false;
...@@ -168,7 +173,7 @@ ...@@ -168,7 +173,7 @@
{{ newErrorsCount }} {{ newErrorsCount == 1 ? 'erreur' : 'erreurs' }} {{ newErrorsCount }} {{ newErrorsCount == 1 ? 'erreur' : 'erreurs' }}
</label> </label>
{% endif %} {% endif %}
</a> </a>
{% endspaceless %} {% endspaceless %}
{% endblock %} {% endblock %}
...@@ -185,19 +190,19 @@ ...@@ -185,19 +190,19 @@
<li><a href={{ path('biopen_element_add') }} target='_blank'>Formulaire</a></li> <li><a href={{ path('biopen_element_add') }} target='_blank'>Formulaire</a></li>
<li><a href={{ path('biopen_partners') }} target='_blank'>Qui sommes nous</a></li> <li><a href={{ path('biopen_partners') }} target='_blank'>Qui sommes nous</a></li>
</ul> </ul>
</div> </div>
{% endblock %} {% endblock %}
{% block side_bar_after_nav %} {% block side_bar_after_nav %}
{# CUSTOM Menu #} {# CUSTOM Menu #}
<ul class="sidebar-menu"> <ul class="sidebar-menu">
<li class="first treeview"> <li class="first treeview">
<a href="{{ path('biopen_bulk_actions_index') }}"><i class="fa fa-bullhorn"></i><span>Actions de masse</span></a> <a href="{{ path('biopen_bulk_actions_index') }}"><i class="fa fa-bullhorn"></i><span>Actions de masse</span></a>
</li> </li>
<li> <li>
<a href="{{ path('biopen_core_help') }}"><i class="fa fa-question"></i><span>Aide</span></a> <a href="{{ path('biopen_core_help') }}"><i class="fa fa-question"></i><span>Aide</span></a>
</li> </li>
{% if use_as_saas %} {% if use_as_saas %}
<li> <li>
{% if is_root_project() %} {% if is_root_project() %}
<a href="{{ path('admin_biopen_saas_project_list') }}"><i class="fa fa-folder-open"></i><span>Projets</span></a> <a href="{{ path('admin_biopen_saas_project_list') }}"><i class="fa fa-folder-open"></i><span>Projets</span></a>
......
...@@ -14,8 +14,8 @@ class ImportDynamicAdminController extends Controller ...@@ -14,8 +14,8 @@ class ImportDynamicAdminController extends Controller
$object = $this->admin->getSubject(); $object = $this->admin->getSubject();
$result = $this->get('biopen.element_import')->collectData($object); $result = $this->get('biopen.element_import')->collectData($object);
$this->addFlash('sonata_flash_success', "Les données ont été chargées avec succès. Vous pouvez maintenant compléter les tables de correspondances, puis importer les données."); $this->addFlash('sonata_flash_success', "Les données ont été chargées avec succès.</br>Voici le résultat obtenu pour le premier élément à importer :<pre>" . print_r($result, true) . '</pre>');
$url = $this->admin->generateUrl('edit', ['id' => $object->getId()]) . "#tab_3"; $url = $this->admin->generateUrl('edit', ['id' => $object->getId()]);
return $this->redirect($url); return $this->redirect($url);
} }
...@@ -89,8 +89,16 @@ class ImportDynamicAdminController extends Controller ...@@ -89,8 +89,16 @@ class ImportDynamicAdminController extends Controller
'SonataAdminBundle' 'SonataAdminBundle'
) )
); );
// redirect to edit mode
return $this->redirectTo($object); if ($request->get('collect')) {
$url = $this->admin->generateUrl('collect', ['id' => $object->getId()]);
} else if ($request->get('import')) {
$url = $this->admin->generateUrl('refresh', ['id' => $object->getId()]);
} else {
$url = $this->admin->generateUrl('edit', ['id' => $object->getId()]);
}
return $this->redirect($url);
} catch (ModelManagerException $e) { } catch (ModelManagerException $e) {
$this->handleModelManagerException($e); $this->handleModelManagerException($e);
$isFormValid = false; $isFormValid = false;
......
...@@ -39,7 +39,7 @@ class OptionValue ...@@ -39,7 +39,7 @@ class OptionValue
{ {
$result = "{"; $result = "{";
$result .= '"id":' . $this->optionId ; $result .= '"id":' . $this->optionId ;
if ($optionName) $result .= ', "name":' . $optionName; if ($optionName) $result .= ', "name":' . json_encode($optionName);
$result .=', "description":' . json_encode($this->description); $result .=', "description":' . json_encode($this->description);
$result .=', "index":' . $this->index; $result .=', "index":' . $this->index;
$result .= "}"; $result .= "}";
......
...@@ -74,17 +74,6 @@ class ElementJsonGenerator ...@@ -74,17 +74,6 @@ class ElementJsonGenerator
// OPTIONS VALUES (= TAXONOMY) // OPTIONS VALUES (= TAXONOMY)
$sortedOptionsValues = $element->getSortedOptionsValues(); $sortedOptionsValues = $element->getSortedOptionsValues();
$optValuesLength = count($sortedOptionsValues); $optValuesLength = count($sortedOptionsValues);
// Options values ids
$baseJson .= ', "categoriesIds": [';
if ($sortedOptionsValues)
{
for ($i=0; $i < $optValuesLength; $i++) {
$baseJson .= $sortedOptionsValues[$i]->getOptionId() . ',';
}
}
$baseJson = rtrim($baseJson, ',');
$baseJson .= '],';
// option values names
$optionsString = ''; $optionsString = '';
$optionsFullJson = []; $optionsFullJson = [];
if ($sortedOptionsValues) if ($sortedOptionsValues)
...@@ -97,7 +86,7 @@ class ElementJsonGenerator ...@@ -97,7 +86,7 @@ class ElementJsonGenerator
} }
} }
$optionsString = rtrim($optionsString, ','); $optionsString = rtrim($optionsString, ',');
$baseJson .= '"categories": [' . $optionsString . '],'; $baseJson .= ',"categories": [' . $optionsString . '],';
$element->setOptionsString($optionsString); // we also update optionsString attribute which is used in exporting from element admin list $element->setOptionsString($optionsString); // we also update optionsString attribute which is used in exporting from element admin list
// Options values with description // Options values with description
if (count($optionsFullJson)) $baseJson .= '"categoriesFull": [' . implode(",", $optionsFullJson) . '],'; if (count($optionsFullJson)) $baseJson .= '"categoriesFull": [' . implode(",", $optionsFullJson) . '],';
......
...@@ -12,14 +12,16 @@ ...@@ -12,14 +12,16 @@
<th>Attribut d'origine</th> <th>Attribut d'origine</th>
<th style="width:20px"></th> <th style="width:20px"></th>
<th>à transformer en</th> <th>à transformer en</th>
<th style="width:20px"></th>
</tr> </tr>
</thead> </thead>
<tbody class="table-striped"> <tbody class="table-striped">
{% for originName, mappedName in mapping %} {% for originName, mappedName in mapping %}
<tr> <tr>
<td class="original">{{originName}}</td> <td class="original">{{originName}}</td>
<td><i class="arrow-icon fa fa-arrow-circle-right"></i></td> <td><i class="arrow-icon fa fa-arrow-circle-right" title="Utiliser le nom d'origine"></i></td>
<td class="mapped"><input type="text" name="ontology[{{originName}}]" class="form-control property-selector" value={{mappedName}} /></td> <td class="mapped"><input type="text" name="ontology[{{originName}}]" class="form-control property-selector" value={{mappedName}} /></td>
<td><i class="clear-icon fa fa-ban" title="Ne pas importer ce champ"></i></td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
...@@ -29,7 +31,7 @@ ...@@ -29,7 +31,7 @@
<style> <style>
.arrow-icon { font-size: 18px; } .arrow-icon { font-size: 18px; }
.arrow-icon:hover { cursor: pointer; } .arrow-icon:hover, .clear-icon:hover { cursor: pointer; }
td { vertical-align: middle !important; } td { vertical-align: middle !important; }
</style> </style>
...@@ -40,13 +42,18 @@ ...@@ -40,13 +42,18 @@
$(this).parent().parent().find('.property-selector:not(.select2-container)').val($(this).parent().siblings('.original').text()).trigger('change'); $(this).parent().parent().find('.property-selector:not(.select2-container)').val($(this).parent().siblings('.original').text()).trigger('change');
}); });
var formProperties = JSON.parse('{{ form.vars.attr["data-form-props"]|raw }}'); $('.clear-icon').click(function() {
var dataProperties = JSON.parse('{{ form.vars.attr["data-props"]|raw }}'); $(this).parent().parent().find('.property-selector:not(.select2-container)').val("/").trigger('change');
});
var formProperties = {{ form.vars.attr["data-form-props"]|raw }};
var dataProperties = {{ form.vars.attr["data-props"]|raw }};
var coreFields = ['id', 'name', 'categories', 'streetAddress', 'addressLocality', 'postalCode', 'addressCountry', 'latitude', 'longitude', 'images', 'owner', 'source'] var coreFields = ['id', 'name', 'categories', 'streetAddress', 'addressLocality', 'postalCode', 'addressCountry', 'latitude', 'longitude', 'images', 'owner', 'source']
var formData = [], allProperties = [], otherData = []; var importedData = []; var formData = [], allProperties = [], otherData = []; var importedData = [];
formData.push({id: 'id', text: 'Identifiant unique'}); formData.push({id: 'id', text: 'Identifiant unique'});
formData.push({id: 'name', text: 'Titre de la fiche'}); formData.push({id: 'name', text: 'Titre de la fiche'});
formData.push({id: 'categories', text: 'Liste des catégories (en tableau ou séparées par des virgules)'}); formData.push({id: 'categories', text: 'Liste des catégories (en tableau ou séparées par des virgules)'});
formData.push({id: 'streetNumber', text: 'Adresse: numéro de rue'});
formData.push({id: 'streetAddress', text: 'Adresse: rue'}); formData.push({id: 'streetAddress', text: 'Adresse: rue'});
formData.push({id: 'addressLocality', text: 'Adresse: ville'}); formData.push({id: 'addressLocality', text: 'Adresse: ville'});
formData.push({id: 'postalCode', text: 'Adresse: code postal'}); formData.push({id: 'postalCode', text: 'Adresse: code postal'});
......
...@@ -9,14 +9,16 @@ ...@@ -9,14 +9,16 @@
<th>Catégories lues depuis le fichier d'origine</th> <th>Catégories lues depuis le fichier d'origine</th>
<th style="width:20px"></th> <th style="width:20px"></th>
<th>Catégories du site</th> <th>Catégories du site</th>
<th style="width:20px"></th>
</tr> </tr>
</thead> </thead>
<tbody class="table-striped"> <tbody class="table-striped">
{% for originName, mappedName in mapping %} {% for originName, mappedName in mapping %}
<tr> <tr>
<td class="original">{{originName}}</td> <td class="original">{{originName}}</td>
<td><i class="fa fa-arrow-circle-right"></i></td> <td>></td>
<td class="mapped"><input type="text" name="taxonomy[{{originName}}]" class="form-control category-selector" value={{mappedName}} /></td> <td class="mapped"><input type="text" name="taxonomy[{{originName}}]" class="form-control category-selector" value={{mappedName}} /></td>
<td><i class="clear-icon fa fa-ban" title="Ne pas utiliser cette catégorie"></i></td>
</tr> </tr>
{% endfor %} {% endfor %}
</tbody> </tbody>
...@@ -30,8 +32,8 @@ ...@@ -30,8 +32,8 @@
<script> <script>
jQuery(document).ready(function() { jQuery(document).ready(function() {
var optionsList = JSON.parse('{{ form.vars.attr["data-options"]|raw }}'); var optionsList = {{ form.vars.attr["data-options"]|raw }};
var formData = [] var formData = [{ id: "", text: ""}]
for(var key in optionsList) { for(var key in optionsList) {
var option = optionsList[key]; var option = optionsList[key];
...@@ -42,5 +44,9 @@ ...@@ -42,5 +44,9 @@
data: formData data: formData
}); });
$('.clear-icon').click(function() {
$(this).parent().parent().find('.category-selector:not(.select2-container)').val("").trigger('change');
});
}); });
</script> </script>
\ No newline at end of file
...@@ -8,16 +8,19 @@ ...@@ -8,16 +8,19 @@
<p>Dernière mise à jour : {{ object.lastRefresh|date('d/m/Y') }}</p> <p>Dernière mise à jour : {{ object.lastRefresh|date('d/m/Y') }}</p>
{% endif %} {% endif %}
<button type="submit" class="btn btn-success" name="submit"><i class="fa fa-save" aria-hidden="true"></i>Sauvegarder</button> <button type="submit" class="btn btn-success" name="submit"><i class="fa fa-save" aria-hidden="true"></i>Sauvegarder</button>
{% include '@BiopenAdmin/partials/list__action_refresh.html.twig' with {'class': 'btn-primary'} %} {% if object.id != "" and object.ontologyMapping|length > 0 %}
<button type="submit" class="btn btn-primary" name="import" value="import">
<i class="fa fa-download" aria-hidden="true"></i>Importer les données
</button>
{% endif %}
{% set class = object.ontologyMapping|length > 0 ? 'btn-default' : 'btn-primary' %} {% set class = object.ontologyMapping|length > 0 ? 'btn-default' : 'btn-primary' %}
{% if object.id != "" %} {% if object.id != "" %}
<a href="{{ admin.generateObjectUrl('collect', object) }}" class="btn {{ class }} view_link" title="Met à jour les tables de correspondance sans réellement importer les données"> <button type="submit" class="btn btn-default" name="collect" value="collect" title="Met à jour les tables de correspondance sans réellement importer les données">
<i class="fa fa-eye" aria-hidden="true"></i> <i class="fa fa-eye" aria-hidden="true"></i>Lire les données
Lire les données </button>
</a>
{% endif %} {% endif %}
<a href="{{ admin.generateObjectUrl('list', object) }}" class="btn btn-default view_link"> <a href="{{ admin.generateObjectUrl('list', object) }}" class="btn btn-default view_link">
<i class="fa fa-list" aria-hidden="true"></i>Retour à la liste <i class="fa fa-list" aria-hidden="true"></i>Retour à la liste
...@@ -27,5 +30,6 @@ ...@@ -27,5 +30,6 @@
<i class="fa fa-trash" aria-hidden="true"></i>Supprimer (ainsi que tous les éléments importés) <i class="fa fa-trash" aria-hidden="true"></i>Supprimer (ainsi que tous les éléments importés)
</a> </a>
{% endif %} {% endif %}
{% endblock %} {% endblock %}
...@@ -51,49 +51,59 @@ class ElementImportMappingService ...@@ -51,49 +51,59 @@ class ElementImportMappingService
$parent = $import->getParentCategoryToCreateOptions() ?: $this->em->getRepository('BiopenGeoDirectoryBundle:Category')->findOneByIsRootCategory(true); $parent = $import->getParentCategoryToCreateOptions() ?: $this->em->getRepository('BiopenGeoDirectoryBundle:Category')->findOneByIsRootCategory(true);
$this->parentCategoryIdToCreateMissingOptions = $parent->getId(); $this->parentCategoryIdToCreateMissingOptions = $parent->getId();
// Execute custom code (the <?php is used to have proper code highliting in text editor, we remove it before executing)
eval(str_replace('<?php', '', $import->getCustomCode()));
// elements is ofently stored nested in a data attribute // elements is ofently stored nested in a data attribute
if (array_key_exists('data', $data)) $data = $data['data']; if (array_key_exists('data', $data)) $data = $data['data'];
// Fixs gogocarto ontology when importing // Fixs gogocarto ontology when importing, to simplify import/export from gogocarto to gogocarto
foreach ($data as $key => $row) { foreach ($data as $key => $row) {
if (array_key_exists('geo', $row)) if (is_array($row)) {
{ if (array_key_exists('geo', $row))
$data[$key]['latitude'] = $row['geo']['latitude']; {
$data[$key]['longitude'] = $row['geo']['longitude']; $data[$key]['latitude'] = $row['geo']['latitude'];
unset($data[$key]['geo']); $data[$key]['longitude'] = $row['geo']['longitude'];
} unset($data[$key]['geo']);
if (array_key_exists('address', $row)) }
{ if (array_key_exists('address', $row))
$address = $row['address']; {
$address = $row['address'];
if (gettype($address) == "string") $data[$key]['streetAddress'] = $address;
else if ($address) { if (gettype($address) == "string") $data[$key]['streetAddress'] = $address;
if (array_key_exists('streetAddress', $address)) $data[$key]['streetAddress'] = $address['streetAddress']; else if ($address) {
if (array_key_exists('addressLocality', $address)) $data[$key]['addressLocality'] = $address['addressLocality']; if (array_key_exists('streetNumber', $address)) $data[$key]['streetNumber'] = $address['streetNumber'];
if (array_key_exists('postalCode', $address)) $data[$key]['postalCode'] = $address['postalCode']; if (array_key_exists('streetAddress', $address)) $data[$key]['streetAddress'] = $address['streetAddress'];
if (array_key_exists('addressCountry', $address)) $data[$key]['addressCountry'] = $address['addressCountry']; if (array_key_exists('addressLocality', $address)) $data[$key]['addressLocality'] = $address['addressLocality'];
if (array_key_exists('postalCode', $address)) $data[$key]['postalCode'] = $address['postalCode'];
if (array_key_exists('addressCountry', $address)) $data[$key]['addressCountry'] = $address['addressCountry'];
}
unset($data[$key]['address']);
}
if (array_key_exists('categories', $row) && array_key_exists('categoriesFull', $row)) {
$data[$key]['categories'] = $data[$key]['categoriesFull'];
unset($data[$key]['categoriesFull']);
} }
unset($data[$key]['address']); } else {
// the $row is not an array, probably a string so we ignore it
unset($data[$key]);
} }
} }
// Execute custom code (the <?php is used to have proper code highliting in text editor, we remove it before executing) // Ontology
eval(str_replace('<?php', '', $import->getCustomCode()));
$this->collectOntology($data, $import); $this->collectOntology($data, $import);
$data = $this->mapOntology($data); $data = $this->mapOntology($data);
// remove empty row, i.e. without name // remove empty row, i.e. without name
$data = array_filter($data, function($row) { return array_key_exists('name', $row); }); $data = array_filter($data, function($row) { return array_key_exists('name', $row); });
// Taxonomy
if ($import->isCategoriesFieldMapped()) if ($import->isCategoriesFieldMapped())
{ {
$this->collectTaxonomy($data, $import); $this->collectTaxonomy($data, $import);
$data = $this->mapTaxonomy($data); $data = $this->mapTaxonomy($data);
} }
$data = $this->addMissingFieldsToData($data);
$this->em->persist($import); $this->em->persist($import);