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         parent::save();
00071 
00072         $soxId = $this->getEditObjectId();
00073         $aParams = oxConfig::getParameter( "editval" );
00074 
00075         if ( !isset( $aParams['oxcountry__oxactive']))
00076             $aParams['oxcountry__oxactive'] = 0;
00077 
00078         $oCountry = oxNew( "oxcountry" );
00079 
00080         if ( $soxId != "-1") {
00081             $oCountry->loadInLang( $this->_iEditLang, $soxId );
00082         } else {
00083             $aParams['oxcountry__oxid']        = null;
00084         }
00085 
00086         //$aParams = $oCountry->ConvertNameArray2Idx( $aParams);
00087         $oCountry->setLanguage(0);
00088         $oCountry->assign( $aParams );
00089         $oCountry->setLanguage($this->_iEditLang);
00090         $oCountry = oxUtilsFile::getInstance()->processFiles( $oCountry );
00091         $oCountry->save();
00092 
00093         // set oxid if inserted
00094         $this->setEditObjectId( $oCountry->getId() );
00095     }
00096 
00102     public function saveinnlang()
00103     {
00104         $myConfig  = $this->getConfig();
00105 
00106 
00107         $soxId = $this->getEditObjectId();
00108         $aParams = oxConfig::getParameter( "editval");
00109 
00110         if ( !isset( $aParams['oxcountry__oxactive']))
00111             $aParams['oxcountry__oxactive'] = 0;
00112 
00113         $oCountry = oxNew( "oxcountry" );
00114 
00115         if ( $soxId != "-1")
00116             $oCountry->loadInLang( $this->_iEditLang, $soxId );
00117         else
00118             $aParams['oxcountry__oxid'] = null;
00119         //$aParams = $oCountry->ConvertNameArray2Idx( $aParams);
00120         $oCountry->setLanguage(0);
00121         $oCountry->assign( $aParams);
00122         $oCountry->setLanguage($this->_iEditLang);
00123 
00124         $oCountry->save();
00125 
00126         // set oxid if inserted
00127         $this->setEditObjectId( $oCountry->getId() );
00128     }
00129 }