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