Ordermanager/src/Application/Controller/Admin/d3_cfg_ordermanageritem_mal...

236 lines
6.1 KiB
PHP
Raw Normal View History

2017-12-20 13:44:53 +01:00
<?php
/**
* This Software is the property of Data Development and is protected
* by copyright law - it is NOT Freeware.
*
* Any unauthorized use of this software without a valid license
* is a violation of the license agreement and will be prosecuted by
* civil and criminal law.
*
* http://www.shopmodule.com
*
* @copyright (C) D3 Data Development (Inh. Thomas Dartsch)
* @author D3 Data Development - Daniel Seifert <support@shopmodule.com>
* @link http://www.oxidmodule.com
*/
namespace D3\Ordermanager\Application\Controller\Admin;
2019-07-09 10:28:15 +02:00
use D3\ModCfg\Application\Model\d3filesystem;
use D3\ModCfg\Application\Model\d3str;
2017-12-20 13:44:53 +01:00
use D3\Ordermanager\Application\Model\d3ordermanager;
use D3\ModCfg\Application\Model\Configuration\d3_cfg_mod;
2019-05-15 11:31:56 +02:00
use Exception;
2017-12-20 13:44:53 +01:00
use OxidEsales\Eshop\Application\Controller\Admin\AdminDetailsController;
use OxidEsales\Eshop\Application\Controller\Admin\AdminMall; // required for non fallback case
2019-05-15 11:31:56 +02:00
use OxidEsales\Eshop\Core\Language;
2017-12-20 13:44:53 +01:00
use OxidEsales\Eshop\Core\Request;
2019-05-15 11:31:56 +02:00
// @codeCoverageIgnoreStart
2017-12-20 13:44:53 +01:00
// fallback for non ee editions
if (false == class_exists("\OxidEsales\Eshop\Application\Controller\Admin\AdminMall")) {
class d3AdminMall extends AdminDetailsController
{
protected $_blThisTemplate = "d3_cfg_ordermanageritem_mall.tpl";
/**
* @return string
*/
public function render()
{
parent::render();
return $this->_blThisTemplate;
}
public function assignToSubshops()
{
}
}
} else {
class d3AdminMall extends AdminMall {}
}
2019-05-15 11:31:56 +02:00
// @codeCoverageIgnoreEnd
2017-12-20 13:44:53 +01:00
/**
*
*/
class d3_cfg_ordermanageritem_mall extends d3AdminMall
{
2019-05-15 11:31:56 +02:00
private $_sModId = 'd3_ordermanager';
2017-12-20 13:44:53 +01:00
/**
* DB table having oxshopincl and oxshopexcl fields we are going to deal with
*/
protected $_sMallTable = "d3modprofile";
protected $_blUseOwnOxid = true;
protected $_sMenuItemTitle = 'd3mxordermanager';
protected $_sMenuSubItemTitle = 'd3tbclordermanager_items_mall';
protected $_sUpdateAddSql;
protected $_sHelpLinkMLAdd;
protected $_aNaviItems = array(
'new' => array(
'sScript' => 'top.oxid.admin.editThis( -1 );return false;',
'sTranslationId' => 'D3_TOOLTIPS_NEWORDERMANAGER',
),
);
/**
* Class name of object to load
*/
protected $_sObjectClassName = d3ordermanager::class;
2019-05-15 11:31:56 +02:00
/**
* d3_cfg_ordermanageritem_mall constructor.
*/
public function __construct()
{
d3GetModCfgDIC()->setParameter('d3.ordermanager.modcfgid', $this->_sModId);
parent::__construct();
}
/**
* @return d3ordermanager
2019-07-09 10:28:15 +02:00
* @throws Exception
2019-05-15 11:31:56 +02:00
*/
public function getProfile()
{
2021-03-16 10:11:13 +01:00
/** @var d3ordermanager $oManager */
$oManager = d3GetModCfgDIC()->get($this->_sObjectClassName);
return $oManager;
2019-05-15 11:31:56 +02:00
}
2017-12-20 13:44:53 +01:00
/**
* @return string
2019-05-15 11:31:56 +02:00
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
public function render()
{
2019-05-15 11:31:56 +02:00
$oProfile = $this->getProfile();
/** @var Request $request */
$request = d3GetModCfgDIC()->get('d3ox.ordermanager.'.Request::class);
$soxId = $request->getRequestEscapedParameter("oxid");
2017-12-20 13:44:53 +01:00
if ($this->_isSetOxid($soxId)) {
// load object
$oProfile->loadInLang($this->_iEditLang, $soxId);
$oProfile = $this->_d3LoadInOtherLang($oProfile, $soxId);
}
$this->addTplParam('edit', $oProfile);
return parent::render();
}
/**
2019-05-15 11:31:56 +02:00
* @return array
2017-12-20 13:44:53 +01:00
*/
2019-05-15 11:31:56 +02:00
public function getUserMessages()
2017-12-20 13:44:53 +01:00
{
2019-05-15 11:31:56 +02:00
return array();
}
2017-12-20 13:44:53 +01:00
2019-05-15 11:31:56 +02:00
/**
* @return Language
* @throws Exception
*/
public function getLang()
{
2021-03-16 10:11:13 +01:00
/** @var Language $lang */
$lang = d3GetModCfgDIC()->get('d3ox.ordermanager.'.Language::class);
return $lang;
2017-12-20 13:44:53 +01:00
}
/**
* @return string
2019-05-15 11:31:56 +02:00
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
public function getHelpURL()
{
$sUrl = $this->d3GetSet()->getHelpURL();
2019-07-09 10:28:15 +02:00
/** @var d3str $oD3Str */
$oD3Str = d3GetModCfgDIC()->get(d3str::class);
2017-12-20 13:44:53 +01:00
if ($this->_sHelpLinkMLAdd) {
2019-07-09 10:28:15 +02:00
$sUrl .= $oD3Str->unprefixedslashit($this->getLang()->translateString($this->_sHelpLinkMLAdd));
2017-12-20 13:44:53 +01:00
}
2019-07-09 10:28:15 +02:00
$oFS = d3GetModCfgDIC()->get(d3filesystem::class);
2017-12-20 13:44:53 +01:00
$aFileName = $oFS->splitFilename($sUrl);
// has no extension
if (false == $aFileName['ext']) {
2019-07-09 10:28:15 +02:00
$sUrl = $oD3Str->trailingslashit($sUrl);
2017-12-20 13:44:53 +01:00
}
return $sUrl;
}
/**
* @return d3_cfg_mod
2019-05-15 11:31:56 +02:00
* @throws Exception
2017-12-20 13:44:53 +01:00
*/
public function d3GetSet()
{
2021-03-16 10:11:13 +01:00
/** @var d3_cfg_mod $modcfg */
$modcfg = d3GetModCfgDIC()->get('d3.ordermanager.modcfg');
return $modcfg;
2017-12-20 13:44:53 +01:00
}
/**
* exampleItem: array('new' => array(
* 'sScript' => 'top.oxid.admin.editThis( -1 );return false;',
* 'sTranslationId' => 'foo',
* )
* @return array
*/
public function getNaviItems()
{
return $this->_aNaviItems;
}
/**
* @return string
*/
public function d3GetMenuItemTitle()
{
return $this->_sMenuItemTitle;
}
/**
* @return string
*/
public function d3GetMenuSubItemTitle()
{
return $this->_sMenuSubItemTitle;
}
/**
* @param $soxId
*
* @return bool
*/
protected function _isSetOxid($soxId)
{
return isset($soxId) && $soxId && $soxId != "-1";
}
/**
* @param d3ordermanager $oProfile
* @param $soxId
*
* @return d3ordermanager
*/
protected function _d3LoadInOtherLang(d3ordermanager $oProfile, $soxId)
{
// load object in other languages
$oOtherLang = $oProfile->getAvailableInLangs();
2019-05-15 11:31:56 +02:00
2017-12-20 13:44:53 +01:00
if (false == isset($oOtherLang[$this->_iEditLang])) {
$oProfile->loadInLang(key($oOtherLang), $soxId);
}
return $oProfile;
}
}