From 5a83ed0f118544492fadb5c164a2c1888791d9f7 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Tue, 25 Feb 2020 08:20:10 +0100 Subject: [PATCH] add files for rel_2.x --- composer.json | 42 +++++++++ .../d3/d3multiattributevalues/metadata.php | 60 ------------- .../d3_article_attribute_ajax_multivalues.php | 70 --------------- patches/article_attribute_ajax.patch | 29 ++++++ .../tpl/d3_article_attribute_multivalues.tpl | 0 src/IntelliSenseHelper.php | 33 +++++++ .../d3_article_attribute_ajax_multivalues.php | 90 +++++++++++++++++++ .../d3_article_attribute_multivalues.php | 6 +- .../Model}/d3_oxattributelist_multivalues.php | 6 +- src/metadata.php | 46 ++++++++++ 10 files changed, 248 insertions(+), 134 deletions(-) create mode 100644 composer.json delete mode 100644 copy_this/modules/d3/d3multiattributevalues/metadata.php delete mode 100644 copy_this/modules/d3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_ajax_multivalues.php create mode 100644 patches/article_attribute_ajax.patch rename {copy_this/modules/d3/d3multiattributevalues => src/Application}/views/admin/tpl/d3_article_attribute_multivalues.tpl (100%) create mode 100644 src/IntelliSenseHelper.php create mode 100644 src/Modules/Application/Controllers/Admin/d3_article_attribute_ajax_multivalues.php rename {copy_this/modules/d3/d3multiattributevalues/modules/controllers/admin => src/Modules/Application/Controllers/Admin}/d3_article_attribute_multivalues.php (82%) rename {copy_this/modules/d3/d3multiattributevalues/modules/models => src/Modules/Application/Model}/d3_oxattributelist_multivalues.php (83%) create mode 100644 src/metadata.php diff --git a/composer.json b/composer.json new file mode 100644 index 0000000..1f32303 --- /dev/null +++ b/composer.json @@ -0,0 +1,42 @@ +{ + "name": "d3/attributemultivalues", + "description": "mehrfache Wertezuordnung zu Attributen", + "type": "oxideshop-module", + "version": "1.0", + "keywords": [ + "oxid", + "modules", + "eShop", + "d3" + ], + "authors": [ + { + "name": "D3 Data Development (Inh. Thomas Dartsch)", + "email": "info@shopmodule.com", + "homepage": "http://www.d3data.de", + "role": "Owner" + } + ], + "homepage": "https://www.oxidmodule.com/", + "license": [ + "proprietary" + ], + "extra": { + "oxideshop": { + "source-directory": "/src", + "target-directory": "d3/attributemultivalues" + }, + "patches": { + "oxid-esales/oxideshop-ce": { + "add multi assignment to article attribute ajax template - 2020-02-24": "vendor/d3/attributemultivalues/patches/article_attribute_ajax.patch" + } + } + }, + "require": { + }, + "autoload": { + "psr-4": { + "D3\\AttributeMultiValues\\": "../../../source/modules/d3/attributemultivalues" + } + } +} diff --git a/copy_this/modules/d3/d3multiattributevalues/metadata.php b/copy_this/modules/d3/d3multiattributevalues/metadata.php deleted file mode 100644 index 60d05d3..0000000 --- a/copy_this/modules/d3/d3multiattributevalues/metadata.php +++ /dev/null @@ -1,60 +0,0 @@ - - * @link http://www.oxidmodule.com - */ - -/** - * Metadata version - */ -$sMetadataVersion = '1.1'; - -/** - * Module information - */ -$aModule = array( - 'id' => 'd3multiattributevalues', - 'title' => (class_exists('d3utils') ? d3utils::getInstance()->getD3Logo() : 'D³') . ' Mehrfachzuordnungen bei Attributen', - 'description' => array( - 'de' => '', - 'en' => '', - ), - 'thumbnail' => 'picture.png', - 'version' => 'indiv.', - 'author' => 'D³ Data Development (Inh.: Thomas Dartsch)', - 'email' => 'support@shopmodule.com', - 'url' => 'http://www.oxidmodule.com/', - 'extend' => array( - 'article_attribute_ajax' => 'd3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_ajax_multivalues', - 'article_attribute' => 'd3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_multivalues', - 'oxattributelist' => 'd3/d3multiattributevalues/modules/models/d3_oxattributelist_multivalues', - ), - 'files' => array( - ), - 'templates' => array( - 'd3_article_attribute_multivalues.tpl' => 'd3/d3multiattributevalues/views/admin/tpl/d3_article_attribute_multivalues.tpl', - ), - 'events' => array( - 'onActivate' => 'd3install::checkUpdateStart', - ), - 'settings' => array( - ), - 'blocks' => array( - ), - 'd3FileRegister' => array( - 'd3/d3multilang/IntelliSenseHelper.php', - 'd3/d3multilang/metadata.php', - 'd3/d3multilang/views/admin/de/d3_multilang_lang.php', - 'd3/d3multilang/views/admin/en/d3_multilang_lang.php', - 'd3/d3multilang/views/admin/tpl/modcfg-pattern/oxid_lang_file.tpl', - ), -); \ No newline at end of file diff --git a/copy_this/modules/d3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_ajax_multivalues.php b/copy_this/modules/d3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_ajax_multivalues.php deleted file mode 100644 index 8933983..0000000 --- a/copy_this/modules/d3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_ajax_multivalues.php +++ /dev/null @@ -1,70 +0,0 @@ - - * @link http://www.oxidmodule.com - */ - -class d3_article_attribute_ajax_multivalues extends d3_article_attribute_ajax_multivalues_parent -{ - /** - * Returns SQL query for data to fetc - * - * @return string - */ - protected function _getQuery() - { - $sQAdd = parent::_getQuery(); - - $sArtId = oxRegistry::getConfig()->getRequestParameter('oxid'); - - if (false == $sArtId) { - $sAttrViewName = $this->_getViewName('oxattribute'); - $sQAdd = " from {$sAttrViewName} where {$sAttrViewName}.oxid "; - } - - return $sQAdd; - } - - /** - * Saves attribute value - */ - public function saveAttributeValue() - { - $oDb = oxDb::getDb(); - - $soxId = oxRegistry::getConfig()->getRequestParameter("oxid"); - $sAttributeId = oxRegistry::getConfig()->getRequestParameter("attr_oxid"); - - $sAttributeValue = oxRegistry::getConfig()->getRequestParameter("attr_value"); - $sO2AttributeValue = $oDb->quote(oxRegistry::getConfig()->getRequestParameter("o2attr_oxid")); - - if (!$this->getConfig()->isUtf()) { - $sAttributeValue = iconv('UTF-8', oxRegistry::getLang()->translateString("charset"), $sAttributeValue); - } - - $oArticle = oxNew("oxarticle"); - if ($oArticle->load($soxId)) { - if (isset($sAttributeId) && ("" != $sAttributeId)) { - $sViewName = $this->_getViewName("oxobject2attribute"); - $sSelect = "select * from {$sViewName} where {$sViewName}.oxid= {$sO2AttributeValue}"; - $oO2A = oxNew("oxi18n"); - $oO2A->setLanguage(oxRegistry::getConfig()->getRequestParameter('editlanguage')); - $oO2A->init("oxobject2attribute"); - if ($oO2A->assignRecord($sSelect)) { - $oO2A->oxobject2attribute__oxvalue->setValue($sAttributeValue); - $oO2A->save(); - } - } - } - } -} diff --git a/patches/article_attribute_ajax.patch b/patches/article_attribute_ajax.patch new file mode 100644 index 0000000..5efc16b --- /dev/null +++ b/patches/article_attribute_ajax.patch @@ -0,0 +1,29 @@ +diff --git "a/source/application/views/admin/tpl/popups/article_attribute.tpl" "b/source/application/views/admin/tpl/popups/article_attribute.tpl" +index 8c7f89f59..8debd4f08 100644 +--- "a/source/application/views/admin/tpl/popups/article_attribute.tpl" ++++ "b/source/application/views/admin/tpl/popups/article_attribute.tpl" +@@ -49,6 +49,7 @@ + $('_attrname').innerHTML = oParam._oData._0; + $('attr_value').value = oParam._oData._2; + $('attr_oxid').value = oParam._oData._3; ++ $('o2attr_oxid').value = oParam._oData._1; [{*** d3 completed ***}] + $D.setStyle( $('arrt_conf'), 'visibility', '' ); + } else { + $D.setStyle( $('arrt_conf'), 'visibility', 'hidden' ); +@@ -73,7 +74,7 @@ + failure: YAHOO.oxid.container2.onFailure, + scope: YAHOO.oxid.container2 + }; +- YAHOO.util.Connect.asyncRequest( 'GET', '[{ $oViewConf->getAjaxLink() }]&cmpid=container2&container=article_attribute&fnc=saveAttributeValue&oxid=[{ $oxid }]&attr_value=' + encodeURIComponent( $('attr_value').value ) + '&attr_oxid=' + encodeURIComponent( $('attr_oxid').value ), callback ); ++ YAHOO.util.Connect.asyncRequest( 'GET', '[{ $oViewConf->getAjaxLink() }]&cmpid=container2&container=article_attribute&fnc=saveAttributeValue&oxid=[{ $oxid }]&attr_value=' + encodeURIComponent( $('attr_value').value ) + '&attr_oxid=' + encodeURIComponent( $('attr_oxid').value ) + '&o2attr_oxid=' + encodeURIComponent( $('o2attr_oxid').value ), callback ); [{*** d3 completed***}] + + } + // subscribint event listeners on buttons +@@ -101,6 +102,7 @@ + +

