diff --git a/htdocs/imports/import.class.php b/htdocs/imports/import.class.php index 28752193ddd..f779dbca535 100644 --- a/htdocs/imports/import.class.php +++ b/htdocs/imports/import.class.php @@ -18,9 +18,9 @@ */ /** - * \file htdocs/admin/import/import.class.php + * \file htdocs/import/import.class.php * \ingroup import - * \brief Fichier de la classe des imports + * \brief File of class to manage imports * \version $Id$ */ @@ -30,6 +30,19 @@ */ class Import { + var $array_import_module; + var $array_import_perms; + var $array_import_icon; + var $array_import_code; + var $array_import_label; + var $array_import_tables; + var $array_import_fields; + var $array_import_entities; + var $array_import_examplevalues; + //var $array_import_sql_start; + //var $array_import_sql_end; + + /** * \brief Constructor * \param DB Database handler @@ -135,8 +148,8 @@ class Import // Tableau des alias a exporter (cle=champ, valeur=alias) $this->array_import_examplevalues[$i]=$module->import_examplevalues_array[$r]; // Requete sql du dataset - $this->array_import_sql_start[$i]=$module->import_sql_start[$r]; - $this->array_import_sql_end[$i]=$module->import_sql_end[$r]; + //$this->array_import_sql_start[$i]=$module->import_sql_start[$r]; + //$this->array_import_sql_end[$i]=$module->import_sql_end[$r]; //$this->array_import_sql[$i]=$module->import_sql[$r]; dol_syslog("Import loaded for module ".$modulename." with index ".$i.", dataset=".$module->import_code[$r].", nb of fields=".sizeof($module->import_fields_code[$r])); diff --git a/htdocs/imports/import.php b/htdocs/imports/import.php index 2e327de20a6..ad86183b851 100644 --- a/htdocs/imports/import.php +++ b/htdocs/imports/import.php @@ -294,6 +294,7 @@ if ($action == 'saveorder') */ +// STEP 1: Page to select dataset to import if ($step == 1 || ! $datatoimport) { // Clean saved file-database matching @@ -372,6 +373,8 @@ if ($step == 1 || ! $datatoimport) } + +// STEP 2: Page to select input format file if ($step == 2 && $datatoimport) { llxHeader('',$langs->trans("NewImport"),'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones'); @@ -447,6 +450,8 @@ if ($step == 2 && $datatoimport) if ($mesg) print $mesg; } + +// STEP 3: Page to select file if ($step == 3 && $datatoimport) { $liste=$objmodelimport->liste_modeles($db); @@ -491,7 +496,10 @@ if ($step == 3 && $datatoimport) print $objimport->array_import_label[0]; print ''; - print '
| '.$langs->trans("InformationOnSourceFile").' | |
| '.$langs->trans("SourceFileFormat").' | '; @@ -575,7 +583,7 @@ if ($step == 3 && $datatoimport) } -// Page to make matching between source file and database fields +// STEP 4: Page to make matching between source file and database fields if ($step == 4 && $datatoimport) { $model=$format; @@ -589,38 +597,22 @@ if ($step == 4 && $datatoimport) $obj = new $classname($db); // Load source fields in input file + $fieldssource=array(); $result=$obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport,$langs); if ($result >= 0) { // Read first line $arrayrecord=$obj->import_read_record(); - $fieldssource=array(); - // Put array into an array starting with 1. + // Put into array fieldssource starting with 1. $i=1; foreach($arrayrecord as $key => $val) { - $newval=dol_trunc($val,24); - // Autodetect format (UTF8 or ISO) - if (utf8_check($val)) $fieldssource[$i]['example1']=$newval; - else $fieldssource[$i]['example1']=utf8_encode($newval); + $fieldssource[$i]['example1']=dol_trunc($val,24); $i++; } $obj->import_close_file(); } -/*$fieldssource=array( - 1=>array('name'=>'aa','example1'=>'val1','example2'=>'val2'), - 2=>array('name'=>'bb','example1'=>'valb1','example2'=>'valb2'), - 3=>array('name'=>'cc','example1'=>'valc1','example2'=>'valc2'), - 4=>array('name'=>'dd','example1'=>'valc1','example2'=>'valc2'), - 5=>array('name'=>'ee','example1'=>'valc1','example2'=>'valc2'), - 6=>array('name'=>'ff','example1'=>'valc1','example2'=>'valc2'), - 7=>array('name'=>'gg','example1'=>'valc1','example2'=>'valc2'), - 8=>array('name'=>'hh','example1'=>'valc1','example2'=>'valc2'), - 9=>array('name'=>'ii','example1'=>'valc1','example2'=>'valc2'), - ); -*/ - // Load targets fields in database $fieldstarget=$objimport->array_import_fields[0]; @@ -706,7 +698,10 @@ if ($step == 4 && $datatoimport) print $objimport->array_import_label[0]; print '|
| '.$langs->trans("InformationOnSourceFile").' | |
| '.$langs->trans("InformationOnSourceFile").' | |
| '.$langs->trans("SourceFileFormat").' | '; @@ -1019,11 +1014,14 @@ if ($step == 4 && $datatoimport) } + +// STEP 5: Summary of choices if ($step == 5 && $datatoimport) { if (empty($dontimportfirstline)) $dontimportfirstline=0; $model=$format; + $liste=$objmodelimport->liste_modeles($db); // Create classe to use for import $dir = DOL_DOCUMENT_ROOT . "/includes/modules/import/"; @@ -1033,22 +1031,21 @@ if ($step == 5 && $datatoimport) $obj = new $classname($db); // Load source fields in input file - $obj->import_open_file($dir.$file,$langs); - $fieldssource=array( - 1=>array('name'=>'aa','example1'=>'val1','example2'=>'val2'), - 2=>array('name'=>'bb','example1'=>'valb1','example2'=>'valb2'), - 3=>array('name'=>'cc','example1'=>'valc1','example2'=>'valc2'), -/* 4=>array('name'=>'dd','example1'=>'valc1','example2'=>'valc2'), - 5=>array('name'=>'ee','example1'=>'valc1','example2'=>'valc2'), - 6=>array('name'=>'ff','example1'=>'valc1','example2'=>'valc2'), - 7=>array('name'=>'gg','example1'=>'valc1','example2'=>'valc2'), - 8=>array('name'=>'hh','example1'=>'valc1','example2'=>'valc2'), - 9=>array('name'=>'ii','example1'=>'valc1','example2'=>'valc2'), -*/ ); - $obj->import_close_file(); - - ksort($array_match_file_to_database); - //var_dump($array_match_file_to_database); + $fieldssource=array(); + $result=$obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport,$langs); + if ($result >= 0) + { + // Read first line + $arrayrecord=$obj->import_read_record(); + // Put into array fieldssource starting with 1. + $i=1; + foreach($arrayrecord as $key => $val) + { + $fieldssource[$i]['example1']=dol_trunc($val,24); + $i++; + } + $obj->import_close_file(); + } $param='&format='.$format.'&datatoimport='.$datatoimport.'&filetoimport='.urlencode($filetoimport); @@ -1095,28 +1092,22 @@ if ($step == 5 && $datatoimport) print $objimport->array_import_label[0]; print '|
| '.$langs->trans("InformationOnSourceFile").' | |
| '.$langs->trans("InformationOnSourceFile").' | |
| '.$langs->trans("SourceFileFormat").' | '; + print '|
| '.$langs->trans("SourceFileFormat").' | '; print ''; - print $format; + $text=$objmodelimport->getDriverDesc($format); + print $html->textwithpicto($objmodelimport->getDriverLabel($format),$text); print ' |
| '.$langs->trans("FileToImport").' | '; + print '|
| '.$langs->trans("FileToImport").' | '; print ''.$filetoimport.' |
| '; print $langs->trans("NbOfSourceLines"); @@ -1132,10 +1123,13 @@ if ($step == 5 && $datatoimport) print ''; print ' | |
| '.$langs->trans("InformationOnTargetTables").' | |
| '.$langs->trans("InformationOnTargetTables").' | |
| '; + print ' | |
| '; print $langs->trans("TablesTarget"); print ' | '; $listtables=array(); @@ -1147,7 +1141,28 @@ if ($step == 5 && $datatoimport) $alias=eregi_replace('\..*$','',$label); $listtables[$alias]=$objimport->array_import_tables[0][$alias]; } - print sizeof($listtables)?(join(', ',$listtables)):$langs->trans("Error"); + if (sizeof($listtables)) + { + $newval=''; + foreach ($listtables as $val) + { + if ($newval) print ', '; + $newval=$val; + // Link to Dolibarr wiki pages + /*$helppagename='EN:Table_'.$newval; + if ($helppagename && empty($conf->global->MAIN_HELP_DISABLELINK)) + { + // Get helpbaseurl, helppage and mode from helppagename and langs + $arrayres=getHelpParamFor($helppagename,$langs); + $helpbaseurl=$arrayres['helpbaseurl']; + $helppage=$arrayres['helppage']; + $mode=$arrayres['mode']; + $newval.=' '.img_picto($langs->trans($mode == 'wiki' ? 'GoToWikiHelpPage': 'GoToHelpPage'),DOL_URL_ROOT.'/theme/common/helpdoc.png','',1).''; + }*/ + print $newval; + } + } + else print $langs->trans("Error"); print ' | ';
$listfields=array();
$i=0;
+ //print 'fieldsource='.$fieldssource;
+ //var_dump($array_match_file_to_database);
foreach($array_match_file_to_database as $code=>$label)
{
$i++;
@@ -1194,6 +1211,230 @@ if ($step == 5 && $datatoimport)
}
+// STEP 6: Result of simulation
+if ($step == 6 && $datatoimport)
+{
+ if (empty($dontimportfirstline)) $dontimportfirstline=0;
+
+ $model=$format;
+ $liste=$objmodelimport->liste_modeles($db);
+
+ // Create classe to use for import
+ $dir = DOL_DOCUMENT_ROOT . "/includes/modules/import/";
+ $file = "import_".$model.".modules.php";
+ $classname = "Import".ucfirst($model);
+ require_once($dir.$file);
+ $obj = new $classname($db);
+
+ // Load source fields in input file
+ $fieldssource=array();
+ $result=$obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport,$langs);
+ if ($result >= 0)
+ {
+ // Read first line
+ $arrayrecord=$obj->import_read_record();
+ // Put into array fieldssource starting with 1.
+ $i=1;
+ foreach($arrayrecord as $key => $val)
+ {
+ $fieldssource[$i]['example1']=dol_trunc($val,24);
+ $i++;
+ }
+ $obj->import_close_file();
+ }
+
+ $param='&format='.$format.'&datatoimport='.$datatoimport.'&filetoimport='.urlencode($filetoimport);
+
+ llxHeader('',$langs->trans("NewImport"),'EN:Module_Imports_En|FR:Module_Imports|ES:Módulo_Importaciones');
+
+ $h = 0;
+
+ $head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=1';
+ $head[$h][1] = $langs->trans("Step")." 1";
+ $h++;
+
+ $head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=2&datatoimport='.$datatoimport;
+ $head[$h][1] = $langs->trans("Step")." 2";
+ $h++;
+
+ $head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=3&'.$param;
+ $head[$h][1] = $langs->trans("Step")." 3";
+ $h++;
+
+ $head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=4&'.$param;
+ $head[$h][1] = $langs->trans("Step")." 4";
+ $h++;
+
+ $head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=5&'.$param;
+ $head[$h][1] = $langs->trans("Step")." 5";
+ $h++;
+
+ $head[$h][0] = DOL_URL_ROOT.'/imports/import.php?step=6&'.$param;
+ $head[$h][1] = $langs->trans("Step")." 6";
+ $hselected=$h;
+ $h++;
+
+ dol_fiche_head($head, $hselected, $langs->trans("NewImport"));
+
+ print '
'; + print ''.$langs->trans("InformationOnSourceFile").''; + print '
'; + + // Launch import + $arrayofresult=array(); + $db->begin(); + + // Open input file + $result=$obj->import_open_file($conf->import->dir_temp.'/'.$filetoimport,$langs); + if ($result > 0) + { + $i=1; + // Loop on each input file record + while ($arrayrecord=$obj->import_read_record()) + { + $i++; + $result=$obj->import_insert($arrayrecord,$array_match_file_to_database,$objimport); + $arrayofresult[$result]++; + } + // Close file + $obj->import_close_file(); + } + + $db->rollback(); // We force rollback because this was just a simulation. + + + // Print $arrayofresult + // TODO + + + print $langs->trans("NowClickToRunTheImport",$langs->transnoentitiesnoconv("RunImportFile")).' '; + + print ''; + + // Actions + print ' '; diff --git a/htdocs/includes/modules/import/import_csv.modules.php b/htdocs/includes/modules/import/import_csv.modules.php index be7a3677058..856ca4cc8bb 100644 --- a/htdocs/includes/modules/import/import_csv.modules.php +++ b/htdocs/includes/modules/import/import_csv.modules.php @@ -18,9 +18,9 @@ */ /** - * \file htdocs/includes/modules/export/export_csv.modules.php - * \ingroup export - * \brief File to build exports with CSV format + * \file htdocs/includes/modules/import/import_csv.modules.php + * \ingroup import + * \brief File to load import files with CSV format * \author Laurent Destailleur * \version $Id$ */ @@ -190,13 +190,12 @@ class ImportCsv extends ModeleImports /** - * \brief Input record line from file + * \brief Return array of next record in input file. + * \return Array Array of field values. Data are UTF8 encoded. */ function import_read_record() { global $conf; - //$importlang=new Translate($this->db); - //if (! empty($conf->global->IMPORT_CSV_FORCE_CHARSET)) $importlang->charset_output=$conf->global->IMPORT_CSV_FORCE_CHARSET; $arrayres=array(); if (version_compare(phpversion(), '5.3') < 0) @@ -207,14 +206,30 @@ class ImportCsv extends ModeleImports { $arrayres=fgetcsv($this->handle,100000,$this->separator,$this->enclosure,$this->escape); } -// var_dump($this->handle); + + //var_dump($this->handle); //var_dump($arrayres);exit; + $newarrayres=array(); if ($arrayres && is_array($arrayres)) { - $this->col=sizeof($arrayres); + foreach($arrayres as $key => $val) + { + if (! empty($conf->global->IMPORT_CSV_FORCE_CHARSET)) // Forced charset + { + if (strtolower($conf->global->IMPORT_CSV_FORCE_CHARSET) == 'utf8') $newarrayres[$key]=$val; + else $newarrayres[$key]=utf8_encode($val); + } + else // Autodetect format (UTF8 or ISO) + { + if (utf8_check($val)) $newarrayres[$key]=$val; + else $newarrayres[$key]=utf8_encode($val); + } + } + + $this->col=sizeof($newarrayres); } - return $arrayres; + return $newarrayres; } /** @@ -228,36 +243,57 @@ class ImportCsv extends ModeleImports /** - * Clean a cell to respect rules of CSV file cells - * @param newvalue String to clean - * @return string Value cleaned + * Insert a record into database + * @param arrayrecord Array of field values + * @param array_match_file_to_database + * @param objimport + * @return int <0 if KO, >0 if OK */ - function csv_clean($newvalue) + function import_insert($arrayrecord,$array_match_file_to_database,$objimport) { - $addquote=0; + $error=0; - // Rule Dolibarr: No HTML - $newvalue=dol_string_nohtmltag($newvalue); - - // Rule 1 CSV: No CR, LF in cells - $newvalue=ereg_replace("\r",'',$newvalue); - $newvalue=ereg_replace("\n",'\n',$newvalue); - - // Rule 2 CSV: If value contains ", we must duplicate ", and add " - if (ereg('"',$newvalue)) + // For each table to insert, me make a separate insert + foreach($objimport->array_import_tables[0] as $alias=>$tablename) { - $addquote=1; - $newvalue=ereg_replace('"','""',$newvalue); + // Build sql request + $sql=''; + $listfields=''; + $listvalues=''; + foreach($array_match_file_to_database as $key => $val) + { + if ($listfields) { $listfields.=', '; $listvalues.=', '; } + $listfields.=$val; + $listvalues.='ee'; + } + if ($listfields) + { + $sql='INSERT INTO '.$tablename.'('.$listfields.') VALUES('.$listvalues.')'; + } + + //print '> '.join(',',$arrayrecord); + print 'sql='.$sql; + print ' '."\n"; + + // Run insert request + if ($sql) + { + $resql=$this->db->query($sql); + if ($resql) + { + print '.'; + } + else + { + print 'E'; + $this->error=$this->db->lasterror(); + $error++; + } + } } - // Rule 3 CSV: If value contains separator, we must add " - if (ereg($this->separator,$newvalue)) - { - $addquote=1; - } - - return ($addquote?'"':'').$newvalue.($addquote?'"':''); - } + return $error?-$error:1; + } } diff --git a/htdocs/includes/modules/import/modules_import.php b/htdocs/includes/modules/import/modules_import.php index 17cc6103410..9442cde9797 100644 --- a/htdocs/includes/modules/import/modules_import.php +++ b/htdocs/includes/modules/import/modules_import.php @@ -36,6 +36,7 @@ class ModeleImports var $error=''; var $driverlabel=array(); + var $driverdesc=array(); var $driverversion=array(); var $liblabel=array(); @@ -55,7 +56,7 @@ class ModeleImports */ function liste_modeles($db) { - dol_syslog("ModeleImport::loadFormat"); + dol_syslog("ModeleImport::liste_modeles"); $dir=DOL_DOCUMENT_ROOT."/includes/modules/import/"; $handle=opendir($dir); diff --git a/htdocs/includes/modules/modProduit.class.php b/htdocs/includes/modules/modProduit.class.php index 24c4fe6fe5e..2fd72389ab4 100644 --- a/htdocs/includes/modules/modProduit.class.php +++ b/htdocs/includes/modules/modProduit.class.php @@ -153,13 +153,13 @@ class modProduit extends DolibarrModules $this->import_code[$r]=$this->rights_class.'_'.$r; $this->import_label[$r]="Products"; // Translation key //$this->import_permission[$r]=array(array("societe","import")); - $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'produit'); + $this->import_tables_array[$r]=array('p'=>MAIN_DB_PREFIX.'product'); $this->import_fields_array[$r]=array('p.ref'=>"Ref*",'p.label'=>"Label*",'p.description'=>"Description",'p.note'=>"Note",'p.price'=>"SellingPriceHT",'p.price_ttc'=>"SellingPriceTTC",'p.tva_tx'=>'VAT','p.envente'=>"OnSell*",'p.duration'=>"Duration"); $this->import_entities_array[$r]=array('p.ref'=>"product",'p.label'=>"product",'p.description'=>"product",'p.note'=>"product",'p.price'=>"product",'p.price_ttc'=>"product",'p.tva_tx'=>'product','p.envente'=>"product",'p.duration'=>"product"); $this->import_examplevalues_array[$r]=array('p.ref'=>"PR123456",'p.label'=>"My product",'p.description'=>"This is a description example for record",'p.note'=>"Some note",'p.price'=>"100",'p.price_ttc'=>"110",'p.tva_tx'=>'10','p.envente'=>"0 or 1",'p.duration'=>"1y"); - $this->import_sql_start[$r]='INSERT INTO '.MAIN_DB_PREFIX.'produit as s'; - $this->import_sql_end[$r] =''; + //$this->import_sql_start[$r]='INSERT INTO '.MAIN_DB_PREFIX.'product as p'; + //$this->import_sql_end[$r] =''; } diff --git a/htdocs/includes/modules/modSociete.class.php b/htdocs/includes/modules/modSociete.class.php index 9e28c8b6222..9f2f24b7c81 100644 --- a/htdocs/includes/modules/modSociete.class.php +++ b/htdocs/includes/modules/modSociete.class.php @@ -237,8 +237,8 @@ class modSociete extends DolibarrModules $this->import_entities_array[$r]=array('s.nom'=>"company",'s.prefix_comm'=>"company",'s.client'=>"company",'s.fournisseur'=>"company",'s.datec'=>"company",'s.code_client'=>"company",'s.code_fournisseur'=>"company",'s.address'=>"company",'s.cp'=>"company",'s.ville'=>"company",'p.code'=>"company",'s.tel'=>"company",'s.fax'=>"company",'s.url'=>"company",'s.email'=>"company",'s.siret'=>"company",'s.siren'=>"company",'s.ape'=>"company",'s.idprof4'=>"company",'s.tva_intra'=>"company",'s.capital'=>"company",'s.note'=>"company",'s.fk_type'=>"company",'s.fk_effectif'=>"company","s.fk_status"=>"company",'s.fk_prospectlevel'=>'company','s.fk_stcomm'=>'company'); $this->import_examplevalues_array[$r]=array('s.nom'=>"A company",'s.prefix_comm'=>"comp",'s.client'=>'0 or 1','s.fournisseur'=>'0 or 1','s.datec'=>dol_print_date(mktime(),'YYYY-MM-DD'),'s.code_client'=>"CU01-0001",'s.code_fournisseur'=>"SU01-0001",'s.address'=>"61 jump street",'s.cp'=>"123456",'s.ville'=>"Big town",'p.code'=>"US",'s.tel'=>"0101010101",'s.fax'=>"0101010102",'s.url'=>"http://mycompany.com",'s.email'=>"test@mycompany.com",'s.siret'=>"",'s.siren'=>"",'s.ape'=>"",'s.idprof4'=>"",'s.tva_intra'=>"FR0123456789",'s.capital'=>"10000",'s.note'=>"This is an example of note for record",'s.fk_type'=>"XXX",'s.fk_effectif'=>"YYY","s.fk_status"=>"ZZZ",'s.fk_prospectlevel'=>'AAA','s.fk_stcomm'=>'BBB'); - $this->import_sql_start[$r]='INSERT INTO '.MAIN_DB_PREFIX.'societe as s'; - $this->import_sql_end[$r] =''; + //$this->import_sql_start[$r]='INSERT INTO '.MAIN_DB_PREFIX.'societe as s'; + //$this->import_sql_end[$r] =''; } diff --git a/htdocs/main.inc.php b/htdocs/main.inc.php index 5bb95991387..752fdd0fd95 100644 --- a/htdocs/main.inc.php +++ b/htdocs/main.inc.php @@ -897,7 +897,7 @@ function top_menu($head, $title='', $target='') $htmltext.=' '.$langs->trans("CurrentUserLanguage").': '.$langs->getDefaultLang(); $htmltext.=' '.$langs->trans("Browser").': '.$conf->browser->name.' ('.$_SERVER['HTTP_USER_AGENT'].')'; if (! empty($conf->browser->phone)) $htmltext.=' '.$langs->trans("Phone").': '.$conf->browser->phone; - + if (! empty($_SESSION["disablemodules"])) $htmltext.=' '.$langs->trans("DisabledModules").': '.join(' ',split(',',$_SESSION["disablemodules"])); // print ' load("help");
$helpbaseurl='';
- if (eregi('^http',$helppagename))
- {
- // If complete URL
- $helpbaseurl='%s';
- $helppage=$helppagename;
- $mode='local';
- }
- else
- {
- // If WIKI URL
- $helppage='';
- if (eregi('^es',$langs->defaultlang))
- {
- $helpbaseurl='http://wiki.dolibarr.org/index.php/%s';
- if (eregi('ES:([^|]+)',$helppagename,$reg)) $helppage=$reg[1];
- }
- if (eregi('^fr',$langs->defaultlang))
- {
- $helpbaseurl='http://wiki.dolibarr.org/index.php/%s';
- if (eregi('FR:([^|]+)',$helppagename,$reg)) $helppage=$reg[1];
- }
- if (empty($helppage)) // If help page not already found
- {
- $helpbaseurl='http://wiki.dolibarr.org/index.php/%s';
- if (eregi('EN:([^|]+)',$helppagename,$reg)) $helppage=$reg[1];
- }
- $mode='wiki';
- }
+ $helppage='';
+ $mode='';
+
+ // Get helpbaseurl, helppage and mode from helppagename and langs
+ $arrayres=getHelpParamFor($helppagename,$langs);
+ $helpbaseurl=$arrayres['helpbaseurl'];
+ $helppage=$arrayres['helppage'];
+ $mode=$arrayres['mode'];
// Link to help pages
if ($helpbaseurl && $helppage)
@@ -1105,6 +1085,43 @@ function left_menu($menu_array, $helppagename='', $moresearchform='')
}
+/**
+ * \brief Return helpbaseurl, helppage and mode
+ * \param helppagename Page name (EN:xxx,ES:eee,FR:fff...)
+ * \param langs Language
+ */
+function getHelpParamFor($helppagename,$langs)
+{
+ if (eregi('^http',$helppagename))
+ {
+ // If complete URL
+ $helpbaseurl='%s';
+ $helppage=$helppagename;
+ $mode='local';
+ }
+ else
+ {
+ // If WIKI URL
+ if (eregi('^es',$langs->defaultlang))
+ {
+ $helpbaseurl='http://wiki.dolibarr.org/index.php/%s';
+ if (eregi('ES:([^|]+)',$helppagename,$reg)) $helppage=$reg[1];
+ }
+ if (eregi('^fr',$langs->defaultlang))
+ {
+ $helpbaseurl='http://wiki.dolibarr.org/index.php/%s';
+ if (eregi('FR:([^|]+)',$helppagename,$reg)) $helppage=$reg[1];
+ }
+ if (empty($helppage)) // If help page not already found
+ {
+ $helpbaseurl='http://wiki.dolibarr.org/index.php/%s';
+ if (eregi('EN:([^|]+)',$helppagename,$reg)) $helppage=$reg[1];
+ }
+ $mode='wiki';
+ }
+ return array('helpbaseurl'=>$helpbaseurl,'helppage'=>$helppage,'mode'=>$mode);
+}
+
/**
* \brief Show a search area
|