8
0

125 Zeilen
3.9 KiB
PHP

2024-10-23 20:18:20 +02:00
<?php
2024-11-19 10:50:33 +01:00
/**
* 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
*/
2024-10-23 20:18:20 +02:00
declare(strict_types=1);
namespace D3\ManufacturerInformation\Application\Controller\Admin;
use D3\ManufacturerInformation\Application\Model\Constants;
use D3\ManufacturerInformation\Modules\Application\Model\D3ManufacturerLongDesc;
2024-10-23 20:18:20 +02:00
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
use OxidEsales\Eshop\Application\Model\Manufacturer;
use OxidEsales\Eshop\Core\Registry;
2024-10-23 20:18:20 +02:00
class ManufacturerInfoLongdesc extends AdminDetailsController
{
2024-11-19 09:54:00 +01:00
/**
* @return string
*/
public function render()
{
parent::render();
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
$this->_aViewData['edit'] = $oManufacturer = oxNew(\OxidEsales\Eshop\Application\Model\Manufacturer::class);
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
$sOXID = $this->_aViewData["oxid"] = $this->getEditObjectId();
if (isset($sOXID) && $sOXID != "-1") {
// load object
$d3manufacturerlang = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("catlang");
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
if (!isset($d3manufacturerlang)) {
$d3manufacturerlang = $this->_iEditLang;
}
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
$this->_aViewData["catlang"] = $d3manufacturerlang;
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
$oManufacturer->loadInLang($d3manufacturerlang, $sOXID);
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
//Disable editing for derived items
if ($oManufacturer->isDerived()) {
$this->_aViewData['readonly'] = true;
}
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
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;
}
}
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
$this->_aViewData["editor"] = $this->generateTextEditor("100%", 280, $oManufacturer, "oxmanufacturers__d3description", "list.tpl.css");
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
return "d3manufacturerlongdesc.tpl";
}
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
/**
* @return void
* @throws \Exception
*/
public function save()
{
parent::save();
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
$iManufacturerLang = intval(\OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("catlang"));
$sOXID = $this->getEditObjectId();
$this->setEditObjectId($sOXID);
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
if ($sOXID == "-1") {
return;
}
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
/** @var Manufacturer|D3ManufacturerLongDesc $oManufacturer */
$oManufacturer = oxNew(Manufacturer::class);
$oManufacturer->loadInLang($iManufacturerLang, $sOXID);
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
if (!$oManufacturer->load($sOXID)) {
return;
}
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
$aParams = Registry::getRequest()->getRequestEscapedParameter("editval");
$oManufacturer->assign($aParams);
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
if (false === is_null($this->d3GetLongdescParamValue())) {
$oManufacturer->d3SetLongdesc($this->d3GetLongdescParamValue());
$oManufacturer->save();
}
}
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
/**
* @return string
*/
2024-11-19 10:50:33 +01:00
public function d3GetLongdescParamValue(): string
2024-11-19 09:54:00 +01:00
{
2024-12-05 12:12:44 +01:00
return (string) Registry::getRequest()->getRequestEscapedParameter("editval")['oxmanufacturers__d3description'];
2024-11-19 09:54:00 +01:00
}
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
/**
* inhaltliche Uebernahme analog Article_Main
* wird genutzt zum Abspeichern der Artikel-Langbeschreibung
*
* @param $sValue
*
* @return mixed
*/
protected function _processLongDesc($sValue)
{
$aSearch = ['&amp;nbsp;', '&amp;', '&quot;', '&lang=', '<p>&nbsp;</p>', '<p>&nbsp; </p>'];
$aReplace = ['&nbsp;', '&', '"', '&amp;lang=', '', ''];
2024-11-19 10:50:33 +01:00
2024-11-19 09:54:00 +01:00
return str_replace($aSearch, $aReplace, $sValue);
}
2024-11-19 10:50:33 +01:00
}