[Update] ManufacturerTab-Controller
[Added] savability and display in tab
This commit is contained in:
parent
2d12603b69
commit
e1a2f8ec48
@ -4,18 +4,25 @@ declare(strict_types=1);
|
|||||||
|
|
||||||
namespace D3\ManufacturerInformation\Application\Controller\Admin;
|
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\Controller\Admin\AdminDetailsController;
|
||||||
|
use OxidEsales\Eshop\Application\Model\Manufacturer;
|
||||||
|
use OxidEsales\Eshop\Core\Registry;
|
||||||
|
|
||||||
class ManufacturerInfoLongdesc extends AdminDetailsController
|
class ManufacturerInfoLongdesc extends AdminDetailsController
|
||||||
{
|
{
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
public function render()
|
public function render()
|
||||||
{
|
{
|
||||||
parent::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();
|
$sOXID = $this->_aViewData["oxid"] = $this->getEditObjectId();
|
||||||
if (isset($soxId) && $soxId != "-1") {
|
if (isset($sOXID) && $sOXID != "-1") {
|
||||||
// load object
|
// load object
|
||||||
$d3manufacturerlang = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("d3manufacturerlang");
|
$d3manufacturerlang = \OxidEsales\Eshop\Core\Registry::getConfig()->getRequestParameter("d3manufacturerlang");
|
||||||
|
|
||||||
@ -25,7 +32,7 @@ class ManufacturerInfoLongdesc extends AdminDetailsController
|
|||||||
|
|
||||||
$this->_aViewData["d3manufacturerlang"] = $d3manufacturerlang;
|
$this->_aViewData["d3manufacturerlang"] = $d3manufacturerlang;
|
||||||
|
|
||||||
$oManufacturer->loadInLang($d3manufacturerlang, $soxId);
|
$oManufacturer->loadInLang($d3manufacturerlang, $sOXID);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@ -42,13 +49,68 @@ class ManufacturerInfoLongdesc extends AdminDetailsController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$this->_aViewData["editor"] = $this->generateTextEditor("100%", 280, $oManufacturer, "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()
|
public function save()
|
||||||
{
|
{
|
||||||
parent::save();
|
parent::save();
|
||||||
|
|
||||||
|
$sOXID = $this->getEditObjectId();
|
||||||
|
$this->setEditObjectId($sOXID);
|
||||||
|
|
||||||
|
if ($sOXID == "-1") {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @var Manufacturer|D3ManufacturerLongDesc $oManufacturer */
|
||||||
|
$oManufacturer = oxNew(Manufacturer::class);
|
||||||
|
$oManufacturer->setLanguage($this->_iEditLang);
|
||||||
|
|
||||||
|
if (!$oManufacturer->load($sOXID)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
$aParams = Registry::getRequest()->getRequestEscapedParameter("editval");
|
||||||
|
$oManufacturer->assign($aParams);
|
||||||
|
|
||||||
|
// default longdesc can parsed only, if longtext #1 is selected, all other longtext selections don't contains its value
|
||||||
|
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($oObject, $sField) // phpcs:ignore PSR2.Methods.MethodDeclaration.Underscore
|
||||||
|
{
|
||||||
|
$sEditObjectValue = '';
|
||||||
|
if ($oObject) {
|
||||||
|
$sEditObjectValue = $this->_processEditValue($oObject->getFieldData(Constants::D3_OXMANUFACTURERS_LONGDESC_FIELDNAME));
|
||||||
|
}
|
||||||
|
|
||||||
|
return $sEditObjectValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
|
public function d3GetLongdescParamValue() :string
|
||||||
|
{
|
||||||
|
return $aParams = Registry::getRequest()->getRequestEscapedParameter("editval")['oxmanufacturers__D3DESCRIPTION'];
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user