+ [{ $attr_name }]:

++ [{*** d3 completed ***}] + +

+ diff --git a/copy_this/modules/d3/d3multiattributevalues/views/admin/tpl/d3_article_attribute_multivalues.tpl b/src/Application/views/admin/tpl/d3_article_attribute_multivalues.tpl similarity index 100% rename from copy_this/modules/d3/d3multiattributevalues/views/admin/tpl/d3_article_attribute_multivalues.tpl rename to src/Application/views/admin/tpl/d3_article_attribute_multivalues.tpl diff --git a/src/IntelliSenseHelper.php b/src/IntelliSenseHelper.php new file mode 100644 index 0000000..33b00ed --- /dev/null +++ b/src/IntelliSenseHelper.php @@ -0,0 +1,33 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\Modules\AttributeMultiValues\Application\Controllers\Admin { + + use OxidEsales\Eshop\Application\Controller\Admin\ArticleAttribute; + use OxidEsales\Eshop\Application\Controller\Admin\ArticleAttributeAjax; + + class d3_article_attribute_ajax_multivalues_parent extends ArticleAttributeAjax {} + + class d3_article_attribute_multivalues_parent extends ArticleAttribute {} +} + +namespace D3\Modules\AttributeMultiValues\Application\Model { + + use OxidEsales\Eshop\Application\Model\AttributeList; + + class d3_oxattributelist_multivalues_parent extends AttributeList {} +} diff --git a/src/Modules/Application/Controllers/Admin/d3_article_attribute_ajax_multivalues.php b/src/Modules/Application/Controllers/Admin/d3_article_attribute_ajax_multivalues.php new file mode 100644 index 0000000..87b1967 --- /dev/null +++ b/src/Modules/Application/Controllers/Admin/d3_article_attribute_ajax_multivalues.php @@ -0,0 +1,90 @@ + + * @link http://www.oxidmodule.com + */ + +namespace D3\Modules\AttributeMultiValues\Application\Controllers\Admin; + +use Exception; +use OxidEsales\Eshop\Application\Model\Article; +use OxidEsales\Eshop\Application\Model\Attribute; +use OxidEsales\Eshop\Core\DatabaseProvider; +use OxidEsales\Eshop\Core\Exception\DatabaseConnectionException; +use OxidEsales\Eshop\Core\Model\MultiLanguageModel; +use OxidEsales\Eshop\Core\Registry; + +class d3_article_attribute_ajax_multivalues extends d3_article_attribute_ajax_multivalues_parent +{ + /** + * Returns SQL query for data to fetc + * + * @return string + */ + protected function _getQuery() + { + $sQAdd = parent::_getQuery(); + + $sArtId = Registry::getRequest()->getRequestParameter('oxid'); + + if (false == $sArtId) { + $attribute = oxNew(Attribute::class); + $sAttrViewName = $attribute->_getViewName(); + $sQAdd = " from {$sAttrViewName} where {$sAttrViewName}.oxid "; + } + + return $sQAdd; + } + + /** + * Saves attribute value + * + * @return void|null + * @throws DatabaseConnectionException + * @throws Exception + */ + public function saveAttributeValue() + { + $database = DatabaseProvider::getDb(); + $request = Registry::getRequest(); + $this->resetContentCache(); + + $articleId = $request->getRequestParameter("oxid"); + $attributeId = $request->getRequestParameter("attr_oxid"); + $attributeValue = $request->getRequestParameter("attr_value"); + + $article = oxNew(Article::class); + if ($article->load($articleId)) { + if ($article->isDerived()) { + return; + } + + $this->onAttributeValueChange($article); + + if (isset($attributeId) && ("" != $attributeId)) { + $viewName = $this->_getViewName("oxobject2attribute"); + $quotedArticleId = $database->quote($article->getId()); + // D3: remove unused attrid selection + $select = "select * from {$viewName} where {$viewName}.oxobjectid= {$quotedArticleId}"; + $objectToAttribute = oxNew(MultiLanguageModel::class); + $objectToAttribute->setLanguage($request->getRequestParameter('editlanguage')); + $objectToAttribute->init("oxobject2attribute"); + if ($objectToAttribute->assignRecord($select)) { + $objectToAttribute->oxobject2attribute__oxvalue->setValue($attributeValue); + $objectToAttribute->save(); + } + } + } + } +} diff --git a/copy_this/modules/d3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_multivalues.php b/src/Modules/Application/Controllers/Admin/d3_article_attribute_multivalues.php similarity index 82% rename from copy_this/modules/d3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_multivalues.php rename to src/Modules/Application/Controllers/Admin/d3_article_attribute_multivalues.php index f24c7b6..75abd2a 100644 --- a/copy_this/modules/d3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_multivalues.php +++ b/src/Modules/Application/Controllers/Admin/d3_article_attribute_multivalues.php @@ -9,11 +9,13 @@ * * http://www.shopmodule.com * - * @copyright © D³ Data Development, Thomas Dartsch - * @author D³ Data Development - Daniel Seifert + * @copyright � D� Data Development, Thomas Dartsch + * @author D� Data Development - Daniel Seifert * @link http://www.oxidmodule.com */ +namespace D3\Modules\AttributeMultiValues\Application\Controllers\Admin; + class d3_article_attribute_multivalues extends d3_article_attribute_multivalues_parent { /** diff --git a/copy_this/modules/d3/d3multiattributevalues/modules/models/d3_oxattributelist_multivalues.php b/src/Modules/Application/Model/d3_oxattributelist_multivalues.php similarity index 83% rename from copy_this/modules/d3/d3multiattributevalues/modules/models/d3_oxattributelist_multivalues.php rename to src/Modules/Application/Model/d3_oxattributelist_multivalues.php index b04a572..54a1f8b 100644 --- a/copy_this/modules/d3/d3multiattributevalues/modules/models/d3_oxattributelist_multivalues.php +++ b/src/Modules/Application/Model/d3_oxattributelist_multivalues.php @@ -9,11 +9,13 @@ * * http://www.shopmodule.com * - * @copyright © D³ Data Development, Thomas Dartsch - * @author D³ Data Development - Daniel Seifert + * @copyright � D� Data Development, Thomas Dartsch + * @author D� Data Development - Daniel Seifert * @link http://www.oxidmodule.com */ +namespace D3\Modules\AttributeMultiValues\Application\Model; + class d3_oxattributelist_multivalues extends d3_oxattributelist_multivalues_parent { /** diff --git a/src/metadata.php b/src/metadata.php new file mode 100644 index 0000000..eb8b7d0 --- /dev/null +++ b/src/metadata.php @@ -0,0 +1,46 @@ + + * @link http://www.oxidmodule.com + */ + +use D3\Modules\AttributeMultiValues\Application\Controllers\Admin\d3_article_attribute_ajax_multivalues; +use D3\Modules\AttributeMultiValues\Application\Controllers\Admin\d3_article_attribute_multivalues; +use D3\Modules\AttributeMultiValues\Application\Model\d3_oxattributelist_multivalues; +use OxidEsales\Eshop\Application\Controller\Admin\ArticleAttribute; +use OxidEsales\Eshop\Application\Controller\Admin\ArticleAttributeAjax; +use OxidEsales\Eshop\Application\Model\AttributeList; + +/** + * Metadata version + */ +$sMetadataVersion = '2.1'; + +/** + * Module information + */ +$aModule = array( + 'id' => 'd3attributemultivalues', + 'title' => 'D³ mehrfache Wertezuordnung zu Attributen', + 'version' => '0.0.0.1', + 'author' => 'D³ Data Development (Inh.: Thomas Dartsch)', + 'email' => 'support@shopmodule.com', + 'url' => 'http://www.oxidmodule.com/', + 'extend' => [ + ArticleAttributeAjax::class => d3_article_attribute_ajax_multivalues::class, + ArticleAttribute::class => d3_article_attribute_multivalues::class, + AttributeList::class => d3_oxattributelist_multivalues::class, + ], + 'templates' => [ + 'd3_article_attribute_multivalues.tpl' => 'd3/d3multiattributevalues/Application/views/admin/tpl/d3_article_attribute_multivalues.tpl', + ] +); \ No newline at end of file