deliveryset_main.php

Go to the documentation of this file.
00001 <?php
00002 
00009 class DeliverySet_Main extends oxAdminDetails
00010 {
00011 
00018     public function render()
00019     {
00020         $myConfig = $this->getConfig();
00021         parent::render();
00022 
00023         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00024         if ($soxId != "-1" && isset($soxId)) {
00025             // load object
00026             $odeliveryset = oxNew("oxdeliveryset");
00027             $odeliveryset->loadInLang($this->_iEditLang, $soxId);
00028 
00029             $oOtherLang = $odeliveryset->getAvailableInLangs();
00030 
00031             if (!isset($oOtherLang[$this->_iEditLang])) {
00032                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00033                 $odeliveryset->loadInLang(key($oOtherLang), $soxId);
00034             }
00035 
00036             $this->_aViewData["edit"] = $odeliveryset;
00037 
00038 
00039             // remove already created languages
00040             $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
00041             if (count($aLang)) {
00042                 $this->_aViewData["posslang"] = $aLang;
00043             }
00044 
00045             foreach ($oOtherLang as $id => $language) {
00046                 $oLang = new stdClass();
00047                 $oLang->sLangDesc = $language;
00048                 $oLang->selected = ($id == $this->_iEditLang);
00049                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00050             }
00051         }
00052 
00053         if (oxRegistry::getConfig()->getRequestParameter("aoc")) {
00054             $oDeliverysetMainAjax = oxNew('deliveryset_main_ajax');
00055             $this->_aViewData['oxajax'] = $oDeliverysetMainAjax->getColumns();
00056 
00057             return "popups/deliveryset_main.tpl";
00058         }
00059 
00060         return "deliveryset_main.tpl";
00061     }
00062 
00068     public function save()
00069     {
00070         parent::save();
00071 
00072         $soxId = $this->getEditObjectId();
00073         $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00074 
00075         // shopid
00076         $sShopID = oxRegistry::getSession()->getVariable("actshop");
00077         $aParams['oxdeliveryset__oxshopid'] = $sShopID;
00078         $oDelSet = oxNew("oxdeliveryset");
00079 
00080         if ($soxId != "-1") {
00081             $oDelSet->loadInLang($this->_iEditLang, $soxId);
00082         } else {
00083             $aParams['oxdeliveryset__oxid'] = null;
00084         }
00085 
00086         // checkbox handling
00087         if (!isset($aParams['oxdeliveryset__oxactive'])) {
00088             $aParams['oxdeliveryset__oxactive'] = 0;
00089         }
00090 
00091 
00092         //$aParams = $oDelSet->ConvertNameArray2Idx( $aParams);
00093         $oDelSet->setLanguage(0);
00094         $oDelSet->assign($aParams);
00095         $oDelSet->setLanguage($this->_iEditLang);
00096         $oDelSet = oxRegistry::get("oxUtilsFile")->processFiles($oDelSet);
00097         $oDelSet->save();
00098 
00099         // set oxid if inserted
00100         $this->setEditObjectId($oDelSet->getId());
00101     }
00102 
00108     public function saveinnlang()
00109     {
00110         $soxId = $this->getEditObjectId();
00111         $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00112         // checkbox handling
00113         if (!isset($aParams['oxdeliveryset__oxactive'])) {
00114             $aParams['oxdeliveryset__oxactive'] = 0;
00115         }
00116 
00117         // shopid
00118         $sShopID = oxRegistry::getSession()->getVariable("actshop");
00119         $aParams['oxdeliveryset__oxshopid'] = $sShopID;
00120         $oDelSet = oxNew("oxdeliveryset");
00121 
00122         if ($soxId != "-1") {
00123             $oDelSet->loadInLang($this->_iEditLang, $soxId);
00124         } else {
00125             $aParams['oxdeliveryset__oxid'] = null;
00126             //$aParams = $oDelSet->ConvertNameArray2Idx( $aParams);
00127         }
00128 
00129         $oDelSet->setLanguage(0);
00130         $oDelSet->assign($aParams);
00131 
00132 
00133         // apply new language
00134         $oDelSet->setLanguage(oxRegistry::getConfig()->getRequestParameter("new_lang"));
00135         $oDelSet->save();
00136 
00137         // set oxid if inserted
00138         $this->setEditObjectId($oDelSet->getId());
00139     }
00140 }