oxefidownloader.php

Go to the documentation of this file.
00001 <?php
00002 
00003 
00004 DEFINE('EFIRE_WSDL_URL', 'https://soap.oxid-efire.com/');
00005 //DEFINE('EFIRE_WSDL_URL', 'http://efire-linux:12156/');
00006 
00012 class oxEfiDownloader extends oxSuperCfg
00013 {
00019     protected $_oSoapClient = null;
00020 
00021     protected $_sVersion = null;
00022 
00033     public function downloadConnector($sUsername, $sPassword, $sShopVersion, $blSaveCredentials)
00034     {
00035 
00036         if ($blSaveCredentials) {
00037             $this->getConfig()->saveShopConfVar('str', 'sEfiUsername', $sUsername);
00038             $this->getConfig()->saveShopConfVar('str', 'sEfiPassword', $sPassword);
00039         } else {
00040             $this->getConfig()->saveShopConfVar('str', 'sEfiUsername', null);
00041             $this->getConfig()->saveShopConfVar('str', 'sEfiPassword', null);
00042         }
00043 
00044         $this->_init($sUsername, $sPassword);
00045 
00046         $sFileName = getShopBasePath() . "core/". strtolower(basename($this->_getConnectorClassName($sShopVersion))) . ".php";
00047         $sFileContents = $this->_getConnectorContents($sShopVersion);
00048 
00049         //writing to file
00050         $fOut = fopen($sFileName, "w");
00051         if (!fputs($fOut, $sFileContents)) {
00052             throw new oxException();
00053         }
00054         fclose($fOut);
00055 
00056         //remove possible old connector from the main shop dir
00057         if (file_exists(getShopBasePath() . "/oxefi.php"))
00058             unlink(getShopBasePath() . "/oxefi.php");
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 }

Generated on Thu Feb 19 15:02:22 2009 for OXID eShop CE by  doxygen 1.5.5