00001 <?php
00002
00008 class Article_Variant extends oxAdminDetails
00009 {
00016 public function render()
00017 {
00018 parent::render();
00019
00020 $soxId = oxConfig::getParameter( "oxid");
00021 $sSLViewName = getViewName('oxselectlist');
00022
00023
00024 $oAllSel = oxNew( "oxlist");
00025 $oAllSel->init( "oxselectlist");
00026 $sQ = "select * from $sSLViewName";
00027 $oAllSel->selectString( $sQ);
00028 $this->_aViewData["allsel"] = $oAllSel;
00029
00030 $oArticle = oxNew( "oxarticle");
00031 $this->_aViewData["edit"] = $oArticle;
00032
00033 if ( $soxId != "-1" && isset( $soxId)) {
00034
00035 $oArticle->loadInLang( $this->_iEditLang, $soxId );
00036
00037
00038 $_POST["language"] = $_GET["language"] = $this->_iEditLang;
00039 $oVariants = $oArticle->getAdminVariants( $this->_iEditLang);
00040
00041 $this->_aViewData["mylist"] = $oVariants;
00042
00043
00044 $oOtherLang = $oArticle->getAvailableInLangs();
00045 if (!isset($oOtherLang[ $this->_iEditLang])) {
00046
00047 $oArticle->loadInLang( key($oOtherLang), $soxId );
00048 }
00049
00050 foreach ( $oOtherLang as $id => $language) {
00051 $oLang= new oxStdClass();
00052 $oLang->sLangDesc = $language;
00053 $oLang->selected = ($id == $this->_iEditLang);
00054 $this->_aViewData["otherlang"][$id] = clone $oLang;
00055 }
00056
00057 if ( $oArticle->oxarticles__oxparentid->value) {
00058 $oParentArticle = oxNew( "oxarticle");
00059 $oParentArticle->load( $oArticle->oxarticles__oxparentid->value);
00060 $this->_aViewData["parentarticle"] = $oParentArticle;
00061 $this->_aViewData["oxparentid"] = $oArticle->oxarticles__oxparentid->value;
00062 $this->_aViewData["issubvariant"] = 1;
00063
00064 $this->_aViewData["readonly"] = 1;
00065 }
00066 $this->_aViewData["editlanguage"] = $this->_iEditLang;
00067
00068 $aLang = array_diff (oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00069 if ( count( $aLang))
00070 $this->_aViewData["posslang"] = $aLang;
00071
00072 foreach ( $oOtherLang as $id => $language) {
00073 $oLang= new oxStdClass();
00074 $oLang->sLangDesc = $language;
00075 $oLang->selected = ($id == $this->_iEditLang);
00076 $this->_aViewData["otherlang"][$id] = $oLang;
00077 }
00078 }
00079
00080 return "article_variant.tpl";
00081 }
00082
00091 public function savevariant($soxId = null, $aParams = null)
00092 {
00093 $myConfig = $this->getConfig();
00094
00095
00096
00097
00098 if (!isset($soxId) && !isset($aParams)) {
00099 $soxId = oxConfig::getParameter( "voxid");
00100 $aParams = oxConfig::getParameter( "editval");
00101 }
00102
00103
00104 if ( !isset( $aParams['oxarticles__oxactive']))
00105 $aParams['oxarticles__oxactive'] = 0;
00106
00107
00108 $sShopID = oxSession::getVar( "actshop");
00109 $aParams['oxarticles__oxshopid'] = $sShopID;
00110
00111
00112 $soxparentId = oxConfig::getParameter( "oxid");
00113 if ( isset( $soxparentId) && $soxparentId && $soxparentId != "-1")
00114 $aParams['oxarticles__oxparentid'] = $soxparentId;
00115 else
00116 unset( $aParams['oxarticles__oxparentid']);
00117
00118 $oArticle = oxNew( "oxarticle");
00119
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131 if ( $soxId != "-1") {
00132 $oArticle->loadInLang( $this->_iEditLang, $soxId );
00133 }
00134
00135
00136 $oArticle->setLanguage(0);
00137 $oArticle->assign( $aParams);
00138 $oArticle->setLanguage($this->_iEditLang);
00139
00140
00141 $oArticle->save();
00142
00143 $oArticle->setLanguage( $this->_iEditLang);
00144 }
00145
00151 public function savevariants()
00152 {
00153 $myConfig = $this->getConfig();
00154
00155
00156 $aParams = oxConfig::getParameter( "editval");
00157
00158 if (is_array($aParams))
00159 foreach($aParams as $soxId => $aVarParams)
00160 $this->savevariant($soxId, $aVarParams);
00161
00162 }
00163
00169 public function deleteVariant()
00170 {
00171
00172
00173 $soxId = oxConfig::getParameter( "voxid");
00174 $oDelete = oxNew( "oxarticle" );
00175 $oDelete->delete( $soxId);
00176 }
00177
00183 public function changename()
00184 {
00185
00186
00187
00188 $soxId = oxConfig::getParameter( "oxid");
00189 $aParams = oxConfig::getParameter( "editval");
00190
00191
00192
00193
00194 $sShopID = oxSession::getVar( "actshop");
00195 $aParams['oxarticles__oxshopid'] = $sShopID;
00196
00197 $oArticle = oxNew( "oxarticle");
00198
00199 if ( $soxId != "-1")
00200 $oArticle->loadInLang( $this->_iEditLang, $soxId );
00201
00202
00203
00204 $oArticle->setLanguage(0);
00205 $oArticle->assign( $aParams);
00206 $oArticle->setLanguage($this->_iEditLang);
00207
00208 $oArticle->save();
00209
00210 $oArticle->setLanguage( $this->_iEditLang);
00211 }
00212
00213
00218 public function addsel()
00219 {
00220 $myConfig = $this->getConfig();
00221
00222 $aSels = oxConfig::getParameter("allsel");
00223 $sParentID = oxConfig::getParameter("oxid");
00224
00225 $oArticle = oxNew("oxarticle");
00226 $oArticle->setEnableMultilang(false);
00227 $oArticle->load($sParentID);
00228
00229
00230
00231 if ($aSels) {
00232 $oVariantHandler = oxNew("oxVariantHandler");
00233 $oVariantHandler->genVariantFromSell( $aSels, $oArticle );
00234 }
00235 }
00236 }