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 = oxConfig::getParameter( "oxid");
00023         // check if we right now saved a new entry
00024         $sSavedID = oxConfig::getParameter( "saved_oxid");
00025         if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00026             $soxId = $sSavedID;
00027             oxSession::deleteVar( "saved_oxid");
00028             $this->_aViewData["oxid"] =  $soxId;
00029             // for reloading upper frame
00030             $this->_aViewData["updatelist"] =  "1";
00031         }
00032 
00033         if ( $soxId != "-1" && isset( $soxId)) {
00034             // load object
00035             $odeliveryset = oxNew( "oxdeliveryset" );
00036             $odeliveryset->loadInLang( $this->_iEditLang, $soxId );
00037 
00038             $oOtherLang = $odeliveryset->getAvailableInLangs();
00039 
00040             if (!isset($oOtherLang[$this->_iEditLang])) {
00041                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00042                 $odeliveryset->loadInLang( key($oOtherLang), $soxId );
00043             }
00044 
00045             $this->_aViewData["edit"] =  $odeliveryset;
00046 
00047 
00048             // remove already created languages
00049             $aLang = array_diff ( oxLang::getInstance()->getLanguageNames(), $oOtherLang );
00050             if ( count( $aLang))
00051                 $this->_aViewData["posslang"] = $aLang;
00052 
00053             foreach ( $oOtherLang as $id => $language) {
00054                 $oLang= new oxStdClass();
00055                 $oLang->sLangDesc = $language;
00056                 $oLang->selected = ($id == $this->_iEditLang);
00057                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00058             }
00059         }
00060 
00061         if ( oxConfig::getParameter("aoc") ) {
00062 
00063             $aColumns = array();
00064             include_once 'inc/'.strtolower(__CLASS__).'.inc.php';
00065             $this->_aViewData['oxajax'] = $aColumns;
00066 
00067             return "popups/deliveryset_main.tpl";
00068         }
00069 
00070         return "deliveryset_main.tpl";
00071     }
00072 
00078     public function save()
00079     {
00080 
00081         $soxId      = oxConfig::getParameter( "oxid");
00082         $aParams    = oxConfig::getParameter( "editval");
00083 
00084             // shopid
00085             $sShopID = oxSession::getVar( "actshop");
00086             $aParams['oxdeliveryset__oxshopid'] = $sShopID;
00087         $oDelSet = oxNew( "oxdeliveryset" );
00088 
00089         if ( $soxId != "-1")
00090             $oDelSet->loadInLang( $this->_iEditLang, $soxId );
00091         else
00092             $aParams['oxdeliveryset__oxid'] = null;
00093         // checkbox handling
00094         if ( !isset( $aParams['oxdeliveryset__oxactive']))
00095             $aParams['oxdeliveryset__oxactive'] = 0;
00096 
00097 
00098         //$aParams = $oDelSet->ConvertNameArray2Idx( $aParams);
00099         $oDelSet->setLanguage(0);
00100         $oDelSet->assign( $aParams);
00101         $oDelSet->setLanguage($this->_iEditLang);
00102         $oDelSet = oxUtilsFile::getInstance()->processFiles( $oDelSet );
00103         $oDelSet->save();
00104         $this->_aViewData["updatelist"] = "1";
00105 
00106         // set oxid if inserted
00107         if ( $soxId == "-1")
00108             oxSession::setVar( "saved_oxid", $oDelSet->oxdeliveryset__oxid->value);
00109     }
00110 
00116     public function saveinnlang()
00117     {
00118         $soxId      = oxConfig::getParameter( "oxid");
00119         $aParams    = oxConfig::getParameter( "editval");
00120         // checkbox handling
00121         if( !isset( $aParams['oxdeliveryset__oxactive']))
00122             $aParams['oxdeliveryset__oxactive'] = 0;
00123 
00124             // shopid
00125             $sShopID = oxSession::getVar( "actshop");
00126             $aParams['oxdeliveryset__oxshopid'] = $sShopID;
00127         $oDelSet = oxNew( "oxdeliveryset" );
00128 
00129         if ( $soxId != "-1")
00130             $oDelSet->loadInLang( $this->_iEditLang, $soxId );
00131         else
00132             $aParams['oxdeliveryset__oxid'] = null;
00133         //$aParams = $oDelSet->ConvertNameArray2Idx( $aParams);
00134 
00135         $oDelSet->setLanguage(0);
00136         $oDelSet->assign( $aParams);
00137 
00138 
00139         // apply new language
00140         $sNewLanguage = oxConfig::getParameter( "new_lang");
00141         $oDelSet->setLanguage( $sNewLanguage);
00142         $oDelSet->save();
00143         $this->_aViewData["updatelist"] = "1";
00144 
00145         // set for reload
00146         oxSession::setVar( "new_lang", $sNewLanguage);
00147 
00148         // set oxid if inserted
00149         if ( $soxId == "-1")
00150             oxSession::setVar( "saved_oxid", $oDelSet->oxdeliveryset__oxid->value);
00151     }
00152 }

Generated by  doxygen 1.6.2