deliveryset_main.php

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