65 public function select_language($selected =
'', $htmlname =
'lang_id', $showauto = 0, $filter =
null, $showempty =
'', $showwarning = 0, $disabled = 0, $morecss =
'', $showcode = 0, $forcecombo = 0, $multiselect = 0, $onlykeys =
null, $mainlangonly = 0)
70 if (!empty($conf->global->MAIN_DEFAULT_LANGUAGE_FILTER)) {
71 $filter[$conf->global->MAIN_DEFAULT_LANGUAGE_FILTER] = 1;
74 $langs_available = $langs->get_available_languages(DOL_DOCUMENT_ROOT, 12, 0, $mainlangonly);
78 if ($selected && empty($showempty)) {
79 if (!is_array($selected) && !array_key_exists($selected, $langs_available)) {
80 $tmparray = explode(
'_', $selected);
81 if (!empty($tmparray[1])) {
84 if (empty($selected)) {
85 $selected = $langs->defaultlang;
94 $out .=
'<select '.($multiselect ?
'multiple="multiple" ' :
'').
'class="flat'.($morecss ?
' '.$morecss :
'').
'" id="'.$htmlname.
'" name="'.$htmlname.($multiselect ?
'[]' :
'').
'"'.($disabled ?
' disabled' :
'').
'>';
95 if ($showempty && !$multiselect) {
96 if (is_numeric($showempty)) {
97 $out .=
'<option value="0"';
99 $out .=
'<option value="-1"';
101 if ($selected ===
'') {
105 if ($showempty !=
'1') {
113 $out .=
'<option value="auto"';
114 if ($selected ===
'auto') {
117 $out .=
'>'.$langs->trans(
"AutoDetectLang").
'</option>';
120 asort($langs_available);
122 foreach ($langs_available as $key => $value) {
123 $valuetoshow = $value;
124 if ($showcode == 1) {
126 $valuetoshow =
'<span class="opacitymedium">'.preg_replace(
'/[_-].*$/',
'', $key).
'</span> - '.$value;
128 $valuetoshow =
'<span class="opacitymedium">'.$key.
'</span> - '.$value;
131 if ($showcode == 2) {
133 $valuetoshow = $value.
' <span class="opacitymedium">('.preg_replace(
'/[_-].*$/',
'', $key).
')</span>';
135 $valuetoshow = $value.
' <span class="opacitymedium">('.$key.
')</span>';
141 $keytouse = preg_replace(
'/[_-].*$/',
'', $key);
144 if ($filter && is_array($filter) && array_key_exists($keytouse, $filter)) {
147 if ($onlykeys && is_array($onlykeys) && !array_key_exists($keytouse, $onlykeys)) {
152 if ((is_string($selected) && (
string) $selected == (
string) $keytouse) || (is_array($selected) && in_array($keytouse, $selected))) {
153 $out .=
'<option value="'.$keytouse.
'" selected data-html="'.
dol_escape_htmltag($valuetoshow).
'">'.$valuetoshow.
'</option>';
155 $out .=
'<option value="'.$keytouse.
'" data-html="'.
dol_escape_htmltag($valuetoshow).
'">'.$valuetoshow.
'</option>';
162 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';
179 public function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib =
'')
182 global $langs, $conf;
188 if (!is_array($dirmenuarray)) {
192 $menuarray = array();
193 foreach ($conf->file->dol_document_root as $dirroot) {
194 foreach ($dirmenuarray as $dirtoscan) {
195 $dir = $dirroot.$dirtoscan;
198 $handle = opendir($dir);
199 if (is_resource($handle)) {
200 while (($file = readdir($handle)) !==
false) {
201 if (is_file($dir.
"/".$file) && substr($file, 0, 1) <>
'.' && substr($file, 0, 3) <>
'CVS' && substr($file, 0, 5) !=
'index') {
202 if (preg_match(
'/lib\.php$/i', $file)) {
205 if (preg_match(
'/eldy_(backoffice|frontoffice)\.php$/i', $file)) {
208 if (preg_match(
'/auguria_(backoffice|frontoffice)\.php$/i', $file)) {
211 if (preg_match(
'/smartphone_(backoffice|frontoffice)\.php$/i', $file)) {
215 $filelib = preg_replace(
'/\.php$/i',
'', $file);
218 if (preg_match(
'/^eldy/i', $file)) {
220 } elseif (preg_match(
'/^smartphone/i', $file)) {
226 if ($file == $selected) {
227 $menuarray[$prefix.
'_'.$file] =
'<option value="'.$file.
'" selected>'.$filelib.
'</option>';
229 $menuarray[$prefix.
'_'.$file] =
'<option value="'.$file.
'">'.$filelib.
'</option>';
241 print
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'"'.($moreattrib ?
' '.$moreattrib :
'').
'>';
243 foreach ($menuarray as $key => $val) {
244 $tab = explode(
'_', $key);
245 $newprefix = $tab[0];
246 if ($newprefix ==
'1' && (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 1)) {
249 if ($newprefix ==
'2' && (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') < 2)) {
252 if ($newprefix != $oldprefix) {
254 print
'<option value="-1" disabled>';
255 if ($newprefix ==
'0') {
256 print
'-- '.$langs->trans(
"VersionRecommanded").
' --';
258 if ($newprefix ==
'1') {
259 print
'-- '.$langs->trans(
"VersionExperimental").
' --';
261 if ($newprefix ==
'2') {
262 print
'-- '.$langs->trans(
"VersionDevelopment").
' --';
264 if ($newprefix ==
'3') {
265 print
'-- '.$langs->trans(
"Other").
' --';
268 $oldprefix = $newprefix;
287 global $langs, $conf;
290 $expdevmenu = array();
292 $menuarray = array();
294 foreach ($dirmenuarray as $dirmenu) {
295 foreach ($conf->file->dol_document_root as $dirroot) {
296 $dir = $dirroot.$dirmenu;
298 $handle = opendir($dir);
299 if (is_resource($handle)) {
300 while (($file = readdir($handle)) !==
false) {
301 if (is_file($dir.
"/".$file) && substr($file, 0, 1) <>
'.' && substr($file, 0, 3) <>
'CVS') {
302 $filelib = preg_replace(
'/(_backoffice|_frontoffice)?\.php$/i',
'', $file);
303 if (preg_match(
'/^index/i', $filelib)) {
306 if (preg_match(
'/^default/i', $filelib)) {
309 if (preg_match(
'/^empty/i', $filelib)) {
312 if (preg_match(
'/\.lib/i', $filelib)) {
315 if (
getDolGlobalInt(
'MAIN_FEATURES_LEVEL') == 0 && in_array($file, $expdevmenu)) {
319 $menuarray[$filelib] = 1;
321 $menuarray[
'all'] = 1;
332 print
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
334 foreach ($menuarray as $key => $val) {
335 $tab = explode(
'_', $key);
336 $newprefix = $tab[0];
337 print
'<option value="'.$key.
'"';
338 if ($key == $selected) {
343 print $langs->trans(
"AllMenus");
347 print
'</option>'.
"\n";
366 global $langs, $conf;
368 print
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
369 print
'<option value="-1"> </option>';
372 "Pacific/Midway"=>
"GMT-11:00",
373 "Pacific/Fakaofo"=>
"GMT-10:00",
374 "America/Anchorage"=>
"GMT-09:00",
375 "America/Los_Angeles"=>
"GMT-08:00",
376 "America/Dawson_Creek"=>
"GMT-07:00",
377 "America/Chicago"=>
"GMT-06:00",
378 "America/Bogota"=>
"GMT-05:00",
379 "America/Anguilla"=>
"GMT-04:00",
380 "America/Araguaina"=>
"GMT-03:00",
381 "America/Noronha"=>
"GMT-02:00",
382 "Atlantic/Azores"=>
"GMT-01:00",
383 "Africa/Abidjan"=>
"GMT+00:00",
384 "Europe/Paris"=>
"GMT+01:00",
385 "Europe/Helsinki"=>
"GMT+02:00",
386 "Europe/Moscow"=>
"GMT+03:00",
387 "Asia/Dubai"=>
"GMT+04:00",
388 "Asia/Karachi"=>
"GMT+05:00",
389 "Indian/Chagos"=>
"GMT+06:00",
390 "Asia/Jakarta"=>
"GMT+07:00",
391 "Asia/Hong_Kong"=>
"GMT+08:00",
392 "Asia/Tokyo"=>
"GMT+09:00",
393 "Australia/Sydney"=>
"GMT+10:00",
394 "Pacific/Noumea"=>
"GMT+11:00",
395 "Pacific/Auckland"=>
"GMT+12:00",
396 "Pacific/Enderbury"=>
"GMT+13:00"
398 foreach ($arraytz as $lib => $gmt) {
399 print
'<option value="'.$lib.
'"';
400 if ($selected == $lib || $selected == $gmt) {
403 print
'>'.$gmt.
'</option>'.
"\n";
421 public function select_paper_format($selected =
'', $htmlname =
'paperformat_id', $filter = 0, $showempty = 0, $forcecombo = 0)
426 $langs->load(
"dict");
428 $sql =
"SELECT code, label, width, height, unit";
429 $sql .=
" FROM ".$this->db->prefix().
"c_paper_format";
430 $sql .=
" WHERE active=1";
432 $sql .=
" AND code LIKE '%".$this->db->escape($filter).
"%'";
435 $resql = $this->db->query(
$sql);
437 $num = $this->db->num_rows($resql);
440 $obj = $this->db->fetch_object($resql);
441 $unitKey = $langs->trans(
'SizeUnit'.$obj->unit);
443 $paperformat[$obj->code] = $langs->trans(
'PaperFormat'.strtoupper($obj->code)).
' - '.round($obj->width).
'x'.round($obj->height).
' '.($unitKey ==
'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
453 $out .=
'<select class="flat" id="'.$htmlname.
'" name="'.$htmlname.
'">';
455 $out .=
'<option value=""';
456 if ($selected ==
'') {
459 $out .=
'> </option>';
461 foreach ($paperformat as $key => $value) {
462 if ($selected == $key) {
463 $out .=
'<option value="'.$key.
'" selected>'.$value.
'</option>';
465 $out .=
'<option value="'.$key.
'">'.$value.
'</option>';
471 include_once DOL_DOCUMENT_ROOT.
'/core/lib/ajax.lib.php';