country_main.php

Go to the documentation of this file.
00001 <?php
00002 
00008 class Country_Main extends oxAdminDetails
00009 {
00017     public function render()
00018     {
00019         $myConfig = $this->getConfig();
00020 
00021 
00022         parent::render();
00023 
00024         $soxId = oxConfig::getParameter( "oxid");
00025         // check if we right now saved a new entry
00026         $sSavedID = oxConfig::getParameter( "saved_oxid");
00027         if ( ($soxId == "-1" || !isset( $soxId)) && isset( $sSavedID) ) {
00028             $soxId = $sSavedID;
00029             oxSession::deleteVar( "saved_oxid");
00030             $this->_aViewData["oxid"] =  $soxId;
00031             // for reloading upper frame
00032             $this->_aViewData["updatelist"] =  "1";
00033         }
00034 
00035         if ( $soxId != "-1" && isset( $soxId)) {
00036             // load object
00037             $oCountry = oxNew( "oxcountry" );
00038             $oCountry->loadInLang( $this->_iEditLang, $soxId );
00039 
00040             if ($oCountry->isForeignCountry()) {
00041                 $this->_aViewData["blForeignCountry"] = true;
00042             } else {
00043                 $this->_aViewData["blForeignCountry"] = false;
00044             }
00045 
00046             $oOtherLang = $oCountry->getAvailableInLangs();
00047             if (!isset($oOtherLang[$this->_iEditLang])) {
00048                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00049                 $oCountry->loadInLang( key($oOtherLang), $soxId );
00050             }
00051             $this->_aViewData["edit"] =  $oCountry;
00052 
00053             // remove already created languages
00054             $aLang = array_diff (oxLang::getInstance()->getLanguageNames(), $oOtherLang );
00055             if ( count( $aLang))
00056                 $this->_aViewData["posslang"] = $aLang;
00057 
00058             foreach ( $oOtherLang as $id => $language) {
00059                 $oLang= new oxStdClass();
00060                 $oLang->sLangDesc = $language;
00061                 $oLang->selected = ($id == $this->_iEditLang);
00062                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00063             }
00064         } else {
00065             $this->_aViewData["blForeignCountry"] = true;
00066         }
00067 
00068         return "country_main.tpl";
00069     }
00070 
00076     public function save()
00077     {
00078         $myConfig  = $this->getConfig();
00079 
00080 
00081         $soxId   = oxConfig::getParameter( "oxid");
00082         $aParams = oxConfig::getParameter( "editval" );
00083 
00084         if ( !isset( $aParams['oxcountry__oxactive']))
00085             $aParams['oxcountry__oxactive'] = 0;
00086 
00087         $oCountry = oxNew( "oxcountry" );
00088 
00089         if ( $soxId != "-1") {
00090             $oCountry->loadInLang( $this->_iEditLang, $soxId );
00091         } else {
00092             $aParams['oxcountry__oxid']        = null;
00093         }
00094 
00095         //$aParams = $oCountry->ConvertNameArray2Idx( $aParams);
00096         $oCountry->setLanguage(0);
00097         $oCountry->assign( $aParams );
00098         $oCountry->setLanguage($this->_iEditLang);
00099         $oCountry = oxUtilsFile::getInstance()->processFiles( $oCountry );
00100         $oCountry->save();
00101         $this->_aViewData["updatelist"] = "1";
00102 
00103         // set oxid if inserted
00104         if ( $soxId == "-1")
00105             oxSession::setVar( "saved_oxid", $oCountry->oxcountry__oxid->value);
00106 
00107         return $this->autosave();
00108     }
00109 
00115     public function saveinnlang()
00116     {
00117         $myConfig  = $this->getConfig();
00118 
00119 
00120         $soxId      = oxConfig::getParameter( "oxid");
00121         $aParams    = oxConfig::getParameter( "editval");
00122 
00123         if ( !isset( $aParams['oxcountry__oxactive']))
00124             $aParams['oxcountry__oxactive'] = 0;
00125 
00126         $oCountry = oxNew( "oxcountry" );
00127 
00128         if ( $soxId != "-1")
00129             $oCountry->loadInLang( $this->_iEditLang, $soxId );
00130         else
00131             $aParams['oxcountry__oxid'] = null;
00132         //$aParams = $oCountry->ConvertNameArray2Idx( $aParams);
00133         $oCountry->setLanguage(0);
00134         $oCountry->assign( $aParams);
00135         $oCountry->setLanguage($this->_iEditLang);
00136         $oCountry = oxUtilsFile::getInstance()->processFiles( $oCountry );
00137         $oCountry->save();
00138         $this->_aViewData["updatelist"] = "1";
00139 
00140         // set oxid if inserted
00141         if ( $soxId == "-1")
00142             oxSession::setVar( "saved_oxid", $oCountry->oxcountry__oxid->value);
00143 
00144         return $this->autosave();
00145     }
00146 }

Generated on Thu Dec 4 12:04:55 2008 for OXID eShop CE by  doxygen 1.5.5