country_main.php

Go to the documentation of this file.
00001 <?php
00002 
00007 class Country_Main extends oxAdminDetails
00008 {
00009 
00017     public function render()
00018     {
00019         $myConfig = $this->getConfig();
00020 
00021 
00022         parent::render();
00023 
00024         $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00025         if ($soxId != "-1" && isset($soxId)) {
00026             // load object
00027             $oCountry = oxNew("oxcountry");
00028             $oCountry->loadInLang($this->_iEditLang, $soxId);
00029 
00030             if ($oCountry->isForeignCountry()) {
00031                 $this->_aViewData["blForeignCountry"] = true;
00032             } else {
00033                 $this->_aViewData["blForeignCountry"] = false;
00034             }
00035 
00036             $oOtherLang = $oCountry->getAvailableInLangs();
00037             if (!isset($oOtherLang[$this->_iEditLang])) {
00038                 // echo "language entry doesn't exist! using: ".key($oOtherLang);
00039                 $oCountry->loadInLang(key($oOtherLang), $soxId);
00040             }
00041             $this->_aViewData["edit"] = $oCountry;
00042 
00043             // remove already created languages
00044             $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
00045             if (count($aLang)) {
00046                 $this->_aViewData["posslang"] = $aLang;
00047             }
00048 
00049             foreach ($oOtherLang as $id => $language) {
00050                 $oLang = new stdClass();
00051                 $oLang->sLangDesc = $language;
00052                 $oLang->selected = ($id == $this->_iEditLang);
00053                 $this->_aViewData["otherlang"][$id] = clone $oLang;
00054             }
00055         } else {
00056             $this->_aViewData["blForeignCountry"] = true;
00057         }
00058 
00059         return "country_main.tpl";
00060     }
00061 
00067     public function save()
00068     {
00069         $myConfig = $this->getConfig();
00070 
00071 
00072         parent::save();
00073 
00074         $soxId = $this->getEditObjectId();
00075         $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00076 
00077         if (!isset($aParams['oxcountry__oxactive'])) {
00078             $aParams['oxcountry__oxactive'] = 0;
00079         }
00080 
00081         $oCountry = oxNew("oxcountry");
00082 
00083         if ($soxId != "-1") {
00084             $oCountry->loadInLang($this->_iEditLang, $soxId);
00085         } else {
00086             $aParams['oxcountry__oxid'] = null;
00087         }
00088 
00089         //$aParams = $oCountry->ConvertNameArray2Idx( $aParams);
00090         $oCountry->setLanguage(0);
00091         $oCountry->assign($aParams);
00092         $oCountry->setLanguage($this->_iEditLang);
00093         $oCountry = oxRegistry::get("oxUtilsFile")->processFiles($oCountry);
00094         $oCountry->save();
00095 
00096         // set oxid if inserted
00097         $this->setEditObjectId($oCountry->getId());
00098     }
00099 
00105     public function saveinnlang()
00106     {
00107         $myConfig = $this->getConfig();
00108 
00109 
00110         $soxId = $this->getEditObjectId();
00111         $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00112 
00113         if (!isset($aParams['oxcountry__oxactive'])) {
00114             $aParams['oxcountry__oxactive'] = 0;
00115         }
00116 
00117         $oCountry = oxNew("oxcountry");
00118 
00119         if ($soxId != "-1") {
00120             $oCountry->loadInLang($this->_iEditLang, $soxId);
00121         } else {
00122             $aParams['oxcountry__oxid'] = null;
00123             //$aParams = $oCountry->ConvertNameArray2Idx( $aParams);
00124         }
00125 
00126         $oCountry->setLanguage(0);
00127         $oCountry->assign($aParams);
00128         $oCountry->setLanguage($this->_iEditLang);
00129 
00130         $oCountry->save();
00131 
00132         // set oxid if inserted
00133         $this->setEditObjectId($oCountry->getId());
00134     }
00135 }