dyn_trusted_ratings.php

Go to the documentation of this file.
00001 <?php
00002 
00003 
00008 class dyn_trusted_ratings extends Shop_Config
00009 {
00015     protected $_aSkipMultiline = array( 'aTsLangIds', 'aHomeCountry', 'aTsActiveLangIds' );
00016 
00023     public function render()
00024     {
00025         parent::render();
00026 
00027         $this->_aViewData['oxid']    = $this->getConfig()->getShopId();
00028         $this->_aViewData["alllang"] = oxLang::getInstance()->getLanguageArray();
00029 
00030         return "dyn_trusted_ratings.tpl";
00031     }
00032 
00038     public function save()
00039     {
00040         $myConfig = $this->getConfig();
00041         $sOxId    = oxConfig::getParameter( "oxid" );
00042 
00043         // base parameters
00044         $aConfStrs  = oxConfig::getParameter( "confstrs" );
00045         $aConfAArs  = oxConfig::getParameter( "confaarrs" );
00046         $aConfBools = oxConfig::getParameter( "confbools" );
00047 
00048         // validating language Ids
00049         if ( is_array( $aConfAArs['aTsLangIds'] ) ) {
00050 
00051             $blActive = ( isset( $aConfBools["blTsWidget"] ) && $aConfBools["blTsWidget"] == "true" ) ? true : false;
00052             $sPkg = "OXID_ESALES";
00053 
00054             $aActiveLangs = array();
00055             foreach ( $aConfAArs['aTsLangIds'] as $sLangId => $sId ) {
00056                 $aActiveLangs[$sLangId] = false;
00057                 if ( $sId ) {
00058                     $sTsUser = $myConfig->getConfigParam( 'sTsUser' );
00059                     $sTsPass = $myConfig->getConfigParam( 'sTsPass' );
00060                     // validating and switching on/off
00061                     $sResult = $this->_validateId( $sId, (bool) $blActive, $sTsUser, $sTsPass, $sPkg );
00062 
00063                     // keeping activation state
00064                     $aActiveLangs[$sLangId] = $sResult == "OK" ? true : false;
00065 
00066                     // error message
00067                     if ( $sResult && $sResult != "OK" ) {
00068                         $this->_aViewData["errorsaving"] = "DYN_TRUSTED_RATINGS_ERR_{$sResult}";
00069                     }
00070                 }
00071             }
00072 
00073             $myConfig->saveShopConfVar( "arr", "aTsActiveLangIds", $aActiveLangs, $sOxId );
00074         }
00075 
00076         parent::save();
00077     }
00078 
00084     protected function _getServiceWsdl()
00085     {
00086         $sWsdl = false;
00087         $oConfig = $this->getConfig();
00088         $aTsConfig = $oConfig->getConfigParam( "aTsConfig" );
00089         if ( is_array( $aTsConfig ) ) {
00090             $sWsdl = $aTsConfig["blTestMode"] ? $oConfig->getConfigParam( "sTsServiceTestWsdl" ) : $oConfig->getConfigParam( "sTsServiceWsdl" );
00091         }
00092 
00093         return $sWsdl;
00094     }
00095 
00107     protected function _validateId( $sId, $blActive, $sUser, $sPass, $sPkg )
00108     {
00109         $sReturn = false;
00110         if ( ( $sWsdl = $this->_getServiceWsdl() ) ) {
00111             try {
00112                 $oClient = new SoapClient( $sWsdl );
00113                 $sReturn = $oClient->updateRatingWidgetState( $sId, (int) $blActive, $sUser, $sPass, $sPkg );
00114             } catch ( SoapFault $oFault ) {
00115                 $sReturn = $oFault->faultstring;
00116             }
00117         }
00118         return $sReturn;
00119     }
00120 
00126     public function getViewId()
00127     {
00128         return 'dyn_interface';
00129     }
00130 
00138     protected function _multilineToArray( $sMultiline )
00139     {
00140         $aArr = $sMultiline;
00141         if ( !is_array( $aArr ) ) {
00142             $aArr = parent::_multilineToArray( $aArr );
00143         }
00144         return $aArr;
00145     }
00146 
00154     protected function _multilineToAarray( $sMultiline )
00155     {
00156         $aArr = $sMultiline;
00157         if ( !is_array( $aArr ) ) {
00158             $aArr = parent::_multilineToAarray( $aArr );
00159         }
00160 
00161         return $aArr;
00162     }
00163 }