// merge 1.4 (5916) => 1.5.x
This commit is contained in:
Executable
+45
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
/**
|
||||
* 2007-2011 PrestaShop
|
||||
*
|
||||
* NOTICE OF LICENSE
|
||||
*
|
||||
* This source file is subject to the Academic Free License (AFL 3.0)
|
||||
* that is bundled with this package in the file LICENSE.txt.
|
||||
* It is also available through the world-wide-web at this URL:
|
||||
* http://opensource.org/licenses/afl-3.0.php
|
||||
* If you did not receive a copy of the license and are unable to
|
||||
* obtain it through the world-wide-web, please send an email
|
||||
* to license@prestashop.com so we can send you a copy immediately.
|
||||
*
|
||||
* DISCLAIMER
|
||||
*
|
||||
* Do not edit or add to this file if you wish to upgrade PrestaShop to newer
|
||||
* versions in the future. If you wish to customize PrestaShop for your
|
||||
* needs please refer to http://www.prestashop.com for more information.
|
||||
*
|
||||
* @author PrestaShop SA <contact@prestashop.com>
|
||||
* @copyright 2007-2011 PrestaShop SA : 6 rue lacepede, 75005 PARIS
|
||||
* @version Release: $Revision: 1.4 $
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
**/
|
||||
|
||||
class TwengaFieldsAddFeed extends TwengaFields
|
||||
{
|
||||
public function __construct()
|
||||
{
|
||||
if(!is_array($this->fields) && empty($this->fields))
|
||||
{
|
||||
$this->fields['key'] = array(32, array('is_string', 'isCleanHtml'), true);
|
||||
$this->fields['PARTNER_AUTH_KEY'] = array(56, array('is_string', 'isCleanHtml'), true);
|
||||
$this->fields['feed_url'] = array(255, array('is_string', 'isCleanHtml'), true);
|
||||
}
|
||||
parent::__construct();
|
||||
}
|
||||
|
||||
public function __destruct()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
@@ -162,7 +162,7 @@ abstract class TwengaFields
|
||||
public function getField($name)
|
||||
{
|
||||
if (!is_array($this->fields))
|
||||
throw new TwengaFieldsException(Tools::displayError('For get a field you have to saved some fields !'));
|
||||
throw new TwengaFieldsException(Tools::displayError('To get a field you have to saved some fields !'));
|
||||
if(!key_exists($name, $this->fields))
|
||||
throw new TwengaFieldsException(Tools::displayError('The field').' <b>'.$name.'</b> '.Tools::displayError('doesn\'t exist.'));
|
||||
return $this->fields[$name];
|
||||
@@ -326,4 +326,4 @@ abstract class TwengaFields
|
||||
return str_replace('"', '"', $ret);
|
||||
}
|
||||
}
|
||||
class TwengaFieldsException extends Exception {}
|
||||
class TwengaFieldsException extends Exception {}
|
||||
|
||||
@@ -191,6 +191,7 @@ class TwengaObj
|
||||
self::$arr_api_url['orderExist'] = 'http://rts.twenga.com/api/Order/Exist';
|
||||
self::$arr_api_url['orderValidate'] = 'http://rts.twenga.com/api/Order/Validate';
|
||||
self::$arr_api_url['orderCancel'] = 'http://rts.twenga.com/api/Order/Cancel';
|
||||
self::$arr_api_url['addFeed'] = 'https://rts.twenga.com/api/Site/AddFeed';
|
||||
|
||||
if(self::PARTNER_AUTH_KEY === NULL)
|
||||
throw new TwengaException(self::$translation_object->l('To activate the Twenga plugin, "PARTNER_AUTH_KEY" contant must be set. Default installation of Prestashop contains this value.', basename(__FILE__, '.php')));
|
||||
@@ -222,7 +223,7 @@ class TwengaObj
|
||||
* @param array $params
|
||||
* @param boolean $authentication
|
||||
* @throws TwengaException in case of cURL error.
|
||||
* @return array with status code and response of the cURL reponse.
|
||||
* @return array with status code and response of the cURL request.
|
||||
*/
|
||||
private static function executeQuery($query, array $params = array(), $authentication = true)
|
||||
{
|
||||
@@ -299,10 +300,32 @@ class TwengaObj
|
||||
} catch (Exception $e) {
|
||||
throw new TwengaException(self::$translation_object->l($e->getMessage(),basename(__FILE__, '.php')), $e->getCode());
|
||||
}
|
||||
|
||||
return (array)$obj_xml;
|
||||
}
|
||||
|
||||
|
||||
public function addFeed($params = array())
|
||||
{
|
||||
require_once realpath(self::$base_dir.'/TwengaAddFeed.php');
|
||||
$params['key'] = self::$hashkey;
|
||||
$params['PARTNER_AUTH_KEY'] = self::PARTNER_AUTH_KEY;
|
||||
try {
|
||||
self::checkParams(__FUNCTION__, $params);
|
||||
} catch (TwengaFieldsException $e) {
|
||||
throw $e;
|
||||
}
|
||||
$str_params = self::buildUrlToQuery(self::$arr_api_url[__FUNCTION__],$params);
|
||||
try {
|
||||
$response = self::executeQuery($str_params);
|
||||
self::checkStatusCode($response['status_code']);
|
||||
$obj_xml = self::parseXml($response['response']);
|
||||
} catch (TwengaException $e) {
|
||||
throw $e;
|
||||
} catch (Exception $e) {
|
||||
throw new TwengaException(self::$translation_object->l($e->getMessage(),basename(__FILE__, '.php')), $e->getCode());
|
||||
}
|
||||
return ((string)$obj_xml->message === 'true') ? true : false;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $params
|
||||
* @throws TwengaFieldsException
|
||||
|
||||
Reference in New Issue
Block a user