improve code style
This commit is contained in:
parent
3a04e15579
commit
23cfaf0c32
@ -12,120 +12,120 @@ use OxidEsales\Eshop\Core\Registry;
|
||||
|
||||
class ManufacturerInfoLongdesc extends AdminDetailsController
|
||||
{
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
parent::render();
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function render()
|
||||
{
|
||||
parent::render();
|
||||
|
||||
$this->_aViewData['edit'] = $oManufacturer = oxNew(\OxidEsales\Eshop\Application\Model\Manufacturer::class);
|
||||
$this->_aViewData['edit'] = $oManufacturer = oxNew(\OxidEsales\Eshop\Application\Model\Manufacturer::class);
|
||||
|
||||
$sOXID = $this->_aViewData["oxid"] = $this->getEditObjectId();
|
||||
if (isset($sOXID) && $sOXID != "-1") {
|
||||
// load object
|
||||
$d3manufacturerlang = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("catlang");
|
||||
$sOXID = $this->_aViewData["oxid"] = $this->getEditObjectId();
|
||||
if (isset($sOXID) && $sOXID != "-1") {
|
||||
// load object
|
||||
$d3manufacturerlang = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("catlang");
|
||||
|
||||
if (!isset($d3manufacturerlang)) {
|
||||
$d3manufacturerlang = $this->_iEditLang;
|
||||
}
|
||||
if (!isset($d3manufacturerlang)) {
|
||||
$d3manufacturerlang = $this->_iEditLang;
|
||||
}
|
||||
|
||||
$this->_aViewData["catlang"] = $d3manufacturerlang;
|
||||
$this->_aViewData["catlang"] = $d3manufacturerlang;
|
||||
|
||||
$oManufacturer->loadInLang($d3manufacturerlang, $sOXID);
|
||||
$oManufacturer->loadInLang($d3manufacturerlang, $sOXID);
|
||||
|
||||
//Disable editing for derived items
|
||||
if ($oManufacturer->isDerived()) {
|
||||
$this->_aViewData['readonly'] = true;
|
||||
}
|
||||
//Disable editing for derived items
|
||||
if ($oManufacturer->isDerived()) {
|
||||
$this->_aViewData['readonly'] = true;
|
||||
}
|
||||
|
||||
foreach (\OxidEsales\Eshop\Core\Registry::getLang()->getLanguageNames() as $id => $language) {
|
||||
$oLang = new \stdClass();
|
||||
$oLang->sLangDesc = $language;
|
||||
$oLang->selected = ($id == $this->_iEditLang);
|
||||
$this->_aViewData["otherlang"][$id] = clone $oLang;
|
||||
}
|
||||
}
|
||||
foreach (\OxidEsales\Eshop\Core\Registry::getLang()->getLanguageNames() as $id => $language) {
|
||||
$oLang = new \stdClass();
|
||||
$oLang->sLangDesc = $language;
|
||||
$oLang->selected = ($id == $this->_iEditLang);
|
||||
$this->_aViewData["otherlang"][$id] = clone $oLang;
|
||||
}
|
||||
}
|
||||
|
||||
$this->_aViewData["editor"] = $this->generateTextEditor("100%", 280, $oManufacturer, "oxmanufacturers__d3description", "list.tpl.css");
|
||||
$this->_aViewData["editor"] = $this->generateTextEditor("100%", 280, $oManufacturer, "oxmanufacturers__d3description", "list.tpl.css");
|
||||
|
||||
return "d3manufacturerlongdesc.tpl";
|
||||
}
|
||||
return "d3manufacturerlongdesc.tpl";
|
||||
}
|
||||
|
||||
/**
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
parent::save();
|
||||
/**
|
||||
* @return void
|
||||
* @throws \Exception
|
||||
*/
|
||||
public function save()
|
||||
{
|
||||
parent::save();
|
||||
|
||||
$iManufacturerLang = intval(\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("catlang"));
|
||||
$sOXID = $this->getEditObjectId();
|
||||
$this->setEditObjectId($sOXID);
|
||||
$iManufacturerLang = intval(\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("catlang"));
|
||||
$sOXID = $this->getEditObjectId();
|
||||
$this->setEditObjectId($sOXID);
|
||||
|
||||
if ($sOXID == "-1") {
|
||||
return;
|
||||
}
|
||||
if ($sOXID == "-1") {
|
||||
return;
|
||||
}
|
||||
|
||||
/** @var Manufacturer|D3ManufacturerLongDesc $oManufacturer */
|
||||
$oManufacturer = oxNew(Manufacturer::class);
|
||||
$oManufacturer->loadInLang($iManufacturerLang, $sOXID);
|
||||
/** @var Manufacturer|D3ManufacturerLongDesc $oManufacturer */
|
||||
$oManufacturer = oxNew(Manufacturer::class);
|
||||
$oManufacturer->loadInLang($iManufacturerLang, $sOXID);
|
||||
|
||||
if (!$oManufacturer->load($sOXID)) {
|
||||
return;
|
||||
}
|
||||
if (!$oManufacturer->load($sOXID)) {
|
||||
return;
|
||||
}
|
||||
|
||||
$aParams = Registry::getRequest()->getRequestEscapedParameter("editval");
|
||||
$oManufacturer->assign($aParams);
|
||||
$aParams = Registry::getRequest()->getRequestEscapedParameter("editval");
|
||||
$oManufacturer->assign($aParams);
|
||||
|
||||
if (false === is_null($this->d3GetLongdescParamValue())) {
|
||||
$oManufacturer->d3SetLongdesc($this->d3GetLongdescParamValue());
|
||||
$oManufacturer->save();
|
||||
}
|
||||
}
|
||||
if (false === is_null($this->d3GetLongdescParamValue())) {
|
||||
$oManufacturer->d3SetLongdesc($this->d3GetLongdescParamValue());
|
||||
$oManufacturer->save();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns string which must be edited by editor
|
||||
*
|
||||
* @param \OxidEsales\Eshop\Core\Model\BaseModel $oObject object with field will be used for editing
|
||||
* @param string $sField name of editable field
|
||||
*
|
||||
* @return string
|
||||
* @deprecated underscore prefix violates PSR12, will be renamed to "getEditValue" in next major
|
||||
*/
|
||||
protected function _getEditValue($oManufacturer, $sField) // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
|
||||
{
|
||||
$sEditObjectValue = '';
|
||||
/**
|
||||
* Returns string which must be edited by editor
|
||||
*
|
||||
* @param \OxidEsales\Eshop\Core\Model\BaseModel $oObject object with field will be used for editing
|
||||
* @param string $sField name of editable field
|
||||
*
|
||||
* @return string
|
||||
* @deprecated underscore prefix violates PSR12, will be renamed to "getEditValue" in next major
|
||||
*/
|
||||
protected function _getEditValue($oManufacturer, $sField) // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
|
||||
{
|
||||
$sEditObjectValue = '';
|
||||
|
||||
if ($oManufacturer and $oManufacturer->getId()) {
|
||||
$sEditObjectValue = $this->_processEditValue($oManufacturer->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME));
|
||||
}
|
||||
if ($oManufacturer and $oManufacturer->getId()) {
|
||||
$sEditObjectValue = $this->_processEditValue($oManufacturer->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME));
|
||||
}
|
||||
|
||||
return $sEditObjectValue;
|
||||
}
|
||||
return $sEditObjectValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function d3GetLongdescParamValue() :string
|
||||
{
|
||||
return (string) $aParams = Registry::getRequest()->getRequestEscapedParameter("editval")['oxmanufacturers__d3description'];
|
||||
}
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function d3GetLongdescParamValue() :string
|
||||
{
|
||||
return (string) $aParams = Registry::getRequest()->getRequestEscapedParameter("editval")['oxmanufacturers__d3description'];
|
||||
}
|
||||
|
||||
/**
|
||||
* inhaltliche Uebernahme analog Article_Main
|
||||
* wird genutzt zum Abspeichern der Artikel-Langbeschreibung
|
||||
*
|
||||
* @param $sValue
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _processLongDesc($sValue)
|
||||
{
|
||||
$aSearch = ['&nbsp;', '&', '"', '&lang=', '<p> </p>', '<p> </p>'];
|
||||
$aReplace = [' ', '&', '"', '&lang=', '', ''];
|
||||
/**
|
||||
* inhaltliche Uebernahme analog Article_Main
|
||||
* wird genutzt zum Abspeichern der Artikel-Langbeschreibung
|
||||
*
|
||||
* @param $sValue
|
||||
*
|
||||
* @return mixed
|
||||
*/
|
||||
protected function _processLongDesc($sValue)
|
||||
{
|
||||
$aSearch = ['&nbsp;', '&', '"', '&lang=', '<p> </p>', '<p> </p>'];
|
||||
$aReplace = [' ', '&', '"', '&lang=', '', ''];
|
||||
|
||||
return str_replace($aSearch, $aReplace, $sValue);
|
||||
}
|
||||
return str_replace($aSearch, $aReplace, $sValue);
|
||||
}
|
||||
}
|
@ -7,8 +7,8 @@ namespace D3\ManufacturerInformation\Application\Model;
|
||||
|
||||
class Constants
|
||||
{
|
||||
public const OXID_MODULE_ID = 'd3manufacturerinformation';
|
||||
public const OXID_MODULE_ID = 'd3manufacturerinformation';
|
||||
|
||||
// Tables and Database
|
||||
public const D3_OXMANUFACTURERS_LONGDESC_FIELDNAME = 'd3description';
|
||||
// Tables and Database
|
||||
public const D3_OXMANUFACTURERS_LONGDESC_FIELDNAME = 'd3description';
|
||||
}
|
@ -5,9 +5,9 @@ $sLangName = "Deutsch";
|
||||
// RESOURCE IDENTITFIER = STRING
|
||||
// -------------------------------
|
||||
$aLang = array(
|
||||
'charset' => 'UTF-8',
|
||||
'charset' => 'UTF-8',
|
||||
|
||||
'mxd3manufacturerinfolongdesc' => 'Text',
|
||||
'mxd3manufacturerinfolongdesc' => 'Text',
|
||||
'SHOP_MODULE_GROUP_d3manufacturerinformation_main' => 'Settings',
|
||||
'SHOP_MODULE_d3manufacturerinformation_showManufacturertextOnDetailsPage' => 'display existing manufacturer texts on item details as a tab'
|
||||
);
|
@ -15,7 +15,7 @@
|
||||
|
||||
namespace D3\ManufacturerInformation\Modules\Application\Model{
|
||||
|
||||
use OxidEsales\Eshop\Application\Model\Manufacturer;
|
||||
use OxidEsales\Eshop\Application\Model\Manufacturer;
|
||||
|
||||
class D3ManufacturerLongDesc_parent extends Manufacturer {}
|
||||
class D3ManufacturerLongDesc_parent extends Manufacturer {}
|
||||
}
|
@ -12,30 +12,30 @@ use OxidEsales\Eshop\Core\Registry;
|
||||
|
||||
class D3ManufacturerLongDesc extends D3ManufacturerLongDesc_parent
|
||||
{
|
||||
/**
|
||||
* @param string $sValue
|
||||
* @return void
|
||||
*/
|
||||
public function d3SetLongdesc(string $sValue) :bool
|
||||
{
|
||||
if ($this->getId() and $this->isLoaded()){
|
||||
try {
|
||||
$this->assign([Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME => $sValue]);
|
||||
$this->save();
|
||||
}catch (\Exception $exception){
|
||||
Registry::getLogger()->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
/**
|
||||
* @param string $sValue
|
||||
* @return void
|
||||
*/
|
||||
public function d3SetLongdesc(string $sValue) :bool
|
||||
{
|
||||
if ($this->getId() and $this->isLoaded()){
|
||||
try {
|
||||
$this->assign([Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME => $sValue]);
|
||||
$this->save();
|
||||
}catch (\Exception $exception){
|
||||
Registry::getLogger()->error($exception->getMessage());
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return Field
|
||||
*/
|
||||
public function d3GetLongdesc(): Field
|
||||
{
|
||||
/**
|
||||
* @return Field
|
||||
*/
|
||||
public function d3GetLongdesc(): Field
|
||||
{
|
||||
$longName = $this->getCoreTableName().'__'.strtolower(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME);
|
||||
return $this->$longName;
|
||||
}
|
||||
return $this->$longName;
|
||||
}
|
||||
}
|
@ -12,14 +12,14 @@ use OxidEsales\Eshop\Core\Field;
|
||||
|
||||
class ManufacturerInfoList extends ManufacturerInfoList_parent
|
||||
{
|
||||
/**
|
||||
* @param Manufacturer|D3ManufacturerLongDesc $oManufacturer
|
||||
* @return void
|
||||
*/
|
||||
protected function _addCategoryFields($oManufacturer)
|
||||
{
|
||||
parent::_addCategoryFields($oManufacturer);
|
||||
/**
|
||||
* @param Manufacturer|D3ManufacturerLongDesc $oManufacturer
|
||||
* @return void
|
||||
*/
|
||||
protected function _addCategoryFields($oManufacturer)
|
||||
{
|
||||
parent::_addCategoryFields($oManufacturer);
|
||||
|
||||
$oManufacturer->oxcategories__oxlongdesc = new Field($oManufacturer->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME), Field::T_RAW);
|
||||
}
|
||||
$oManufacturer->oxcategories__oxlongdesc = new Field($oManufacturer->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME), Field::T_RAW);
|
||||
}
|
||||
}
|
@ -41,14 +41,14 @@ $aModule = [
|
||||
'email' => 'support@shopmodule.com',
|
||||
'url' => 'https://www.oxidmodule.com/',
|
||||
'controllers' => [
|
||||
"d3manufacturerinfolongdesc" => ManufacturerInfoLongdesc::class
|
||||
"d3manufacturerinfolongdesc" => ManufacturerInfoLongdesc::class
|
||||
],
|
||||
'extend' => [
|
||||
OEManufacturer::class => D3ManufacturerLongDesc::class,
|
||||
OEManufacturerList::class => ManufacturerInfoList::class
|
||||
OEManufacturer::class => D3ManufacturerLongDesc::class,
|
||||
OEManufacturerList::class => ManufacturerInfoList::class
|
||||
],
|
||||
'templates' => [
|
||||
'd3manufacturerlongdesc.tpl' => 'd3/manufacturerinformation/Application/views/admin/tpl/d3manufacturer_longdesc.tpl',
|
||||
'd3manufacturerlongdesc.tpl' => 'd3/manufacturerinformation/Application/views/admin/tpl/d3manufacturer_longdesc.tpl',
|
||||
],
|
||||
'settings' => [
|
||||
[
|
||||
|
@ -18,31 +18,31 @@ final class Version20241023154223 extends AbstractMigration
|
||||
return 'Adds the D3 manufacturer longdesc column';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
|
||||
$this->d3AddLongdescColumnToOxmanufacturers($schema);
|
||||
}
|
||||
$this->d3AddLongdescColumnToOxmanufacturers($schema);
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
* @return void
|
||||
* @throws \Doctrine\DBAL\Schema\SchemaException
|
||||
*/
|
||||
public function d3AddLongdescColumnToOxmanufacturers(Schema $schema){
|
||||
$table = !$schema->hasTable('oxmanufacturers') ?
|
||||
$schema->createTable('oxmanufacturers') :
|
||||
$schema->getTable('oxmanufacturers');
|
||||
/**
|
||||
* @param Schema $schema
|
||||
* @return void
|
||||
* @throws \Doctrine\DBAL\Schema\SchemaException
|
||||
*/
|
||||
public function d3AddLongdescColumnToOxmanufacturers(Schema $schema){
|
||||
$table = !$schema->hasTable('oxmanufacturers') ?
|
||||
$schema->createTable('oxmanufacturers') :
|
||||
$schema->getTable('oxmanufacturers');
|
||||
|
||||
// Beschreibung
|
||||
if (!$table->hasColumn('D3DESCRIPTION')) {
|
||||
$table->addColumn('D3DESCRIPTION', (new TextType())->getName())
|
||||
->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT)
|
||||
->setNotnull(true);
|
||||
}
|
||||
}
|
||||
// Beschreibung
|
||||
if (!$table->hasColumn('D3DESCRIPTION')) {
|
||||
$table->addColumn('D3DESCRIPTION', (new TextType())->getName())
|
||||
->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT)
|
||||
->setNotnull(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -15,48 +15,48 @@ final class Version20241028172608 extends AbstractMigration
|
||||
{
|
||||
public function getDescription() : string
|
||||
{
|
||||
return 'Adds multilang tables for the D3 manufacturer longdesc';
|
||||
return 'Adds multilang tables for the D3 manufacturer longdesc';
|
||||
}
|
||||
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
public function up(Schema $schema) : void
|
||||
{
|
||||
$this->connection->getDatabasePlatform()->registerDoctrineTypeMapping('enum', 'string');
|
||||
|
||||
$this->d3AddLongdescMultilangColumnsToOxmanufacturers($schema);
|
||||
}
|
||||
$this->d3AddLongdescMultilangColumnsToOxmanufacturers($schema);
|
||||
}
|
||||
|
||||
public function down(Schema $schema) : void
|
||||
{}
|
||||
|
||||
/**
|
||||
* @param Schema $schema
|
||||
* @return void
|
||||
* @throws \Doctrine\DBAL\Schema\SchemaException
|
||||
*/
|
||||
public function d3AddLongdescMultilangColumnsToOxmanufacturers(Schema $schema){
|
||||
$table = !$schema->hasTable('oxmanufacturers') ?
|
||||
$schema->createTable('oxmanufacturers') :
|
||||
$schema->getTable('oxmanufacturers');
|
||||
/**
|
||||
* @param Schema $schema
|
||||
* @return void
|
||||
* @throws \Doctrine\DBAL\Schema\SchemaException
|
||||
*/
|
||||
public function d3AddLongdescMultilangColumnsToOxmanufacturers(Schema $schema){
|
||||
$table = !$schema->hasTable('oxmanufacturers') ?
|
||||
$schema->createTable('oxmanufacturers') :
|
||||
$schema->getTable('oxmanufacturers');
|
||||
|
||||
// lang 1
|
||||
if (!$table->hasColumn('D3DESCRIPTION_1')) {
|
||||
$table->addColumn('D3DESCRIPTION_1', (new TextType())->getName())
|
||||
->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT)
|
||||
->setNotnull(true);
|
||||
}
|
||||
// lang 1
|
||||
if (!$table->hasColumn('D3DESCRIPTION_1')) {
|
||||
$table->addColumn('D3DESCRIPTION_1', (new TextType())->getName())
|
||||
->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT)
|
||||
->setNotnull(true);
|
||||
}
|
||||
|
||||
// lang 2
|
||||
if (!$table->hasColumn('D3DESCRIPTION_2')) {
|
||||
$table->addColumn('D3DESCRIPTION_2', (new TextType())->getName())
|
||||
->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT)
|
||||
->setNotnull(true);
|
||||
}
|
||||
// lang 2
|
||||
if (!$table->hasColumn('D3DESCRIPTION_2')) {
|
||||
$table->addColumn('D3DESCRIPTION_2', (new TextType())->getName())
|
||||
->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT)
|
||||
->setNotnull(true);
|
||||
}
|
||||
|
||||
// lang 3
|
||||
if (!$table->hasColumn('D3DESCRIPTION_3')) {
|
||||
$table->addColumn('D3DESCRIPTION_3', (new TextType())->getName())
|
||||
->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT)
|
||||
->setNotnull(true);
|
||||
}
|
||||
}
|
||||
// lang 3
|
||||
if (!$table->hasColumn('D3DESCRIPTION_3')) {
|
||||
$table->addColumn('D3DESCRIPTION_3', (new TextType())->getName())
|
||||
->setLength($this->connection->getDatabasePlatform()::LENGTH_LIMIT_TEXT)
|
||||
->setNotnull(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user