OXID eShop CE  4.9.6
 All Classes Files Functions Variables Pages
dyn_trusted_ratings.php
Go to the documentation of this file.
1 <?php
2 
3 
10 {
11 
17  protected $_aSkipMultiline = array('aTsLangIds', 'aHomeCountry', 'aTsActiveLangIds');
18 
25  public function render()
26  {
28 
29  $this->_aViewData['oxid'] = $this->getConfig()->getShopId();
30  $this->_aViewData["alllang"] = oxRegistry::getLang()->getLanguageArray();
31 
32  return "dyn_trusted_ratings.tpl";
33  }
34 
38  public function save()
39  {
40  $myConfig = $this->getConfig();
41  $sOxId = $this->getEditObjectId();
42 
43  // base parameters
44  $aConfStrs = oxRegistry::getConfig()->getRequestParameter("confstrs");
45  $aConfAArs = oxRegistry::getConfig()->getRequestParameter("confaarrs");
46  $aConfBools = oxRegistry::getConfig()->getRequestParameter("confbools");
47 
48  // validating language Ids
49  if (is_array($aConfAArs['aTsLangIds'])) {
50 
51  $blActive = (isset($aConfBools["blTsWidget"]) && $aConfBools["blTsWidget"] == "true") ? true : false;
52  $sPkg = "OXID_ESALES";
53 
54  $aActiveLangs = array();
55  foreach ($aConfAArs['aTsLangIds'] as $sLangId => $sId) {
56  $aActiveLangs[$sLangId] = false;
57  if ($sId) {
58  $sTsUser = $myConfig->getConfigParam('sTsUser');
59  $sTsPass = $myConfig->getConfigParam('sTsPass');
60  // validating and switching on/off
61  $sResult = $this->_validateId($sId, (bool) $blActive, $sTsUser, $sTsPass, $sPkg);
62 
63  // keeping activation state
64  $aActiveLangs[$sLangId] = $sResult == "OK" ? true : false;
65 
66  // error message
67  if ($sResult && $sResult != "OK") {
68  $this->_aViewData["errorsaving"] = "DYN_TRUSTED_RATINGS_ERR_{$sResult}";
69  }
70  }
71  }
72 
73  $myConfig->saveShopConfVar("arr", "aTsActiveLangIds", $aActiveLangs, $sOxId);
74  }
75 
76  parent::save();
77  }
78 
84  protected function _getServiceWsdl()
85  {
86  $sWsdl = false;
87  $oConfig = $this->getConfig();
88  $aTsConfig = $oConfig->getConfigParam("aTsConfig");
89  if (is_array($aTsConfig)) {
90  $sWsdl = $aTsConfig["blTestMode"] ? $oConfig->getConfigParam("sTsServiceTestWsdl") : $oConfig->getConfigParam("sTsServiceWsdl");
91  }
92 
93  return $sWsdl;
94  }
95 
107  protected function _validateId($sId, $blActive, $sUser, $sPass, $sPkg)
108  {
109  $sReturn = false;
110  if (($sWsdl = $this->_getServiceWsdl())) {
111  try {
112  $oClient = new SoapClient($sWsdl);
113  $sReturn = $oClient->updateRatingWidgetState($sId, (int) $blActive, $sUser, $sPass, $sPkg);
114  } catch (SoapFault $oFault) {
115  $sReturn = $oFault->faultstring;
116  }
117  }
118 
119  return $sReturn;
120  }
121 
127  public function getViewId()
128  {
129  return 'dyn_interface';
130  }
131 
139  protected function _multilineToArray($sMultiline)
140  {
141  $aArr = $sMultiline;
142  if (!is_array($aArr)) {
143  $aArr = parent::_multilineToArray($aArr);
144  }
145 
146  return $aArr;
147  }
148 
156  protected function _multilineToAarray($sMultiline)
157  {
158  $aArr = $sMultiline;
159  if (!is_array($aArr)) {
160  $aArr = parent::_multilineToAarray($aArr);
161  }
162 
163  return $aArr;
164  }
165 }