65 public function select_language($selected =
'', $htmlname =
'lang_id', $showauto = 0, $filter = array(), $showempty =
'', $showwarning = 0, $disabled = 0, $morecss =
'', $showcode = 0, $forcecombo = 0, $multiselect = 0, $onlykeys = array(), $mainlangonly = 0)
70 if (!empty($conf->global->MAIN_DEFAULT_LANGUAGE_FILTER)) {
71 if (!is_array($filter)) {
74 $filter[$conf->global->MAIN_DEFAULT_LANGUAGE_FILTER] = 1;
77 $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12, 0, $mainlangonly);
81 if ($selected && empty($showempty)) {
82 if (!is_array($selected) && !array_key_exists($selected, $langs_available)) {
83 $tmparray = explode(
'_', $selected);
84 if (!empty($tmparray[1])) {
87 if (empty($selected)) {
88 $selected = $langs->defaultlang;
97 $out .=
'<select '.($multiselect ?
'multiple="multiple" ' :
'').
'class="flat'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.($multiselect ?
'[]' :
'').
'"'.($disabled ?
' disabled' :
'').
'>';
98 if ($showempty && !$multiselect) {
99 if (is_numeric($showempty)) {
100 $out .=
'<option value="0"';
102 $out .=
'<option value="-1"';
104 if ($selected ===
'') {
108 if ($showempty !=
'1') {
116 $out .=
'<option value="auto"';
117 if ($selected ===
'auto') {
120 $out .=
'>'.$langs->trans(
"AutoDetectLang").
'</option>';
123 asort($langs_available);
125 foreach ($langs_available as $key => $value) {
126 $valuetoshow = $value;
127 if ($showcode == 1) {
129 $valuetoshow =
'<span class="opacitymedium">'.preg_replace(
'/[_-].*$/',
'', $key).
'</span> - '.$value;
131 $valuetoshow =
'<span class="opacitymedium">'.$key.
'</span> - '.$value;
134 if ($showcode == 2) {
136 $valuetoshow = $value.
' <span class="opacitymedium">('.preg_replace(
'/[_-].*$/',
'', $key).
')</span>';
138 $valuetoshow = $value.
' <span class="opacitymedium">('.$key.
')</span>';
144 $keytouse = preg_replace(
'/[_-].*$/',
'', $key);
147 if ($filter && is_array($filter) && array_key_exists($keytouse, $filter)) {
150 if ($onlykeys && is_array($onlykeys) && !array_key_exists($keytouse, $onlykeys)) {
155 if ((is_string($selected) && (
string) $selected == (
string) $keytouse) || (is_array($selected) && in_array($keytouse, $selected))) {
156 $out .=
'<option value="'.$keytouse.
'" selected data-html="'.
dol_escape_htmltag($valuetoshow).
'">'.$valuetoshow.
'</option>';
158 $out .=
'<option value="'.$keytouse.
'" data-html="'.
dol_escape_htmltag($valuetoshow).
'">'.$valuetoshow.
'</option>';
165 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
182 public function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib =
'')
185 global $langs, $conf;
191 if (!is_array($dirmenuarray)) {
195 $menuarray = array();
196 foreach ($conf->file->dol_document_root as $dirroot) {
197 foreach ($dirmenuarray as $dirtoscan) {
198 $dir = $dirroot.$dirtoscan;
201 $handle = opendir($dir);
202 if (is_resource($handle)) {
203 while (($file = readdir($handle)) !==
false) {
204 if (is_file($dir.
"/".$file) && substr($file, 0, 1) <>
'.' && substr($file, 0, 3) <>
'CVS' && substr($file, 0, 5) !=
'index') {
205 if (preg_match(
'/lib\.php$/i', $file)) {
208 if (preg_match(
'/eldy_(backoffice|frontoffice)\.php$/i', $file)) {
211 if (preg_match(
'/auguria_(backoffice|frontoffice)\.php$/i', $file)) {
214 if (preg_match(
'/smartphone_(backoffice|frontoffice)\.php$/i', $file)) {
218 $filelib = preg_replace(
'/\.php$/i',
'', $file);
221 if (preg_match(
'/^eldy/i', $file)) {
223 } elseif (preg_match(
'/^smartphone/i', $file)) {
229 if ($file == $selected) {
230 $menuarray[$prefix.
'_'.$file] =
'<option value="'.$file.
'" selected>'.$filelib.
'</option>';
232 $menuarray[$prefix.
'_'.$file] =
'<option value="'.$file.
'">'.$filelib.
'</option>';
244 print
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
246 foreach ($menuarray as $key => $val) {
247 $tab = explode(
'_', $key);
248 $newprefix = $tab[0];
249 if ($newprefix ==
'1' && (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1)) {
252 if ($newprefix ==
'2' && (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2)) {
255 if ($newprefix != $oldprefix) {
257 print
'<option value="-1" disabled>';
258 if ($newprefix ==
'0') {
259 print
'-- '.$langs->trans(
"VersionRecommanded").
' --';
261 if ($newprefix ==
'1') {
262 print
'-- '.$langs->trans(
"VersionExperimental").
' --';
264 if ($newprefix ==
'2') {
265 print
'-- '.$langs->trans(
"VersionDevelopment").
' --';
267 if ($newprefix ==
'3') {
268 print
'-- '.$langs->trans(
"Other").
' --';
271 $oldprefix = $newprefix;
290 global $langs, $conf;
293 $expdevmenu = array();
295 $menuarray = array();
297 foreach ($dirmenuarray as $dirmenu) {
298 foreach ($conf->file->dol_document_root as $dirroot) {
299 $dir = $dirroot.$dirmenu;
301 $handle = opendir($dir);
302 if (is_resource($handle)) {
303 while (($file = readdir($handle)) !==
false) {
304 if (is_file($dir.
"/".$file) && substr($file, 0, 1) <>
'.' && substr($file, 0, 3) <>
'CVS') {
305 $filelib = preg_replace(
'/(_backoffice|_frontoffice)?\.php$/i',
'', $file);
306 if (preg_match(
'/^index/i', $filelib)) {
309 if (preg_match(
'/^default/i', $filelib)) {
312 if (preg_match(
'/^empty/i', $filelib)) {
315 if (preg_match(
'/\.lib/i', $filelib)) {
318 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 0 && in_array($file, $expdevmenu)) {
322 $menuarray[$filelib] = 1;
324 $menuarray[
'all'] = 1;
335 print
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
337 foreach ($menuarray as $key => $val) {
338 $tab = explode(
'_', $key);
339 $newprefix = $tab[0];
340 print
'<option value="'.$key.
'"';
341 if ($key == $selected) {
346 print $langs->trans(
"AllMenus");
350 print
'</option>'.
"\n";
369 global $langs, $conf;
371 print
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
372 print
'<option value="-1"> </option>';
375 "Pacific/Midway"=>
"GMT-11:00",
376 "Pacific/Fakaofo"=>
"GMT-10:00",
377 "America/Anchorage"=>
"GMT-09:00",
378 "America/Los_Angeles"=>
"GMT-08:00",
379 "America/Dawson_Creek"=>
"GMT-07:00",
380 "America/Chicago"=>
"GMT-06:00",
381 "America/Bogota"=>
"GMT-05:00",
382 "America/Anguilla"=>
"GMT-04:00",
383 "America/Araguaina"=>
"GMT-03:00",
384 "America/Noronha"=>
"GMT-02:00",
385 "Atlantic/Azores"=>
"GMT-01:00",
386 "Africa/Abidjan"=>
"GMT+00:00",
387 "Europe/Paris"=>
"GMT+01:00",
388 "Europe/Helsinki"=>
"GMT+02:00",
389 "Europe/Moscow"=>
"GMT+03:00",
390 "Asia/Dubai"=>
"GMT+04:00",
391 "Asia/Karachi"=>
"GMT+05:00",
392 "Indian/Chagos"=>
"GMT+06:00",
393 "Asia/Jakarta"=>
"GMT+07:00",
394 "Asia/Hong_Kong"=>
"GMT+08:00",
395 "Asia/Tokyo"=>
"GMT+09:00",
396 "Australia/Sydney"=>
"GMT+10:00",
397 "Pacific/Noumea"=>
"GMT+11:00",
398 "Pacific/Auckland"=>
"GMT+12:00",
399 "Pacific/Enderbury"=>
"GMT+13:00"
401 foreach ($arraytz as $lib => $gmt) {
402 print
'<option value="'.$lib.
'"';
403 if ($selected == $lib || $selected == $gmt) {
406 print
'>'.$gmt.
'</option>'.
"\n";
424 public function select_paper_format($selected =
'', $htmlname =
'paperformat_id', $filter = 0, $showempty = 0, $forcecombo = 0)
429 $langs->load(
"dict");
431 $sql =
"SELECT code, label, width, height, unit";
432 $sql .=
" FROM ".$this->db->prefix().
"c_paper_format";
433 $sql .=
" WHERE active=1";
435 $sql .=
" AND code LIKE '%".$this->db->escape($filter).
"%'";
438 $resql = $this->db->query($sql);
440 $num = $this->db->num_rows($resql);
443 $obj = $this->db->fetch_object($resql);
444 $unitKey = $langs->trans(
'SizeUnit'.$obj->unit);
446 $paperformat[$obj->code] = $langs->trans(
'PaperFormat'.strtoupper($obj->code)).
' - '.round($obj->width).
'x'.round($obj->height).
' '.($unitKey ==
'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
456 $out .=
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
458 $out .=
'<option value=""';
459 if ($selected ==
'') {
462 $out .=
'> </option>';
464 foreach ($paperformat as $key => $value) {
465 if ($selected == $key) {
466 $out .=
'<option value="'.$key.
'" selected>'.$value.
'</option>';
468 $out .=
'<option value="'.$key.
'">'.$value.
'</option>';
474 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
ajax_combobox($htmlname, $events=array(), $minLengthToAutocomplete=0, $forcefocus=0, $widthTypeOfAutocomplete='resolve', $idforemptyvalue='-1', $morecss='')
Convert a html select field into an ajax combobox.
getLanguageCodeFromCountryCode($countrycode)
Return default language from country code.
picto_from_langcode($codelang, $moreatt='', $notitlealt=0)
Return img flag of country for a language code or country code.
dol_print_error($db='', $error='', $errors=null)
Displays error message system with all the information to facilitate the diagnosis and the escalation...
getDolGlobalInt($key, $default=0)
Return dolibarr global constant int value.
dol_escape_htmltag($stringtoescape, $keepb=0, $keepn=0, $noescapetags='', $escapeonlyhtmltags=0, $cleanalsojavascript=0)
Returns text escaped for inclusion in HTML alt or title or value tags, or into values of HTML input f...