OXID eShop CE  4.8.12
 All Classes Files Functions Variables Pages
dyn_trusted_ratings.php
Go to the documentation of this file.
1 <?php
2 
3 
9 {
15  protected $_aSkipMultiline = array( 'aTsLangIds', 'aHomeCountry', 'aTsActiveLangIds' );
16 
23  public function render()
24  {
26 
27  $this->_aViewData['oxid'] = $this->getConfig()->getShopId();
28  $this->_aViewData["alllang"] = oxRegistry::getLang()->getLanguageArray();
29 
30  return "dyn_trusted_ratings.tpl";
31  }
32 
38  public function save()
39  {
40  $myConfig = $this->getConfig();
41  $sOxId = $this->getEditObjectId();
42 
43  // base parameters
44  $aConfStrs = oxConfig::getParameter( "confstrs" );
45  $aConfAArs = oxConfig::getParameter( "confaarrs" );
46  $aConfBools = oxConfig::getParameter( "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  return $sReturn;
119  }
120 
126  public function getViewId()
127  {
128  return 'dyn_interface';
129  }
130 
138  protected function _multilineToArray( $sMultiline )
139  {
140  $aArr = $sMultiline;
141  if ( !is_array( $aArr ) ) {
142  $aArr = parent::_multilineToArray( $aArr );
143  }
144  return $aArr;
145  }
146 
154  protected function _multilineToAarray( $sMultiline )
155  {
156  $aArr = $sMultiline;
157  if ( !is_array( $aArr ) ) {
158  $aArr = parent::_multilineToAarray( $aArr );
159  }
160 
161  return $aArr;
162  }
163 }