143 lignes
4.6 KiB
PHP
143 lignes
4.6 KiB
PHP
<?php
|
|
|
|
/**
|
|
* Copyright (c) D3 Data Development (Inh. Thomas Dartsch)
|
|
*
|
|
* For the full copyright and license information, please view
|
|
* the LICENSE file that was distributed with this source code.
|
|
*
|
|
* https://www.d3data.de
|
|
*
|
|
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
|
|
* @author D3 Data Development - Max Buhe, Daniel Seifert <info@shopmodule.com>
|
|
* @link https://www.oxidmodule.com
|
|
*/
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace D3\ManufacturerInformation\Application\Controller\Admin;
|
|
|
|
use D3\ManufacturerInformation\Application\Model\Constants;
|
|
use D3\ManufacturerInformation\Modules\Application\Model\D3ManufacturerLongDesc;
|
|
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
|
|
use OxidEsales\Eshop\Application\Model\Manufacturer;
|
|
use OxidEsales\Eshop\Core\Registry;
|
|
|
|
class ManufacturerInfoLongdesc extends AdminDetailsController
|
|
{
|
|
/**
|
|
* @return string
|
|
*/
|
|
public function render()
|
|
{
|
|
parent::render();
|
|
|
|
/** @var Manufacturer|D3ManufacturerLongDesc $oManufacturer */
|
|
$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::getRequest()->getRequestEscapedParameter("catlang");
|
|
|
|
if (!isset($d3manufacturerlang)) {
|
|
$d3manufacturerlang = $this->_iEditLang;
|
|
}
|
|
|
|
$this->_aViewData["catlang"] = $d3manufacturerlang;
|
|
|
|
$oManufacturer->loadInLang($d3manufacturerlang, $sOXID);
|
|
|
|
//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;
|
|
}
|
|
}
|
|
|
|
$this->_aViewData["editor"] = $this->generateTextEditor("100%", 280, $oManufacturer, $oManufacturer->getD3LongDescTableColumnName(), "list.css");
|
|
|
|
return "@d3manufacturerinformation/admin/d3manufacturerlongdesc";
|
|
}
|
|
|
|
/**
|
|
* @return void
|
|
* @throws \Exception
|
|
*/
|
|
public function save()
|
|
{
|
|
parent::save();
|
|
|
|
$iManufacturerLang = intval(\OxidEsales\Eshop\Core\Registry::getRequest()->getRequestEscapedParameter("catlang"));
|
|
$sOXID = $this->getEditObjectId();
|
|
$this->setEditObjectId($sOXID);
|
|
|
|
if ($sOXID == "-1") {
|
|
return;
|
|
}
|
|
|
|
/** @var Manufacturer|D3ManufacturerLongDesc $oManufacturer */
|
|
$oManufacturer = oxNew(Manufacturer::class);
|
|
$oManufacturer->loadInLang($iManufacturerLang, $sOXID);
|
|
|
|
if (!$oManufacturer->load($sOXID)) {
|
|
return;
|
|
}
|
|
|
|
$aParams = Registry::getRequest()->getRequestEscapedParameter("editval");
|
|
$oManufacturer->assign($aParams);
|
|
|
|
if (false === is_null($this->d3GetLongdescParamValue($oManufacturer))) {
|
|
$oManufacturer->d3SetLongdesc($this->d3GetLongdescParamValue($oManufacturer));
|
|
$oManufacturer->save();
|
|
}
|
|
}
|
|
|
|
/**
|
|
* @param $oManufacturer
|
|
* @param $sField
|
|
* @return string
|
|
*/
|
|
protected function getEditValue($oManufacturer, $sField)
|
|
{
|
|
$sEditObjectValue = '';
|
|
|
|
if ($oManufacturer and $oManufacturer->getId()) {
|
|
$sEditObjectValue = $oManufacturer->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME);
|
|
}
|
|
|
|
return $sEditObjectValue;
|
|
}
|
|
|
|
/**
|
|
* @param Manufacturer|D3ManufacturerLongDesc $oManufacturer
|
|
* @return string
|
|
*/
|
|
public function d3GetLongdescParamValue(Manufacturer $oManufacturer): string
|
|
{
|
|
return (string) $aParams = Registry::getRequest()->getRequestEscapedParameter("editval")[$oManufacturer->getD3LongDescTableColumnName()];
|
|
}
|
|
|
|
/**
|
|
* 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);
|
|
}
|
|
}
|