From c17878f773deb8e67929a48c797f321fa690ba44 Mon Sep 17 00:00:00 2001 From: Daniel Seifert Date: Mon, 24 Feb 2020 15:53:45 +0100 Subject: [PATCH] add release 1.x --- .../d3/d3multiattributevalues/metadata.php | 60 +++++++++ .../d3_article_attribute_ajax_multivalues.php | 70 ++++++++++ .../d3_article_attribute_multivalues.php | 37 ++++++ .../models/d3_oxattributelist_multivalues.php | 38 ++++++ .../tpl/d3_article_attribute_multivalues.tpl | 120 ++++++++++++++++++ setup+doku/usage.txt | 8 ++ 6 files changed, 333 insertions(+) create mode 100644 copy_this/modules/d3/d3multiattributevalues/metadata.php create mode 100644 copy_this/modules/d3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_ajax_multivalues.php create mode 100644 copy_this/modules/d3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_multivalues.php create mode 100644 copy_this/modules/d3/d3multiattributevalues/modules/models/d3_oxattributelist_multivalues.php create mode 100644 copy_this/modules/d3/d3multiattributevalues/views/admin/tpl/d3_article_attribute_multivalues.tpl create mode 100644 setup+doku/usage.txt diff --git a/copy_this/modules/d3/d3multiattributevalues/metadata.php b/copy_this/modules/d3/d3multiattributevalues/metadata.php new file mode 100644 index 0000000..60d05d3 --- /dev/null +++ b/copy_this/modules/d3/d3multiattributevalues/metadata.php @@ -0,0 +1,60 @@ + + * @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 new file mode 100644 index 0000000..8933983 --- /dev/null +++ b/copy_this/modules/d3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_ajax_multivalues.php @@ -0,0 +1,70 @@ + + * @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/copy_this/modules/d3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_multivalues.php b/copy_this/modules/d3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_multivalues.php new file mode 100644 index 0000000..f24c7b6 --- /dev/null +++ b/copy_this/modules/d3/d3multiattributevalues/modules/controllers/admin/d3_article_attribute_multivalues.php @@ -0,0 +1,37 @@ + + * @link http://www.oxidmodule.com + */ + +class d3_article_attribute_multivalues extends d3_article_attribute_multivalues_parent +{ + /** + * Collects article attributes and selection lists, passes them to Smarty engine, + * returns name of template file "article_attribute.tpl". + * + * @return string + */ + public function render() + { + $sTplName = parent::render(); + + $iAoc = oxRegistry::getConfig()->getRequestParameter("aoc"); + + if ($iAoc == 1) { + $sTplName = "d3_article_attribute_multivalues.tpl"; + } + + return $sTplName; + } +} diff --git a/copy_this/modules/d3/d3multiattributevalues/modules/models/d3_oxattributelist_multivalues.php b/copy_this/modules/d3/d3multiattributevalues/modules/models/d3_oxattributelist_multivalues.php new file mode 100644 index 0000000..b04a572 --- /dev/null +++ b/copy_this/modules/d3/d3multiattributevalues/modules/models/d3_oxattributelist_multivalues.php @@ -0,0 +1,38 @@ + + * @link http://www.oxidmodule.com + */ + +class d3_oxattributelist_multivalues extends d3_oxattributelist_multivalues_parent +{ + /** + * Assign data from array to list + * + * @param array $aData data for list + */ + public function assignArray($aData) + { + $this->clear(); + if (count($aData)) { + + $oSaved = clone $this->getBaseObject(); + + foreach ($aData as $aItem) { + $oListObject = clone $oSaved; + $this->_assignElement($oListObject, $aItem); + $this->_aArray[] = $oListObject; + } + } + } +} diff --git a/copy_this/modules/d3/d3multiattributevalues/views/admin/tpl/d3_article_attribute_multivalues.tpl b/copy_this/modules/d3/d3multiattributevalues/views/admin/tpl/d3_article_attribute_multivalues.tpl new file mode 100644 index 0000000..6533e2f --- /dev/null +++ b/copy_this/modules/d3/d3multiattributevalues/views/admin/tpl/d3_article_attribute_multivalues.tpl @@ -0,0 +1,120 @@ +[{include file="popups/headitem.tpl" title="GENERAL_ADMIN_TITLE"|oxmultilangassign}] + + + + + + + + + + + + + + + + + + + + + + + + + + +
[{oxmultilang ident="GENERAL_AJAX_DESCRIPTION"}]
[{oxmultilang ident="GENERAL_FILTERING"}]

[{oxmultilang ident="ARTICLE_ATTRIBUTE_NOATTRIBUTE"}][{oxmultilang ident="ARTICLE_ATTRIBUTE_ITEMSATTRIBUTE"}][{oxmultilang ident="ARTICLE_ATTRIBUTE_SELECTONEATTR"}]
+ + + + diff --git a/setup+doku/usage.txt b/setup+doku/usage.txt new file mode 100644 index 0000000..72a68d0 --- /dev/null +++ b/setup+doku/usage.txt @@ -0,0 +1,8 @@ +entwickelt in EE 5.2.1 + +ermöglicht, im Admin ein Attribute einem Artikel mehrfach mit unterschiedlichen Werten zuzuordnen + +Artikel A +-> Farbe "rot" +-> Farbe "grün" +-> Material "Stoff" \ No newline at end of file