Go to the documentation of this file.00001 <?php
00002
00008 class Article_Variant extends oxAdminDetails
00009 {
00015 protected $_oProductParent = null;
00016
00023 public function render()
00024 {
00025 parent::render();
00026
00027 $soxId = $this->getEditObjectId();
00028 $sSLViewName = getViewName('oxselectlist');
00029
00030
00031 $oAllSel = oxNew( "oxlist");
00032 $oAllSel->init( "oxselectlist");
00033 $sQ = "select * from $sSLViewName";
00034 $oAllSel->selectString( $sQ);
00035 $this->_aViewData["allsel"] = $oAllSel;
00036
00037 $oArticle = oxNew( "oxarticle");
00038 $this->_aViewData["edit"] = $oArticle;
00039
00040 if ( $soxId != "-1" && isset( $soxId)) {
00041
00042 $oArticle->loadInLang( $this->_iEditLang, $soxId );
00043
00044
00045 $_POST["language"] = $_GET["language"] = $this->_iEditLang;
00046 $oVariants = $oArticle->getAdminVariants( $this->_iEditLang);
00047
00048 $this->_aViewData["mylist"] = $oVariants;
00049
00050
00051 $oOtherLang = $oArticle->getAvailableInLangs();
00052 if (!isset($oOtherLang[ $this->_iEditLang])) {
00053
00054 $oArticle->loadInLang( key($oOtherLang), $soxId );
00055 }
00056
00057 foreach ( $oOtherLang as $id => $language) {
00058 $oLang= new oxStdClass();
00059 $oLang->sLangDesc = $language;
00060 $oLang->selected = ($id == $this->_iEditLang);
00061 $this->_aViewData["otherlang"][$id] = clone $oLang;
00062 }
00063
00064 if ( $oArticle->oxarticles__oxparentid->value) {
00065 $this->_aViewData["parentarticle"] = $this->_getProductParent( $oArticle->oxarticles__oxparentid->value );
00066 $this->_aViewData["oxparentid"] = $oArticle->oxarticles__oxparentid->value;
00067 $this->_aViewData["issubvariant"] = 1;
00068
00069 $this->_aViewData["readonly"] = 1;
00070 }
00071 $this->_aViewData["editlanguage"] = $this->_iEditLang;
00072
00073 $aLang = array_diff (oxLang::getInstance()->getLanguageNames(), $oOtherLang);
00074 if ( count( $aLang))
00075 $this->_aViewData["posslang"] = $aLang;
00076
00077 foreach ( $oOtherLang as $id => $language) {
00078 $oLang= new oxStdClass();
00079 $oLang->sLangDesc = $language;
00080 $oLang->selected = ($id == $this->_iEditLang);
00081 $this->_aViewData["otherlang"][$id] = $oLang;
00082 }
00083 }
00084
00085 return "article_variant.tpl";
00086 }
00087
00096 public function savevariant($sOXID = null, $aParams = null)
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
00109 $aParams['oxarticles__oxshopid'] = oxSession::getVar( "actshop" );
00110
00111
00112 $soxparentId = $this->getEditObjectId();
00113 if ( isset( $soxparentId) && $soxparentId && $soxparentId != "-1" ) {
00114 $aParams['oxarticles__oxparentid'] = $soxparentId;
00115 } else {
00116 unset( $aParams['oxarticles__oxparentid'] );
00117 }
00118
00119 $oArticle = oxNew( "oxarticle");
00120
00121
00122
00123
00124
00125
00126
00127
00128
00129
00130
00131
00132 if ( $sOXID != "-1" ) {
00133 $oArticle->loadInLang( $this->_iEditLang, $sOXID );
00134 }
00135
00136 $oArticle->setLanguage( 0 );
00137 $oArticle->assign( $aParams );
00138 $oArticle->setLanguage( $this->_iEditLang );
00139
00140
00141 $oArticle->save();
00142 }
00143
00151 protected function _getProductParent( $sParentId )
00152 {
00153 if ( $this->_oProductParent === null ||
00154 ( $this->_oProductParent !== false && $this->_oProductParent->getId() != $sParentId ) ) {
00155 $this->_oProductParent = false;
00156 $oProduct = oxNew( "oxarticle" );
00157 if ( $oProduct->load( $sParentId ) ) {
00158 $this->_oProductParent = $oProduct;
00159 }
00160 }
00161 return $this->_oProductParent;
00162 }
00163
00169 public function savevariants()
00170 {
00171
00172 $aParams = oxConfig::getParameter( "editval" );
00173 if ( is_array( $aParams ) ) {
00174 foreach ( $aParams as $soxId => $aVarParams ) {
00175 $this->savevariant( $soxId, $aVarParams );
00176 }
00177 }
00178
00179 }
00180
00186 public function deleteVariant()
00187 {
00188
00189
00190 $soxId = oxConfig::getParameter( "voxid" );
00191 $oDelete = oxNew( "oxarticle" );
00192 $oDelete->delete( $soxId );
00193 }
00194
00200 public function changename()
00201 {
00202 $soxId = $this->getEditObjectId();
00203
00204 $aParams = oxConfig::getParameter( "editval");
00205
00206
00207
00208 $aParams['oxarticles__oxshopid'] = oxSession::getVar( "actshop" );
00209
00210 $oArticle = oxNew( "oxarticle" );
00211 if ( $soxId != "-1") {
00212 $oArticle->loadInLang( $this->_iEditLang, $soxId );
00213 }
00214
00215 $oArticle->setLanguage( 0 );
00216 $oArticle->assign( $aParams);
00217 $oArticle->setLanguage( $this->_iEditLang );
00218 $oArticle->save();
00219 }
00220
00221
00227 public function addsel()
00228 {
00229 $oArticle = oxNew("oxarticle");
00230 $oArticle->setEnableMultilang( false );
00231 if ( $oArticle->load( $this->getEditObjectId() ) ) {
00232
00233
00234
00235 if ( $aSels = oxConfig::getParameter( "allsel" ) ) {
00236 $oVariantHandler = oxNew( "oxVariantHandler" );
00237 $oVariantHandler->genVariantFromSell( $aSels, $oArticle );
00238 }
00239 }
00240 }
00241 }