country_main.php

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

Generated on Wed May 13 13:25:50 2009 for OXID eShop CE by  doxygen 1.5.5