OXID eShop CE  4.9.5
 All Classes Files Functions Variables Pages
deliveryset_main.php
Go to the documentation of this file.
1 <?php
2 
10 {
11 
18  public function render()
19  {
20  $myConfig = $this->getConfig();
22 
23  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
24  if ($soxId != "-1" && isset($soxId)) {
25  // load object
26  $odeliveryset = oxNew("oxdeliveryset");
27  $odeliveryset->loadInLang($this->_iEditLang, $soxId);
28 
29  $oOtherLang = $odeliveryset->getAvailableInLangs();
30 
31  if (!isset($oOtherLang[$this->_iEditLang])) {
32  // echo "language entry doesn't exist! using: ".key($oOtherLang);
33  $odeliveryset->loadInLang(key($oOtherLang), $soxId);
34  }
35 
36  $this->_aViewData["edit"] = $odeliveryset;
37 
38 
39  // remove already created languages
40  $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
41  if (count($aLang)) {
42  $this->_aViewData["posslang"] = $aLang;
43  }
44 
45  foreach ($oOtherLang as $id => $language) {
46  $oLang = new stdClass();
47  $oLang->sLangDesc = $language;
48  $oLang->selected = ($id == $this->_iEditLang);
49  $this->_aViewData["otherlang"][$id] = clone $oLang;
50  }
51  }
52 
53  if (oxRegistry::getConfig()->getRequestParameter("aoc")) {
54  $oDeliverysetMainAjax = oxNew('deliveryset_main_ajax');
55  $this->_aViewData['oxajax'] = $oDeliverysetMainAjax->getColumns();
56 
57  return "popups/deliveryset_main.tpl";
58  }
59 
60  return "deliveryset_main.tpl";
61  }
62 
68  public function save()
69  {
70  parent::save();
71 
72  $soxId = $this->getEditObjectId();
73  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
74 
75  // shopid
76  $sShopID = oxRegistry::getSession()->getVariable("actshop");
77  $aParams['oxdeliveryset__oxshopid'] = $sShopID;
78  $oDelSet = oxNew("oxdeliveryset");
79 
80  if ($soxId != "-1") {
81  $oDelSet->loadInLang($this->_iEditLang, $soxId);
82  } else {
83  $aParams['oxdeliveryset__oxid'] = null;
84  }
85 
86  // checkbox handling
87  if (!isset($aParams['oxdeliveryset__oxactive'])) {
88  $aParams['oxdeliveryset__oxactive'] = 0;
89  }
90 
91 
92  //$aParams = $oDelSet->ConvertNameArray2Idx( $aParams);
93  $oDelSet->setLanguage(0);
94  $oDelSet->assign($aParams);
95  $oDelSet->setLanguage($this->_iEditLang);
96  $oDelSet = oxRegistry::get("oxUtilsFile")->processFiles($oDelSet);
97  $oDelSet->save();
98 
99  // set oxid if inserted
100  $this->setEditObjectId($oDelSet->getId());
101  }
102 
108  public function saveinnlang()
109  {
110  $soxId = $this->getEditObjectId();
111  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
112  // checkbox handling
113  if (!isset($aParams['oxdeliveryset__oxactive'])) {
114  $aParams['oxdeliveryset__oxactive'] = 0;
115  }
116 
117  // shopid
118  $sShopID = oxRegistry::getSession()->getVariable("actshop");
119  $aParams['oxdeliveryset__oxshopid'] = $sShopID;
120  $oDelSet = oxNew("oxdeliveryset");
121 
122  if ($soxId != "-1") {
123  $oDelSet->loadInLang($this->_iEditLang, $soxId);
124  } else {
125  $aParams['oxdeliveryset__oxid'] = null;
126  //$aParams = $oDelSet->ConvertNameArray2Idx( $aParams);
127  }
128 
129  $oDelSet->setLanguage(0);
130  $oDelSet->assign($aParams);
131 
132 
133  // apply new language
134  $oDelSet->setLanguage(oxRegistry::getConfig()->getRequestParameter("new_lang"));
135  $oDelSet->save();
136 
137  // set oxid if inserted
138  $this->setEditObjectId($oDelSet->getId());
139  }
140 }