00001 <?php
00002
00003
00004 DEFINE('EFIRE_WSDL_URL', 'https://soap.oxid-efire.com/');
00005
00006
00011 class oxEfiDownloader extends oxSuperCfg
00012 {
00018 protected $_oSoapClient = null;
00019
00020 protected $_sVersion = null;
00021
00032 public function downloadConnector($sUsername, $sPassword, $sShopVersion, $blSaveCredentials)
00033 {
00034
00035 if ($blSaveCredentials) {
00036 $this->getConfig()->saveShopConfVar('str', 'sEfiUsername', $sUsername);
00037 $this->getConfig()->saveShopConfVar('str', 'sEfiPassword', $sPassword);
00038 } else {
00039 $this->getConfig()->saveShopConfVar('str', 'sEfiUsername', null);
00040 $this->getConfig()->saveShopConfVar('str', 'sEfiPassword', null);
00041 }
00042
00043 $this->_init($sUsername, $sPassword);
00044
00045 $sFileName = getShopBasePath() . "core/". strtolower(basename($this->_getConnectorClassName($sShopVersion))) . ".php";
00046 $sFileContents = $this->_getConnectorContents($sShopVersion);
00047
00048
00049 $fOut = fopen($sFileName, "w");
00050 if (!fputs($fOut, $sFileContents)) {
00051 throw new oxException();
00052 }
00053 fclose($fOut);
00054
00055
00056 if (file_exists(getShopBasePath() . "/oxefi.php")) {
00057 unlink(getShopBasePath() . "/oxefi.php");
00058 }
00059
00060 return $sFileName;
00061 }
00062
00071 protected function _init($sUsername, $sPassword)
00072 {
00073 $this->_oClient = new SoapClient( EFIRE_WSDL_URL . 'eshopconnector/?wsdl',
00074 array(
00075 'trace' => 1,
00076 'style' => SOAP_DOCUMENT,
00077 'login' => $sUsername,
00078 'password' => $sPassword,
00079 'cache_wsdl' => WSDL_CACHE_NONE
00080 )
00081 );
00082
00083 }
00084
00092 protected function _getConnectorClassName($sShopVersion)
00093 {
00094 $oResponse = $this->_oClient->getConnectorClassName($sShopVersion);
00095
00096 if (!$oResponse->blResult) {
00097 throw new Exception($oResponse->sMessage);
00098 }
00099
00100 return $oResponse->sMessage;
00101 }
00102
00110 protected function _getConnectorContents($sShopVersion)
00111 {
00112 $oResponse = $this->_oClient->getConnectorFileContents($sShopVersion);
00113
00114 if (!$oResponse->blResult) {
00115 throw new Exception($oResponse->sMessage);
00116 }
00117
00118 return $oResponse->sMessage;
00119 }
00120
00121 }