OXID eShop CE  4.8.10
 All Classes Files Functions Variables Pages
payment_country.php
Go to the documentation of this file.
1 <?php
2 
9 {
17  public function render()
18  {
19  $myConfig = $this->getConfig();
21 
22  // remove itm from list
23  unset( $this->_aViewData["sumtype"][2]);
24 
25  $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
26  if ( $soxId != "-1" && isset( $soxId)) {
27  // load object
28  $oPayment = oxNew( "oxpayment" );
29  $oPayment->loadInLang( $this->_iEditLang, $soxId );
30 
31  $oOtherLang = $oPayment->getAvailableInLangs();
32  if (!isset($oOtherLang[$this->_iEditLang])) {
33  // echo "language entry doesn't exist! using: ".key($oOtherLang);
34  $oPayment->loadInLang( key($oOtherLang), $soxId );
35  }
36  $this->_aViewData["edit"] = $oPayment;
37 
38  // remove already created languages
39  $aLang = array_diff ( oxRegistry::getLang()->getLanguageNames(), $oOtherLang );
40  if ( count( $aLang))
41  $this->_aViewData["posslang"] = $aLang;
42 
43  foreach ( $oOtherLang as $id => $language) {
44  $oLang= new stdClass();
45  $oLang->sLangDesc = $language;
46  $oLang->selected = ($id == $this->_iEditLang);
47  $this->_aViewData["otherlang"][$id] = clone $oLang;
48  }
49  }
50 
51  if ( oxConfig::getParameter("aoc") ) {
52  $oPaymentCountryAjax = oxNew( 'payment_country_ajax' );
53  $this->_aViewData['oxajax'] = $oPaymentCountryAjax->getColumns();
54 
55  return "popups/payment_country.tpl";
56  }
57  return "payment_country.tpl";
58  }
59 
65  public function addcountry()
66  {
67  $sOxId = $this->getEditObjectId();
68  $aChosenCntr = oxConfig::getParameter( "allcountries" );
69  if ( isset( $sOxId ) && $sOxId != "-1" && is_array( $aChosenCntr ) ) {
70  foreach ( $aChosenCntr as $sChosenCntr ) {
71  $oObject2Payment = oxNew( 'oxbase' );
72  $oObject2Payment->init( 'oxobject2payment' );
73  $oObject2Payment->oxobject2payment__oxpaymentid = new oxField( $sOxId );
74  $oObject2Payment->oxobject2payment__oxobjectid = new oxField( $sChosenCntr );
75  $oObject2Payment->oxobject2payment__oxtype = new oxField( "oxcountry" );
76  $oObject2Payment->save();
77  }
78  }
79  }
80 
86  public function removecountry()
87  {
88  $sOxId = $this->getEditObjectId();
89  $aChosenCntr = oxConfig::getParameter( "countries" );
90  if ( isset( $sOxId ) && $sOxId != "-1" && is_array( $aChosenCntr ) ) {
91  foreach ( $aChosenCntr as $sChosenCntr ) {
92  $oObject2Payment = oxNew( 'oxbase' );
93  $oObject2Payment->init( 'oxobject2payment' );
94  $oObject2Payment->delete( $sChosenCntr );
95  }
96  }
97  }
98 }