Go to the documentation of this file.00001 <?php
00002
00008 class Payment_Main extends oxAdminDetails
00009 {
00010
00014 protected $_aFieldArray = null;
00015
00023 public function render()
00024 {
00025 parent::render();
00026
00027
00028 unset($this->_aViewData["sumtype"][2]);
00029
00030
00031 $oGroups = oxNew("oxlist");
00032 $oGroups->init("oxgroups");
00033 $oGroups->selectString("select * from " . getViewName("oxgroups", $this->_iEditLang));
00034
00035 $soxId = $this->_aViewData["oxid"] = $this->getEditObjectId();
00036 if ($soxId != "-1" && isset($soxId)) {
00037
00038 $oPayment = oxNew("oxpayment");
00039 $oPayment->loadInLang($this->_iEditLang, $soxId);
00040
00041 $oOtherLang = $oPayment->getAvailableInLangs();
00042 if (!isset($oOtherLang[$this->_iEditLang])) {
00043
00044 $oPayment->loadInLang(key($oOtherLang), $soxId);
00045 }
00046 $this->_aViewData["edit"] = $oPayment;
00047
00048
00049 $aLang = array_diff(oxRegistry::getLang()->getLanguageNames(), $oOtherLang);
00050 if (count($aLang)) {
00051 $this->_aViewData["posslang"] = $aLang;
00052 }
00053
00054 foreach ($oOtherLang as $id => $language) {
00055 $oLang = new stdClass();
00056 $oLang->sLangDesc = $language;
00057 $oLang->selected = ($id == $this->_iEditLang);
00058 $this->_aViewData["otherlang"][$id] = clone $oLang;
00059 }
00060
00061
00062 $this->_aViewData['aFieldNames'] = oxRegistry::getUtils()->assignValuesFromText($oPayment->oxpayments__oxvaldesc->value);
00063 }
00064
00065 if (oxRegistry::getConfig()->getRequestParameter("aoc")) {
00066 $oPaymentMainAjax = oxNew('payment_main_ajax');
00067 $this->_aViewData['oxajax'] = $oPaymentMainAjax->getColumns();
00068
00069 return "popups/payment_main.tpl";
00070 }
00071
00072 $this->_aViewData["editor"] = $this->_generateTextEditor("100%", 300, $oPayment, "oxpayments__oxlongdesc");
00073
00074 return "payment_main.tpl";
00075 }
00076
00082 public function save()
00083 {
00084
00085 parent::save();
00086
00087 $soxId = $this->getEditObjectId();
00088 $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00089
00090 if (!isset($aParams['oxpayments__oxactive'])) {
00091 $aParams['oxpayments__oxactive'] = 0;
00092 }
00093 if (!isset($aParams['oxpayments__oxchecked'])) {
00094 $aParams['oxpayments__oxchecked'] = 0;
00095 }
00096
00097 $oPayment = oxNew("oxpayment");
00098
00099 if ($soxId != "-1") {
00100 $oPayment->loadInLang($this->_iEditLang, $soxId);
00101 } else {
00102 $aParams['oxpayments__oxid'] = null;
00103
00104 }
00105
00106 $oPayment->setLanguage(0);
00107 $oPayment->assign($aParams);
00108
00109
00110 $aRules = (array) oxRegistry::getConfig()->getRequestParameter("oxpayments__oxaddsumrules");
00111
00112 if (empty($aRules)) {
00113 $this->_aViewData["noticeoxaddsumrules"] = 1;
00114 }
00115 $oPayment->oxpayments__oxaddsumrules = new oxField(array_sum($aRules));
00116
00117
00118
00119 if (!is_array($this->_aFieldArray)) {
00120 $this->_aFieldArray = oxRegistry::getUtils()->assignValuesFromText($oPayment->oxpayments__oxvaldesc->value);
00121 }
00122
00123
00124 $sValdesc = "";
00125 foreach ($this->_aFieldArray as $oField) {
00126 $sValdesc .= $oField->name . "__@@";
00127 }
00128
00129 $oPayment->oxpayments__oxvaldesc = new oxField($sValdesc, oxField::T_RAW);
00130 $oPayment->setLanguage($this->_iEditLang);
00131 $oPayment->save();
00132
00133
00134 $this->setEditObjectId($oPayment->getId());
00135 }
00136
00142 public function saveinnlang()
00143 {
00144
00145 $soxId = $this->getEditObjectId();
00146 $aParams = oxRegistry::getConfig()->getRequestParameter("editval");
00147
00148
00149 $sShopID = oxRegistry::getSession()->getVariable("actshop");
00150 $aParams['oxpayments__oxshopid'] = $sShopID;
00151 $oObj = oxNew("oxpayment");
00152
00153 if ($soxId != "-1") {
00154 $oObj->loadInLang($this->_iEditLang, $soxId);
00155 } else {
00156 $aParams['oxpayments__oxid'] = null;
00157
00158 }
00159
00160 $oObj->setLanguage(0);
00161 $oObj->assign($aParams);
00162
00163
00164 $oObj->setLanguage(oxRegistry::getConfig()->getRequestParameter("new_lang"));
00165 $oObj->save();
00166
00167
00168 $this->setEditObjectId($oObj->getId());
00169 }
00170
00176 public function delFields()
00177 {
00178
00179 $oPayment = oxNew("oxpayment");
00180 if ($oPayment->loadInLang($this->_iEditLang, $this->getEditObjectId())) {
00181
00182 $aDelFields = oxRegistry::getConfig()->getRequestParameter("aFields");
00183 $this->_aFieldArray = oxRegistry::getUtils()->assignValuesFromText($oPayment->oxpayments__oxvaldesc->value);
00184
00185 if (is_array($aDelFields) && count($aDelFields)) {
00186 foreach ($aDelFields as $sDelField) {
00187 foreach ($this->_aFieldArray as $sKey => $oField) {
00188 if ($oField->name == $sDelField) {
00189 unset($this->_aFieldArray[$sKey]);
00190 break;
00191 }
00192 }
00193 }
00194 $this->save();
00195 }
00196 }
00197 }
00198
00204 public function addField()
00205 {
00206
00207 $oPayment = oxNew("oxpayment");
00208 if ($oPayment->loadInLang($this->_iEditLang, $this->getEditObjectId())) {
00209
00210 $this->_aFieldArray = oxRegistry::getUtils()->assignValuesFromText($oPayment->oxpayments__oxvaldesc->value);
00211
00212 $oField = new stdClass();
00213 $oField->name = oxRegistry::getConfig()->getRequestParameter("sAddField");
00214
00215 $this->_aFieldArray[] = $oField;
00216
00217 $this->save();
00218 }
00219 }
00220 }