From e6e45862a177295aba713d7569beb7bd8de63127 Mon Sep 17 00:00:00 2001 From: jfefe Date: Fri, 25 Apr 2014 12:45:35 +0200 Subject: [PATCH 1/3] Work into multilang into product webservice --- htdocs/webservices/server_productorservice.php | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index 87c1c829ee4..d464d64a99c 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -707,16 +707,20 @@ function getListOfProductsOrServices($authentication,$filterproduct) /** - * getProductsForCategory + * Get list of products for a category * * @param array $authentication Array of authentication information * @param array $id Category id * @param $lang $lang Force lang * @return array Array result - */function getProductsForCategory($authentication,$id,$lang='') + */ +function getProductsForCategory($authentication,$id,$lang='') { global $db,$conf,$langs; + $langcode=($lang?$lang:(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT)); + $langs->setDefaultLang($langcode); + dol_syslog("Function: getProductsForCategory login=".$authentication['login']." id=".$id); if ($authentication['entity']) $conf->entity=$authentication['entity']; @@ -773,11 +777,11 @@ function getListOfProductsOrServices($authentication,$filterproduct) 'id' => $obj->id, 'ref' => $obj->ref, 'ref_ext' => $obj->ref_ext, - 'label' => $obj->label, - 'description' => $obj->description, + 'label' => $obj->multilangs[$langs->defaultlang]["label"]?$obj->multilangs[$langs->defaultlang]["label"]:$obj->label, + 'description' => $obj->multilangs[$langs->defaultlang]["description"]?$obj->multilangs[$langs->defaultlang]["description"]:$obj->description, 'date_creation' => dol_print_date($obj->date_creation,'dayhourrfc'), 'date_modification' => dol_print_date($obj->date_modification,'dayhourrfc'), - 'note' => $obj->note, + 'note' => $obj->multilangs[$langs->defaultlang]["note"]?$obj->multilangs[$langs->defaultlang]["note"]:$obj->note, 'status_tosell' => $obj->status, 'status_tobuy' => $obj->status_buy, 'type' => $obj->type, From 181a49c18cbf5c23496065aac8d2bbf1074176d1 Mon Sep 17 00:00:00 2001 From: jfefe Date: Fri, 25 Apr 2014 13:20:36 +0200 Subject: [PATCH 2/3] Add multilang support into getProductsForCategory webservice method --- htdocs/webservices/server_productorservice.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index d464d64a99c..ea8ea85fa32 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -777,11 +777,11 @@ function getProductsForCategory($authentication,$id,$lang='') 'id' => $obj->id, 'ref' => $obj->ref, 'ref_ext' => $obj->ref_ext, - 'label' => $obj->multilangs[$langs->defaultlang]["label"]?$obj->multilangs[$langs->defaultlang]["label"]:$obj->label, - 'description' => $obj->multilangs[$langs->defaultlang]["description"]?$obj->multilangs[$langs->defaultlang]["description"]:$obj->description, + 'label' => ! empty($obj->multilangs[$langs->defaultlang]["label"]) ? $obj->multilangs[$langs->defaultlang]["label"] : $obj->label, + 'description' => ! empty($obj->multilangs[$langs->defaultlang]["description"]) ? $obj->multilangs[$langs->defaultlang]["description"] : $obj->description, 'date_creation' => dol_print_date($obj->date_creation,'dayhourrfc'), 'date_modification' => dol_print_date($obj->date_modification,'dayhourrfc'), - 'note' => $obj->multilangs[$langs->defaultlang]["note"]?$obj->multilangs[$langs->defaultlang]["note"]:$obj->note, + 'note' => ! empty($obj->multilangs[$langs->defaultlang]["note"]) ? $obj->multilangs[$langs->defaultlang]["note"] : $obj->note, 'status_tosell' => $obj->status, 'status_tobuy' => $obj->status_buy, 'type' => $obj->type, From f9e08c23d97d2304457cd5d1a83798bd98d02806 Mon Sep 17 00:00:00 2001 From: jfefe Date: Fri, 25 Apr 2014 13:28:01 +0200 Subject: [PATCH 3/3] Add multilang support into getProductOrService webservice method --- htdocs/webservices/server_productorservice.php | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/htdocs/webservices/server_productorservice.php b/htdocs/webservices/server_productorservice.php index ea8ea85fa32..dbbde72cb34 100644 --- a/htdocs/webservices/server_productorservice.php +++ b/htdocs/webservices/server_productorservice.php @@ -303,7 +303,7 @@ $server->register( * @param int $id Id of object * @param string $ref Ref of object * @param ref_ext $ref_ext Ref external of object - * @param $lang $lang Force lang + * @param string $lang Lang to force * @return mixed */ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang='') @@ -312,6 +312,9 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang='' dol_syslog("Function: getProductOrService login=".$authentication['login']." id=".$id." ref=".$ref." ref_ext=".$ref_ext); + $langcode=($lang?$lang:(empty($conf->global->MAIN_LANG_DEFAULT)?'auto':$conf->global->MAIN_LANG_DEFAULT)); + $langs->setDefaultLang($langcode); + if ($authentication['entity']) $conf->entity=$authentication['entity']; // Init and check authentication @@ -347,6 +350,10 @@ function getProductOrService($authentication,$id='',$ref='',$ref_ext='',$lang='' $pdir = get_exdir($product->id,2) . $product->id ."/photos/"; $dir = $dir . '/'. $pdir; + if (! empty($product->multilangs[$langs->defaultlang]["label"])) $product->label = $product->multilangs[$langs->defaultlang]["label"]; + if (! empty($product->multilangs[$langs->defaultlang]["description"])) $product->description = $product->multilangs[$langs->defaultlang]["description"]; + if (! empty($product->multilangs[$langs->defaultlang]["note"])) $product->note = $product->multilangs[$langs->defaultlang]["note"]; + // Create $objectresp = array( 'result'=>array('result_code'=>'OK', 'result_label'=>''),