Fix translation of dolistore interface
This commit is contained in:
parent
695c231e78
commit
b099e0a135
@ -40,41 +40,52 @@ class Dolistore
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Constructor
|
* Constructor
|
||||||
*
|
|
||||||
* @param array $options Options
|
|
||||||
*/
|
*/
|
||||||
function __construct($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0))
|
function __construct()
|
||||||
{
|
{
|
||||||
global $conf, $langs;
|
global $conf, $langs;
|
||||||
|
|
||||||
$this->start = $options['start'];
|
|
||||||
$this->end = $options['end'];
|
|
||||||
$this->per_page = $options['per_page'];
|
|
||||||
$this->categorie = $options['categorie'];
|
|
||||||
$this->search = $options['search'];
|
|
||||||
|
|
||||||
$this->url = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace';
|
$this->url = DOL_URL_ROOT.'/admin/modules.php?mode=marketplace';
|
||||||
$this->shop_url = 'https://www.dolistore.com/index.php?controller=product&id_product=';
|
$this->shop_url = 'https://www.dolistore.com/index.php?controller=product&id_product=';
|
||||||
$this->vat_rate = 1.2; // 20% de TVA
|
$this->vat_rate = 1.2; // 20% de TVA
|
||||||
$this->debug_api = false;
|
$this->debug_api = false;
|
||||||
|
|
||||||
if ($this->end == 0) {
|
$langtmp = explode('_', $langs->defaultlang);
|
||||||
|
$lang = $langtmp[0];
|
||||||
|
$lang_array = array('en'=>0, 'fr'=>1, 'es'=>2, 'it'=>3, 'de'=>4); // Into table ps_lang of Prestashop - 1
|
||||||
|
if (! in_array($lang, array_keys($lang_array))) $lang = 'en';
|
||||||
|
$this->lang = $lang_array[$lang];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Load data from remote Dolistore market place.
|
||||||
|
* This fills ->categories
|
||||||
|
*
|
||||||
|
* @param array $options Options
|
||||||
|
* @return void
|
||||||
|
*/
|
||||||
|
function getRemoteData($options = array('start' => 0, 'end' => 10, 'per_page' => 50, 'categorie' => 0))
|
||||||
|
{
|
||||||
|
global $conf, $langs;
|
||||||
|
|
||||||
|
$this->start = $options['start'];
|
||||||
|
$this->end = $options['end'];
|
||||||
|
$this->per_page = $options['per_page'];
|
||||||
|
$this->categorie = $options['categorie'];
|
||||||
|
$this->search = $options['search'];
|
||||||
|
|
||||||
|
if ($this->end == 0) {
|
||||||
$this->end = $this->per_page;
|
$this->end = $this->per_page;
|
||||||
}
|
}
|
||||||
|
|
||||||
$langtmp = explode('_', $langs->defaultlang);
|
try {
|
||||||
$lang = $langtmp[0];
|
|
||||||
$lang_array = array('fr'=>1, 'en'=>2, 'es'=>3, 'it'=>4, 'de'=>5);
|
|
||||||
if (! in_array($lang, array_keys($lang_array))) $lang = 'en';
|
|
||||||
$this->lang = $lang_array[$lang]; // 1=fr 2=en ...
|
|
||||||
|
|
||||||
try {
|
|
||||||
$this->api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
|
$this->api = new PrestaShopWebservice($conf->global->MAIN_MODULE_DOLISTORE_API_SRV,
|
||||||
$conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $this->debug_api);
|
$conf->global->MAIN_MODULE_DOLISTORE_API_KEY, $this->debug_api);
|
||||||
|
|
||||||
// Here we set the option array for the Webservice : we want products resources
|
// Here we set the option array for the Webservice : we want products resources
|
||||||
$opt = array();
|
$opt = array();
|
||||||
$opt['resource'] = 'products';
|
$opt['resource'] = 'products';
|
||||||
|
|
||||||
// make a search to limit the id returned.
|
// make a search to limit the id returned.
|
||||||
if ($this->search != '') {
|
if ($this->search != '') {
|
||||||
$opt2 = array();
|
$opt2 = array();
|
||||||
@ -102,7 +113,9 @@ class Dolistore
|
|||||||
$opt['sort'] = 'id_desc';
|
$opt['sort'] = 'id_desc';
|
||||||
$opt['filter[active]'] = '[1]';
|
$opt['filter[active]'] = '[1]';
|
||||||
$opt['limit'] = "$this->start,$this->end";
|
$opt['limit'] = "$this->start,$this->end";
|
||||||
// Call
|
// $opt['filter[id]'] contais list of product id that are result of search
|
||||||
|
|
||||||
|
// Call API to get the detail
|
||||||
$xml = $this->api->get($opt);
|
$xml = $this->api->get($opt);
|
||||||
$this->products = $xml->products->children();
|
$this->products = $xml->products->children();
|
||||||
|
|
||||||
@ -124,7 +137,12 @@ class Dolistore
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Return tree of Dolistore categories. $this->categories must have been loaded before.
|
||||||
|
*
|
||||||
|
* @param int $parent Id of parent category
|
||||||
|
* @return string
|
||||||
|
*/
|
||||||
function get_categories($parent = 0)
|
function get_categories($parent = 0)
|
||||||
{
|
{
|
||||||
if (!isset($this->categories)) die('not possible');
|
if (!isset($this->categories)) die('not possible');
|
||||||
|
|||||||
@ -55,7 +55,7 @@ $options['categorie'] = ((GETPOST('categorie', 'int')?GETPOST('categorie', 'int'
|
|||||||
$options['start'] = ((GETPOST('start', 'int')?GETPOST('start', 'int'):0) + 0);
|
$options['start'] = ((GETPOST('start', 'int')?GETPOST('start', 'int'):0) + 0);
|
||||||
$options['end'] = ((GETPOST('end', 'int')?GETPOST('end', 'int'):0) + 0);
|
$options['end'] = ((GETPOST('end', 'int')?GETPOST('end', 'int'):0) + 0);
|
||||||
$options['search'] = GETPOST('search_keyword', 'alpha');
|
$options['search'] = GETPOST('search_keyword', 'alpha');
|
||||||
$dolistore = new Dolistore($options);
|
$dolistore = new Dolistore();
|
||||||
|
|
||||||
|
|
||||||
if (! $user->admin)
|
if (! $user->admin)
|
||||||
@ -832,6 +832,10 @@ if ($mode == 'marketplace')
|
|||||||
|
|
||||||
if (empty($conf->global->MAIN_DISABLE_DOLISTORE_SEARCH) && $conf->global->MAIN_FEATURES_LEVEL >= 1)
|
if (empty($conf->global->MAIN_DISABLE_DOLISTORE_SEARCH) && $conf->global->MAIN_FEATURES_LEVEL >= 1)
|
||||||
{
|
{
|
||||||
|
// $options is array with filter criterias
|
||||||
|
//var_dump($options);
|
||||||
|
$dolistore->getRemoteData($options);
|
||||||
|
|
||||||
print '<span class="opacitymedium">'.$langs->trans('DOLISTOREdescriptionLong').'</span><br><br>';
|
print '<span class="opacitymedium">'.$langs->trans('DOLISTOREdescriptionLong').'</span><br><br>';
|
||||||
|
|
||||||
$previouslink = $dolistore->get_previous_link();
|
$previouslink = $dolistore->get_previous_link();
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user