OXID eShop CE  4.9.9
 All Classes Files Functions Variables Pages
payment_main.php
Go to the documentation of this file.
1 <?php
2 
9 {
10 
14  protected $_aFieldArray = null;
15 
23  public function render()
24  {
26 
27  // remove itm from list
28  unset($this->_aViewData["sumtype"][2]);
29 
30  // all usergroups
31  $oGroups = oxNew("oxlist");
32  $oGroups->init("oxgroups");
33  $oGroups->selectString("select * from " . getViewName("oxgroups", $this->_iEditLang));
34 
35  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
36  if ($soxId != "-1" && isset($soxId)) {
37  // load object
38  $oPayment = oxNew("oxpayment");
39  $oPayment->loadInLang($this->_iEditLang, $soxId);
40 
41  $oOtherLang = $oPayment->getAvailableInLangs();
42  if (!isset($oOtherLang[$this->_iEditLang])) {
43  // echo "language entry doesn't exist! using: ".key($oOtherLang);
44  $oPayment->loadInLang(key($oOtherLang), $soxId);
45  }
46  $this->_aViewData["edit"] = $oPayment;
47 
48  // remove already created languages
49  $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
50  if (count($aLang)) {
51  $this->_aViewData["posslang"] = $aLang;
52  }
53 
54  foreach ($oOtherLang as $id => $language) {
55  $oLang = new stdClass();
56  $oLang->sLangDesc = $language;
57  $oLang->selected = ($id == $this->_iEditLang);
58  $this->_aViewData["otherlang"][$id] = clone $oLang;
59  }
60 
61  // #708
62  $this->_aViewData['aFieldNames'] = oxRegistry::getUtils()->assignValuesFromText($oPayment->oxpayments__oxvaldesc->value);
63  }
64 
65  if (oxRegistry::getConfig()->getRequestParameter("aoc")) {
66  $oPaymentMainAjax = oxNew('payment_main_ajax');
67  $this->_aViewData['oxajax'] = $oPaymentMainAjax->getColumns();
68 
69  return "popups/payment_main.tpl";
70  }
71 
72  $this->_aViewData["editor"] = $this->_generateTextEditor("100%", 300, $oPayment, "oxpayments__oxlongdesc");
73 
74  return "payment_main.tpl";
75  }
76 
82  public function save()
83  {
84 
85  parent::save();
86 
87  $soxId = $this->getEditObjectId();
88  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
89  // checkbox handling
90  if (!isset($aParams['oxpayments__oxactive'])) {
91  $aParams['oxpayments__oxactive'] = 0;
92  }
93  if (!isset($aParams['oxpayments__oxchecked'])) {
94  $aParams['oxpayments__oxchecked'] = 0;
95  }
96 
97  $oPayment = oxNew("oxpayment");
98 
99  if ($soxId != "-1") {
100  $oPayment->loadInLang($this->_iEditLang, $soxId);
101  } else {
102  $aParams['oxpayments__oxid'] = null;
103  //$aParams = $oPayment->ConvertNameArray2Idx( $aParams);
104  }
105 
106  $oPayment->setLanguage(0);
107  $oPayment->assign($aParams);
108 
109  // setting add sum calculation rules
110  $aRules = (array) oxRegistry::getConfig()->getRequestParameter("oxpayments__oxaddsumrules");
111  // if sum eqals 0, show notice, that default value will be used.
112  if (empty($aRules)) {
113  $this->_aViewData["noticeoxaddsumrules"] = 1;
114  }
115  $oPayment->oxpayments__oxaddsumrules = new oxField(array_sum($aRules));
116 
117 
118  //#708
119  if (!is_array($this->_aFieldArray)) {
120  $this->_aFieldArray = oxRegistry::getUtils()->assignValuesFromText($oPayment->oxpayments__oxvaldesc->value);
121  }
122 
123  // build value
124  $sValdesc = "";
125  foreach ($this->_aFieldArray as $oField) {
126  $sValdesc .= $oField->name . "__@@";
127  }
128 
129  $oPayment->oxpayments__oxvaldesc = new oxField($sValdesc, oxField::T_RAW);
130  $oPayment->setLanguage($this->_iEditLang);
131  $oPayment->save();
132 
133  // set oxid if inserted
134  $this->setEditObjectId($oPayment->getId());
135  }
136 
142  public function saveinnlang()
143  {
144 
145  $soxId = $this->getEditObjectId();
146  $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
147 
148  // shopid
149  $sShopID = oxRegistry::getSession()->getVariable("actshop");
150  $aParams['oxpayments__oxshopid'] = $sShopID;
151  $oObj = oxNew("oxpayment");
152 
153  if ($soxId != "-1") {
154  $oObj->loadInLang($this->_iEditLang, $soxId);
155  } else {
156  $aParams['oxpayments__oxid'] = null;
157  //$aParams = $oObj->ConvertNameArray2Idx( $aParams);
158  }
159 
160  $oObj->setLanguage(0);
161  $oObj->assign($aParams);
162 
163  // apply new language
164  $oObj->setLanguage(oxRegistry::getConfig()->getRequestParameter("new_lang"));
165  $oObj->save();
166 
167  // set oxid if inserted
168  $this->setEditObjectId($oObj->getId());
169  }
170 
176  public function delFields()
177  {
178 
179  $oPayment = oxNew("oxpayment");
180  if ($oPayment->loadInLang($this->_iEditLang, $this->getEditObjectId())) {
181 
182  $aDelFields = oxRegistry::getConfig()->getRequestParameter("aFields");
183  $this->_aFieldArray = oxRegistry::getUtils()->assignValuesFromText($oPayment->oxpayments__oxvaldesc->value);
184 
185  if (is_array($aDelFields) && count($aDelFields)) {
186  foreach ($aDelFields as $sDelField) {
187  foreach ($this->_aFieldArray as $sKey => $oField) {
188  if ($oField->name == $sDelField) {
189  unset($this->_aFieldArray[$sKey]);
190  break;
191  }
192  }
193  }
194  $this->save();
195  }
196  }
197  }
198 
204  public function addField()
205  {
206 
207  $oPayment = oxNew("oxpayment");
208  if ($oPayment->loadInLang($this->_iEditLang, $this->getEditObjectId())) {
209 
210  $this->_aFieldArray = oxRegistry::getUtils()->assignValuesFromText($oPayment->oxpayments__oxvaldesc->value);
211 
212  $oField = new stdClass();
213  $oField->name = oxRegistry::getConfig()->getRequestParameter("sAddField");
214 
215  $this->_aFieldArray[] = $oField;
216 
217  $this->save();
218  }
219  }
220 }