OXID eShop CE  4.9.9
 All Classes Files Functions Variables Pages
country_main.php
Go to the documentation of this file.
1 <?php
2 
8 {
9 
17  public function render()
18  {
19  $myConfig = $this->getConfig();
20 
21 
23 
24  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
25  if ($soxId != "-1" && isset($soxId)) {
26  // load object
27  $oCountry = oxNew("oxcountry");
28  $oCountry->loadInLang($this->_iEditLang, $soxId);
29 
30  if ($oCountry->isForeignCountry()) {
31  $this->_aViewData["blForeignCountry"] = true;
32  } else {
33  $this->_aViewData["blForeignCountry"] = false;
34  }
35 
36  $oOtherLang = $oCountry->getAvailableInLangs();
37  if (!isset($oOtherLang[$this->_iEditLang])) {
38  // echo "language entry doesn't exist! using: ".key($oOtherLang);
39  $oCountry->loadInLang(key($oOtherLang), $soxId);
40  }
41  $this->_aViewData["edit"] = $oCountry;
42 
43  // remove already created languages
44  $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
45  if (count($aLang)) {
46  $this->_aViewData["posslang"] = $aLang;
47  }
48 
49  foreach ($oOtherLang as $id => $language) {
50  $oLang = new stdClass();
51  $oLang->sLangDesc = $language;
52  $oLang->selected = ($id == $this->_iEditLang);
53  $this->_aViewData["otherlang"][$id] = clone $oLang;
54  }
55  } else {
56  $this->_aViewData["blForeignCountry"] = true;
57  }
58 
59  return "country_main.tpl";
60  }
61 
67  public function save()
68  {
69  $myConfig = $this->getConfig();
70 
71 
72  parent::save();
73 
74  $soxId = $this->getEditObjectId();
75  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
76 
77  if (!isset($aParams['oxcountry__oxactive'])) {
78  $aParams['oxcountry__oxactive'] = 0;
79  }
80 
81  $oCountry = oxNew("oxcountry");
82 
83  if ($soxId != "-1") {
84  $oCountry->loadInLang($this->_iEditLang, $soxId);
85  } else {
86  $aParams['oxcountry__oxid'] = null;
87  }
88 
89  //$aParams = $oCountry->ConvertNameArray2Idx( $aParams);
90  $oCountry->setLanguage(0);
91  $oCountry->assign($aParams);
92  $oCountry->setLanguage($this->_iEditLang);
93  $oCountry = oxRegistry::get("oxUtilsFile")->processFiles($oCountry);
94  $oCountry->save();
95 
96  // set oxid if inserted
97  $this->setEditObjectId($oCountry->getId());
98  }
99 
105  public function saveinnlang()
106  {
107  $myConfig = $this->getConfig();
108 
109 
110  $soxId = $this->getEditObjectId();
111  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
112 
113  if (!isset($aParams['oxcountry__oxactive'])) {
114  $aParams['oxcountry__oxactive'] = 0;
115  }
116 
117  $oCountry = oxNew("oxcountry");
118 
119  if ($soxId != "-1") {
120  $oCountry->loadInLang($this->_iEditLang, $soxId);
121  } else {
122  $aParams['oxcountry__oxid'] = null;
123  //$aParams = $oCountry->ConvertNameArray2Idx( $aParams);
124  }
125 
126  $oCountry->setLanguage(0);
127  $oCountry->assign($aParams);
128  $oCountry->setLanguage($this->_iEditLang);
129 
130  $oCountry->save();
131 
132  // set oxid if inserted
133  $this->setEditObjectId($oCountry->getId());
134  }
135 }