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 = $this->_aViewData["oxid"] = $this->getEditObjectId();
00024         if ( $soxId != "-1" && isset( $soxId)) {
00025             // load object
00026             $oCountry = oxNew( "oxcountry" );
00027             $oCountry->loadInLang( $this->_iEditLang, $soxId );
00028 
00029             if ($oCountry->isForeignCountry()) {
00030                 $this->_aViewData["blForeignCountry"] = true;
00031             } else {
00032                 $this->_aViewData["blForeignCountry"] = false;
00033             }
00034 
00035             $oOtherLang = $oCountry->getAvailableInLangs();
00036             if (!isset($oOtherLang[$this->_iEditLang])) {
00037                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00038                 $oCountry->loadInLang( key($oOtherLang), $soxId );
00039             }
00040             $this->_aViewData["edit"] =  $oCountry;
00041 
00042             // remove already created languages
00043             $aLang = array_diff (oxLang::getInstance()->getLanguageNames(), $oOtherLang );
00044             if ( count( $aLang))
00045                 $this->_aViewData["posslang"] = $aLang;
00046 
00047             foreach ( $oOtherLang as $id => $language) {
00048                 $oLang= new oxStdClass();
00049                 $oLang->sLangDesc = $language;
00050                 $oLang->selected = ($id == $this->_iEditLang);
00051                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00052             }
00053         } else {
00054             $this->_aViewData["blForeignCountry"] = true;
00055         }
00056 
00057         return "country_main.tpl";
00058     }
00059 
00065     public function save()
00066     {
00067         $myConfig  = $this->getConfig();
00068 
00069 
00070         $soxId = $this->getEditObjectId();
00071         $aParams = oxConfig::getParameter( "editval" );
00072 
00073         if ( !isset( $aParams['oxcountry__oxactive']))
00074             $aParams['oxcountry__oxactive'] = 0;
00075 
00076         $oCountry = oxNew( "oxcountry" );
00077 
00078         if ( $soxId != "-1") {
00079             $oCountry->loadInLang( $this->_iEditLang, $soxId );
00080         } else {
00081             $aParams['oxcountry__oxid']        = null;
00082         }
00083 
00084         //$aParams = $oCountry->ConvertNameArray2Idx( $aParams);
00085         $oCountry->setLanguage(0);
00086         $oCountry->assign( $aParams );
00087         $oCountry->setLanguage($this->_iEditLang);
00088         $oCountry = oxUtilsFile::getInstance()->processFiles( $oCountry );
00089         $oCountry->save();
00090 
00091         // set oxid if inserted
00092         $this->setEditObjectId( $oCountry->getId() );
00093     }
00094 
00100     public function saveinnlang()
00101     {
00102         $myConfig  = $this->getConfig();
00103 
00104 
00105         $soxId = $this->getEditObjectId();
00106         $aParams = oxConfig::getParameter( "editval");
00107 
00108         if ( !isset( $aParams['oxcountry__oxactive']))
00109             $aParams['oxcountry__oxactive'] = 0;
00110 
00111         $oCountry = oxNew( "oxcountry" );
00112 
00113         if ( $soxId != "-1")
00114             $oCountry->loadInLang( $this->_iEditLang, $soxId );
00115         else
00116             $aParams['oxcountry__oxid'] = null;
00117         //$aParams = $oCountry->ConvertNameArray2Idx( $aParams);
00118         $oCountry->setLanguage(0);
00119         $oCountry->assign( $aParams);
00120         $oCountry->setLanguage($this->_iEditLang);
00121 
00122         $oCountry->save();
00123 
00124         // set oxid if inserted
00125         $this->setEditObjectId( $oCountry->getId() );
00126     }
00127 }