add configurable debug mode, exports do execute SELECT queries only
This commit is contained in:
parent
c7bf1017d4
commit
602cdf43ee
@ -16,19 +16,10 @@
|
|||||||
namespace D3\DataWizard\Application\Controller\Admin;
|
namespace D3\DataWizard\Application\Controller\Admin;
|
||||||
|
|
||||||
use D3\DataWizard\Application\Model\Configuration;
|
use D3\DataWizard\Application\Model\Configuration;
|
||||||
use D3\DataWizard\Application\Model\Exports\activeArticlesInactiveCategory;
|
use Doctrine\DBAL\DBALException;
|
||||||
use D3\DataWizard\Application\Model\Exports\articlesWithoutManufacturers;
|
|
||||||
use D3\DataWizard\Application\Model\Exports\emptyCategories;
|
|
||||||
use D3\DataWizard\Application\Model\Exports\gappedArticleImages;
|
|
||||||
use D3\DataWizard\Application\Model\Exports\inactiveCategories;
|
|
||||||
use D3\DataWizard\Application\Model\Exports\inactiveParentCategory;
|
|
||||||
use D3\DataWizard\Application\Model\Exports\noArticleTextSet;
|
|
||||||
use D3\DataWizard\Application\Model\Exports\unreleasedRatings;
|
|
||||||
use D3\DataWizard\Application\Model\Exports\wrongArticlePrice;
|
|
||||||
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
|
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
|
||||||
use OxidEsales\Eshop\Core\Exception\StandardException;
|
use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||||
use OxidEsales\Eshop\Core\Registry;
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
use OxidEsales\Eshop\Core\UtilsView;
|
|
||||||
|
|
||||||
class d3ExportWizard extends AdminDetailsController
|
class d3ExportWizard extends AdminDetailsController
|
||||||
{
|
{
|
||||||
@ -54,16 +45,31 @@ class d3ExportWizard extends AdminDetailsController
|
|||||||
return $this->configuration->getExportsByGroup($group);
|
return $this->configuration->getExportsByGroup($group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @throws DBALException
|
||||||
|
*/
|
||||||
public function doExport()
|
public function doExport()
|
||||||
{
|
{
|
||||||
$id = Registry::getRequest()->getRequestEscapedParameter('exportid');
|
try {
|
||||||
$this->configuration->getExportById($id)->run();
|
$id = Registry::getRequest()->getRequestEscapedParameter('exportid');
|
||||||
|
$export = $this->configuration->getExportById($id);
|
||||||
|
|
||||||
$oEx = oxNew(
|
if (Registry::getConfig()->getConfigParam('d3datawizard_debug')) {
|
||||||
StandardException::class,
|
throw oxNew(
|
||||||
Registry::getLang()->translateString('D3_DATAWIZARD_ERR_NOEXPORTCONTENT')
|
StandardException::class,
|
||||||
);
|
$export->getQuery()
|
||||||
Registry::get(UtilsView::class)->addErrorToDisplay($oEx);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
$export->run();
|
||||||
|
|
||||||
|
throw oxNew(
|
||||||
|
StandardException::class,
|
||||||
|
Registry::getLang()->translateString('D3_DATAWIZARD_ERR_NOEXPORTCONTENT')
|
||||||
|
);
|
||||||
|
} catch (StandardException $e) {
|
||||||
|
Registry::getUtilsView()->addErrorToDisplay($e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public function getUserMessages()
|
public function getUserMessages()
|
||||||
|
@ -16,11 +16,36 @@
|
|||||||
namespace D3\DataWizard\Application\Model;
|
namespace D3\DataWizard\Application\Model;
|
||||||
|
|
||||||
use D3\ModCfg\Application\Model\d3database;
|
use D3\ModCfg\Application\Model\d3database;
|
||||||
|
use D3\ModCfg\Application\Model\Exception\d3_cfg_mod_exception;
|
||||||
|
use D3\ModCfg\Application\Model\Exception\d3ShopCompatibilityAdapterException;
|
||||||
|
use Doctrine\DBAL\DBALException;
|
||||||
|
use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException;
|
||||||
|
use OxidEsales\Eshop\Core\Exception\DatabaseErrorException;
|
||||||
|
use OxidEsales\Eshop\Core\Exception\StandardException;
|
||||||
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
|
|
||||||
abstract class ExportBase implements QueryBase
|
abstract class ExportBase implements QueryBase
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @throws StandardException
|
||||||
|
* @throws d3ShopCompatibilityAdapterException
|
||||||
|
* @throws d3_cfg_mod_exception
|
||||||
|
* @throws DBALException
|
||||||
|
* @throws DatabaseConnectionException
|
||||||
|
* @throws DatabaseErrorException
|
||||||
|
*/
|
||||||
public function run()
|
public function run()
|
||||||
{
|
{
|
||||||
|
$query = trim($this->getQuery());
|
||||||
|
|
||||||
|
if (strtolower(substr($query, 0, 6)) !== 'select') {
|
||||||
|
/** @var StandardException $e */
|
||||||
|
throw oxNew(
|
||||||
|
StandardException::class,
|
||||||
|
$this->getTitle().' - '.Registry::getLang()->translateString('D3_DATAWIZARD_EXPORT_NOSELECT')
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
d3database::getInstance()->downloadExportCsvByQuery($this->getExportFilename(), $this->getQuery());
|
d3database::getInstance()->downloadExportCsvByQuery($this->getExportFilename(), $this->getQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -26,6 +26,9 @@ $aLang = array(
|
|||||||
'd3mxDataWizard' => '<i class="fa fa-fw fas-hat-wizard"></i> Data Wizard',
|
'd3mxDataWizard' => '<i class="fa fa-fw fas-hat-wizard"></i> Data Wizard',
|
||||||
'd3mxDataWizard_Export' => 'Exporte',
|
'd3mxDataWizard_Export' => 'Exporte',
|
||||||
|
|
||||||
|
'SHOP_MODULE_GROUP_d3datawizard_general' => 'Grundeinstellungen',
|
||||||
|
'SHOP_MODULE_d3datawizard_debug' => 'zeigt Abfragen anstatt diese auszuführen',
|
||||||
|
|
||||||
'D3_DATAWIZARD_GROUP_ARTICLES' => 'Artikel',
|
'D3_DATAWIZARD_GROUP_ARTICLES' => 'Artikel',
|
||||||
'D3_DATAWIZARD_GROUP_CATEGORIES' => 'Kategorien',
|
'D3_DATAWIZARD_GROUP_CATEGORIES' => 'Kategorien',
|
||||||
'D3_DATAWIZARD_GROUP_REMARKS' => 'Bewertungen',
|
'D3_DATAWIZARD_GROUP_REMARKS' => 'Bewertungen',
|
||||||
@ -34,6 +37,8 @@ $aLang = array(
|
|||||||
|
|
||||||
'D3_DATAWIZARD_EXPORT_SUBMIT' => 'Export starten',
|
'D3_DATAWIZARD_EXPORT_SUBMIT' => 'Export starten',
|
||||||
|
|
||||||
|
'D3_DATAWIZARD_EXPORT_NOSELECT' => 'Export kann nicht ausgeführt werden. Exporte erfordern SELECT Query.',
|
||||||
|
|
||||||
'D3_DATAWIZARD_ERR_NOEXPORT_INSTALLED' => 'Es sind keine Exporte installiert oder aktiviert.',
|
'D3_DATAWIZARD_ERR_NOEXPORT_INSTALLED' => 'Es sind keine Exporte installiert oder aktiviert.',
|
||||||
'D3_DATAWIZARD_ERR_NOEXPORTCONTENT' => 'Export ist leer, kein Inhalt zum Download verfügbar'
|
'D3_DATAWIZARD_ERR_NOEXPORTCONTENT' => 'Export ist leer, kein Inhalt zum Download verfügbar'
|
||||||
|
|
||||||
|
@ -17,12 +17,15 @@
|
|||||||
*/
|
*/
|
||||||
$sMetadataVersion = '2.1';
|
$sMetadataVersion = '2.1';
|
||||||
|
|
||||||
|
$sModuleId = 'd3datawizard';
|
||||||
|
$logo = '<img src="https://logos.oxidmodule.com/d3logo.svg" alt="(D3)" style="height:1em;width:1em">';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Module information
|
* Module information
|
||||||
*/
|
*/
|
||||||
$aModule = [
|
$aModule = [
|
||||||
'id' => 'd3datawizard',
|
'id' => $sModuleId,
|
||||||
'title' => '<img src="https://logos.oxidmodule.com/d3logo.svg" alt="(D3)" style="height:1em;width:1em"> Data Wizard framework',
|
'title' => $logo.' Data Wizard framework',
|
||||||
'description' => [
|
'description' => [
|
||||||
'de' => '',
|
'de' => '',
|
||||||
'en' => '',
|
'en' => '',
|
||||||
@ -40,5 +43,13 @@ $aModule = [
|
|||||||
'templates' => [
|
'templates' => [
|
||||||
'd3ExportWizard.tpl' => 'd3/datawizard/Application/views/admin/tpl/d3ExportWizard.tpl',
|
'd3ExportWizard.tpl' => 'd3/datawizard/Application/views/admin/tpl/d3ExportWizard.tpl',
|
||||||
],
|
],
|
||||||
|
'settings' => [
|
||||||
|
[
|
||||||
|
'group' => $sModuleId.'_general',
|
||||||
|
'name' => $sModuleId.'_debug',
|
||||||
|
'type' => 'bool',
|
||||||
|
'value' => false
|
||||||
|
],
|
||||||
|
],
|
||||||
'blocks' => []
|
'blocks' => []
|
||||||
];
|
];
|
||||||
|
Loading…
x
Reference in New Issue
Block a user