article_variant.php

Go to the documentation of this file.
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         // all selectlists
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             // load object
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             // load object in other languages
00044             $oOtherLang = $oArticle->getAvailableInLangs();
00045             if (!isset($oOtherLang[ $this->_iEditLang])) {
00046                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
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                 // A. disable variant information editing for variant
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         //if (!oxConfig::getParameter( "editlanguage"))
00096         //    oxSession::setVar( "editlanguage", $this->_iEditLang);
00097 
00098         if (!isset($soxId) && !isset($aParams)) {
00099             $soxId      = oxConfig::getParameter( "voxid");
00100             $aParams    = oxConfig::getParameter( "editval");
00101         }
00102 
00103         // checkbox handling
00104         if ( !isset( $aParams['oxarticles__oxactive']))
00105             $aParams['oxarticles__oxactive'] = 0;
00106 
00107             // shopid
00108             $sShopID = oxSession::getVar( "actshop");
00109             $aParams['oxarticles__oxshopid'] = $sShopID;
00110 
00111         // varianthandling
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         //TODO: solve this from lazy loading point of view
00122         //acessing main fields for lazy loading mechnism to iniatialise them
00123         $oArticle->oxarticles__oxvarselect->value;
00124         $oArticle->oxarticles__oxartnum->value;
00125         $oArticle->oxarticles__oxprice->value;
00126         $oArticle->oxarticles__oxstock->value;
00127         $oArticle->oxarticles__oxshopid->value;
00128         $oArticle->oxarticles__oxshopincl->value;
00129         $oArticle->oxarticles__oxshopexcl->value;*/
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             //echo $aParams['oxarticles__oxartnum']."---";
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         //if (!oxConfig::getParameter( "editlanguage"))
00186         //    oxSession::setVar( "editlanguage",$this->_iEditLang);
00187 
00188         $soxId   = oxConfig::getParameter( "oxid");
00189         $aParams = oxConfig::getParameter( "editval");
00190 
00191 
00192 
00193             // shopid
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         //$aParams = $oArticle->ConvertNameArray2Idx( $aParams);
00203 
00204         $oArticle->setLanguage(0);
00205         $oArticle->assign( $aParams);
00206         $oArticle->setLanguage($this->_iEditLang);
00207 
00208         $oArticle->save();
00209         //$oArticle->SetLanguage(oxConfig::getParameter( "editlanguage"));
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 }

Generated on Mon Oct 26 20:07:15 2009 for OXID eShop CE by  doxygen 1.5.5