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 ( oxLang::getInstance()->getLanguageNames(), $oOtherLang );
00040             if ( count( $aLang))
00041                 $this->_aViewData["posslang"] = $aLang;
00042 
00043             foreach ( $oOtherLang as $id => $language) {
00044                 $oLang= new oxStdClass();
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 
00053             $aColumns = array();
00054             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00055             $this->_aViewData['oxajax'] = $aColumns;
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 = oxConfig::getParameter( "editval");
00074 
00075             // shopid
00076             $sShopID = oxSession::getVar( "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         // checkbox handling
00085         if ( !isset( $aParams['oxdeliveryset__oxactive']))
00086             $aParams['oxdeliveryset__oxactive'] = 0;
00087 
00088 
00089         //$aParams = $oDelSet->ConvertNameArray2Idx( $aParams);
00090         $oDelSet->setLanguage(0);
00091         $oDelSet->assign( $aParams);
00092         $oDelSet->setLanguage($this->_iEditLang);
00093         $oDelSet = oxUtilsFile::getInstance()->processFiles( $oDelSet );
00094         $oDelSet->save();
00095 
00096         // set oxid if inserted
00097         $this->setEditObjectId( $oDelSet->getId() );
00098     }
00099 
00105     public function saveinnlang()
00106     {
00107         $soxId = $this->getEditObjectId();
00108         $aParams = oxConfig::getParameter( "editval");
00109         // checkbox handling
00110         if( !isset( $aParams['oxdeliveryset__oxactive']))
00111             $aParams['oxdeliveryset__oxactive'] = 0;
00112 
00113             // shopid
00114             $sShopID = oxSession::getVar( "actshop");
00115             $aParams['oxdeliveryset__oxshopid'] = $sShopID;
00116         $oDelSet = oxNew( "oxdeliveryset" );
00117 
00118         if ( $soxId != "-1")
00119             $oDelSet->loadInLang( $this->_iEditLang, $soxId );
00120         else
00121             $aParams['oxdeliveryset__oxid'] = null;
00122         //$aParams = $oDelSet->ConvertNameArray2Idx( $aParams);
00123 
00124         $oDelSet->setLanguage(0);
00125         $oDelSet->assign( $aParams);
00126 
00127 
00128         // apply new language
00129         $oDelSet->setLanguage( oxConfig::getParameter( "new_lang" ) );
00130         $oDelSet->save();
00131 
00132         // set oxid if inserted
00133         $this->setEditObjectId( $oDelSet->getId() );
00134     }
00135 }