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         return $sFileName;
00057     }
00058 
00067     protected function _init($sUsername, $sPassword)
00068     {
00069         $this->_oClient = new SoapClient( EFIRE_WSDL_URL . 'eshopconnector/?wsdl',
00070                                           array(
00071                                                  'trace'      => 1,
00072                                                  'style'      => SOAP_DOCUMENT,
00073                                                  'login'      => $sUsername,
00074                                                  'password'   => $sPassword,
00075                                                  'cache_wsdl' => WSDL_CACHE_NONE
00076                                                )
00077                                         );
00078 
00079     }
00080 
00088     protected function _getConnectorClassName($sShopVersion)
00089     {
00090         $oResponse = $this->_oClient->getConnectorClassName($sShopVersion);
00091 
00092         if (!$oResponse->blResult) {
00093             throw new Exception($oResponse->sMessage);
00094         }
00095 
00096         return $oResponse->sMessage;
00097     }
00098 
00106     protected function _getConnectorContents($sShopVersion)
00107     {
00108         $oResponse = $this->_oClient->getConnectorFileContents($sShopVersion);
00109 
00110         if (!$oResponse->blResult) {
00111             throw new Exception($oResponse->sMessage);
00112         }
00113 
00114         return $oResponse->sMessage;
00115     }
00116 
00117 }

Generated on Thu Dec 4 12:04:56 2008 for OXID eShop CE by  doxygen 1.5.5