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