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