forked from Wavyzz/dolibarr
update
This commit is contained in:
@@ -29,40 +29,40 @@
|
||||
*/
|
||||
class FormAdmin
|
||||
{
|
||||
public $db;
|
||||
public $error;
|
||||
public $db;
|
||||
public $error;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
*
|
||||
* @param DoliDB $db Database handler
|
||||
*/
|
||||
public function __construct($db)
|
||||
{
|
||||
$this->db = $db;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return html select list with available languages (key='en_US', value='United States' for example)
|
||||
*
|
||||
* @param string $selected Language pre-selected
|
||||
* @param string $htmlname Name of HTML select
|
||||
* @param int $showauto Show 'auto' choice
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return html select list with available languages (key='en_US', value='United States' for example)
|
||||
*
|
||||
* @param string $selected Language pre-selected
|
||||
* @param string $htmlname Name of HTML select
|
||||
* @param int $showauto Show 'auto' choice
|
||||
* @param array $filter Array of keys to exclude in list (opposite of $onlykeys)
|
||||
* @param string $showempty '1'=Add empty value or string to show
|
||||
* @param string $showempty '1'=Add empty value or 'string to show'
|
||||
* @param int $showwarning Show a warning if language is not complete
|
||||
* @param int $disabled Disable edit of select
|
||||
* @param string $morecss Add more css styles
|
||||
* @param int $showcode 1=Add language code into label at begining, 2=Add language code into label at end
|
||||
* @param int $forcecombo Force to use combo box (so no ajax beautify effect)
|
||||
* @param int $multiselect Make the combo a multiselect
|
||||
* @param array $onlykeys Show only the following keys (opposite of $filter). Example array('fr', 'es', ...)
|
||||
* @param int $mainlangonly 1=Show only main languages ('fr_FR' no' fr_BE', 'es_ES' not 'es_MX', ...)
|
||||
* @return string Return HTML select string with list of languages
|
||||
*/
|
||||
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)
|
||||
* @param int $forcecombo Force to use combo box (so no ajax beautify effect)
|
||||
* @param int $multiselect Make the combo a multiselect
|
||||
* @param array $onlykeys Array of language keys to restrict list with the following keys (opposite of $filter). Example array('fr', 'es', ...)
|
||||
* @param int $mainlangonly 1=Show only main languages ('fr_FR' no' fr_BE', 'es_ES' not 'es_MX', ...)
|
||||
* @return string Return HTML select string with list of languages
|
||||
*/
|
||||
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)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $conf, $langs;
|
||||
@@ -95,10 +95,13 @@ class FormAdmin
|
||||
foreach ($langs_available as $key => $value)
|
||||
{
|
||||
$valuetoshow = $value;
|
||||
if ($showcode == 1) $valuetoshow = $key.' - '.$value;
|
||||
if ($showcode == 1) {
|
||||
if ($mainlangonly) $valuetoshow = '<span class="opacitymedium">'.preg_replace('/[_-].*$/', '', $key).'</span> - '.$value;
|
||||
else $valuetoshow = '<span class="opacitymedium">'.$key.'</span> - '.$value;
|
||||
}
|
||||
if ($showcode == 2) {
|
||||
if ($mainlangonly) $valuetoshow = $value.' ('.preg_replace('/[_-].*$/', '', $key).')';
|
||||
else $valuetoshow = $value.' ('.$key.')';
|
||||
if ($mainlangonly) $valuetoshow = $value.' <span class="opacitymedium">('.preg_replace('/[_-].*$/', '', $key).')</span>';
|
||||
else $valuetoshow = $value.' <span class="opacitymedium">('.$key.')</span>';
|
||||
}
|
||||
|
||||
$keytouse = $key;
|
||||
@@ -111,11 +114,11 @@ class FormAdmin
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($selected == $keytouse)
|
||||
{
|
||||
$out .= '<option value="'.$keytouse.'" selected>'.$valuetoshow.'</option>';
|
||||
$valuetoshow .= ' '.picto_from_langcode($key, 'class="saturatemedium"');
|
||||
if ($selected == $keytouse) {
|
||||
$out .= '<option value="'.$keytouse.'" selected data-html="'.dol_escape_htmltag($valuetoshow).'">'.$valuetoshow.'</option>';
|
||||
} else {
|
||||
$out .= '<option value="'.$keytouse.'">'.$valuetoshow.'</option>';
|
||||
$out .= '<option value="'.$keytouse.'" data-html="'.dol_escape_htmltag($valuetoshow).'">'.$valuetoshow.'</option>';
|
||||
}
|
||||
}
|
||||
$out .= '</select>';
|
||||
@@ -130,73 +133,73 @@ class FormAdmin
|
||||
return $out;
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return list of available menus (eldy_backoffice, ...)
|
||||
*
|
||||
* @param string $selected Preselected menu value
|
||||
* @param string $htmlname Name of html select
|
||||
* @param array $dirmenuarray Array of directories to scan
|
||||
* @param string $moreattrib More attributes on html select tag
|
||||
* @return integer|null
|
||||
*/
|
||||
public function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib = '')
|
||||
{
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return list of available menus (eldy_backoffice, ...)
|
||||
*
|
||||
* @param string $selected Preselected menu value
|
||||
* @param string $htmlname Name of html select
|
||||
* @param array $dirmenuarray Array of directories to scan
|
||||
* @param string $moreattrib More attributes on html select tag
|
||||
* @return integer|null
|
||||
*/
|
||||
public function select_menu($selected, $htmlname, $dirmenuarray, $moreattrib = '')
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
global $langs, $conf;
|
||||
|
||||
// Clean parameters
|
||||
// Clean parameters
|
||||
|
||||
|
||||
// Check parameters
|
||||
if (!is_array($dirmenuarray)) return -1;
|
||||
// Check parameters
|
||||
if (!is_array($dirmenuarray)) return -1;
|
||||
|
||||
$menuarray = array();
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
{
|
||||
foreach ($dirmenuarray as $dirtoscan)
|
||||
{
|
||||
$dir = $dirroot.$dirtoscan;
|
||||
//print $dir.'<br>';
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && substr($file, 0, 5) != 'index')
|
||||
{
|
||||
if (preg_match('/lib\.php$/i', $file)) continue; // We exclude library files
|
||||
if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files
|
||||
if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files
|
||||
if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
{
|
||||
foreach ($dirmenuarray as $dirtoscan)
|
||||
{
|
||||
$dir = $dirroot.$dirtoscan;
|
||||
//print $dir.'<br>';
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS' && substr($file, 0, 5) != 'index')
|
||||
{
|
||||
if (preg_match('/lib\.php$/i', $file)) continue; // We exclude library files
|
||||
if (preg_match('/eldy_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files
|
||||
if (preg_match('/auguria_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files
|
||||
if (preg_match('/smartphone_(backoffice|frontoffice)\.php$/i', $file)) continue; // We exclude all menu manager files
|
||||
|
||||
$filelib = preg_replace('/\.php$/i', '', $file);
|
||||
$prefix = '';
|
||||
// 0=Recommanded, 1=Experimental, 2=Developpement, 3=Other
|
||||
if (preg_match('/^eldy/i', $file)) $prefix = '0';
|
||||
elseif (preg_match('/^smartphone/i', $file)) $prefix = '2';
|
||||
else $prefix = '3';
|
||||
$filelib = preg_replace('/\.php$/i', '', $file);
|
||||
$prefix = '';
|
||||
// 0=Recommanded, 1=Experimental, 2=Developpement, 3=Other
|
||||
if (preg_match('/^eldy/i', $file)) $prefix = '0';
|
||||
elseif (preg_match('/^smartphone/i', $file)) $prefix = '2';
|
||||
else $prefix = '3';
|
||||
|
||||
if ($file == $selected)
|
||||
{
|
||||
$menuarray[$prefix.'_'.$file] = '<option value="'.$file.'" selected>'.$filelib.'</option>';
|
||||
} else {
|
||||
$menuarray[$prefix.'_'.$file] = '<option value="'.$file.'">'.$filelib.'</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if ($file == $selected)
|
||||
{
|
||||
$menuarray[$prefix.'_'.$file] = '<option value="'.$file.'" selected>'.$filelib.'</option>';
|
||||
} else {
|
||||
$menuarray[$prefix.'_'.$file] = '<option value="'.$file.'">'.$filelib.'</option>';
|
||||
}
|
||||
}
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
ksort($menuarray);
|
||||
|
||||
// Output combo list of menus
|
||||
print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
|
||||
$oldprefix = '';
|
||||
print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'"'.($moreattrib ? ' '.$moreattrib : '').'>';
|
||||
$oldprefix = '';
|
||||
foreach ($menuarray as $key => $val)
|
||||
{
|
||||
$tab = explode('_', $key);
|
||||
@@ -208,7 +211,7 @@ class FormAdmin
|
||||
// Affiche titre
|
||||
print '<option value="-1" disabled>';
|
||||
if ($newprefix == '0') print '-- '.$langs->trans("VersionRecommanded").' --';
|
||||
if ($newprefix == '1') print '-- '.$langs->trans("VersionExperimental").' --';
|
||||
if ($newprefix == '1') print '-- '.$langs->trans("VersionExperimental").' --';
|
||||
if ($newprefix == '2') print '-- '.$langs->trans("VersionDevelopment").' --';
|
||||
if ($newprefix == '3') print '-- '.$langs->trans("Other").' --';
|
||||
print '</option>';
|
||||
@@ -217,69 +220,69 @@ class FormAdmin
|
||||
print $val."\n"; // Show menu entry
|
||||
}
|
||||
print '</select>';
|
||||
}
|
||||
}
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return combo list of available menu families
|
||||
*
|
||||
* @param string $selected Menu pre-selected
|
||||
* @param string $htmlname Name of html select
|
||||
* @param string[] $dirmenuarray Directories to scan
|
||||
* @return void
|
||||
*/
|
||||
public function select_menu_families($selected, $htmlname, $dirmenuarray)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return combo list of available menu families
|
||||
*
|
||||
* @param string $selected Menu pre-selected
|
||||
* @param string $htmlname Name of html select
|
||||
* @param string[] $dirmenuarray Directories to scan
|
||||
* @return void
|
||||
*/
|
||||
public function select_menu_families($selected, $htmlname, $dirmenuarray)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
|
||||
//$expdevmenu=array('smartphone_backoffice.php','smartphone_frontoffice.php'); // Menu to disable if $conf->global->MAIN_FEATURES_LEVEL is not set
|
||||
$expdevmenu = array();
|
||||
//$expdevmenu=array('smartphone_backoffice.php','smartphone_frontoffice.php'); // Menu to disable if $conf->global->MAIN_FEATURES_LEVEL is not set
|
||||
$expdevmenu = array();
|
||||
|
||||
$menuarray = array();
|
||||
|
||||
foreach ($dirmenuarray as $dirmenu)
|
||||
{
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
{
|
||||
$dir = $dirroot.$dirmenu;
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
|
||||
{
|
||||
$filelib = preg_replace('/(_backoffice|_frontoffice)?\.php$/i', '', $file);
|
||||
if (preg_match('/^index/i', $filelib)) continue;
|
||||
if (preg_match('/^default/i', $filelib)) continue;
|
||||
if (preg_match('/^empty/i', $filelib)) continue;
|
||||
if (preg_match('/\.lib/i', $filelib)) continue;
|
||||
if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file, $expdevmenu)) continue;
|
||||
foreach ($conf->file->dol_document_root as $dirroot)
|
||||
{
|
||||
$dir = $dirroot.$dirmenu;
|
||||
if (is_dir($dir))
|
||||
{
|
||||
$handle = opendir($dir);
|
||||
if (is_resource($handle))
|
||||
{
|
||||
while (($file = readdir($handle)) !== false)
|
||||
{
|
||||
if (is_file($dir."/".$file) && substr($file, 0, 1) <> '.' && substr($file, 0, 3) <> 'CVS')
|
||||
{
|
||||
$filelib = preg_replace('/(_backoffice|_frontoffice)?\.php$/i', '', $file);
|
||||
if (preg_match('/^index/i', $filelib)) continue;
|
||||
if (preg_match('/^default/i', $filelib)) continue;
|
||||
if (preg_match('/^empty/i', $filelib)) continue;
|
||||
if (preg_match('/\.lib/i', $filelib)) continue;
|
||||
if (empty($conf->global->MAIN_FEATURES_LEVEL) && in_array($file, $expdevmenu)) continue;
|
||||
|
||||
$menuarray[$filelib] = 1;
|
||||
}
|
||||
$menuarray['all'] = 1;
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
$menuarray[$filelib] = 1;
|
||||
}
|
||||
$menuarray['all'] = 1;
|
||||
}
|
||||
closedir($handle);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
ksort($menuarray);
|
||||
|
||||
// Affichage liste deroulante des menus
|
||||
print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
$oldprefix = '';
|
||||
print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
$oldprefix = '';
|
||||
foreach ($menuarray as $key => $val)
|
||||
{
|
||||
$tab = explode('_', $key);
|
||||
$newprefix = $tab[0];
|
||||
print '<option value="'.$key.'"';
|
||||
if ($key == $selected)
|
||||
if ($key == $selected)
|
||||
{
|
||||
print ' selected';
|
||||
}
|
||||
@@ -289,26 +292,26 @@ class FormAdmin
|
||||
print '</option>'."\n";
|
||||
}
|
||||
print '</select>';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return a HTML select list of timezones
|
||||
*
|
||||
* @param string $selected Menu pre-selectionnee
|
||||
* @param string $htmlname Nom de la zone select
|
||||
* @return void
|
||||
*/
|
||||
public function select_timezone($selected, $htmlname)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return a HTML select list of timezones
|
||||
*
|
||||
* @param string $selected Menu pre-selectionnee
|
||||
* @param string $htmlname Nom de la zone select
|
||||
* @return void
|
||||
*/
|
||||
public function select_timezone($selected, $htmlname)
|
||||
{
|
||||
// phpcs:enable
|
||||
global $langs, $conf;
|
||||
|
||||
print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
print '<option value="-1"> </option>';
|
||||
print '<select class="flat" id="'.$htmlname.'" name="'.$htmlname.'">';
|
||||
print '<option value="-1"> </option>';
|
||||
|
||||
$arraytz = array(
|
||||
$arraytz = array(
|
||||
"Pacific/Midway"=>"GMT-11:00",
|
||||
"Pacific/Fakaofo"=>"GMT-10:00",
|
||||
"America/Anchorage"=>"GMT-09:00",
|
||||
@@ -335,17 +338,17 @@ class FormAdmin
|
||||
"Pacific/Auckland"=>"GMT+12:00",
|
||||
"Pacific/Enderbury"=>"GMT+13:00"
|
||||
);
|
||||
foreach ($arraytz as $lib => $gmt) {
|
||||
print '<option value="'.$lib.'"';
|
||||
if ($selected == $lib || $selected == $gmt) print ' selected';
|
||||
print '>'.$gmt.'</option>'."\n";
|
||||
}
|
||||
print '</select>';
|
||||
}
|
||||
foreach ($arraytz as $lib => $gmt) {
|
||||
print '<option value="'.$lib.'"';
|
||||
if ($selected == $lib || $selected == $gmt) print ' selected';
|
||||
print '>'.$gmt.'</option>'."\n";
|
||||
}
|
||||
print '</select>';
|
||||
}
|
||||
|
||||
|
||||
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
// phpcs:disable PEAR.NamingConventions.ValidFunctionName.ScopeNotCamelCaps
|
||||
/**
|
||||
* Return html select list with available languages (key='en_US', value='United States' for example)
|
||||
*
|
||||
@@ -365,23 +368,23 @@ class FormAdmin
|
||||
$sql = "SELECT code, label, width, height, unit";
|
||||
$sql .= " FROM ".MAIN_DB_PREFIX."c_paper_format";
|
||||
$sql .= " WHERE active=1";
|
||||
if ($filter) $sql .= " AND code LIKE '%".$this->db->escape($filter)."%'";
|
||||
if ($filter) $sql .= " AND code LIKE '%".$this->db->escape($filter)."%'";
|
||||
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$unitKey = $langs->trans('SizeUnit'.$obj->unit);
|
||||
$resql = $this->db->query($sql);
|
||||
if ($resql)
|
||||
{
|
||||
$num = $this->db->num_rows($resql);
|
||||
$i = 0;
|
||||
while ($i < $num)
|
||||
{
|
||||
$obj = $this->db->fetch_object($resql);
|
||||
$unitKey = $langs->trans('SizeUnit'.$obj->unit);
|
||||
|
||||
$paperformat[$obj->code] = $langs->trans('PaperFormat'.strtoupper($obj->code)).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
|
||||
$paperformat[$obj->code] = $langs->trans('PaperFormat'.strtoupper($obj->code)).' - '.round($obj->width).'x'.round($obj->height).' '.($unitKey == 'SizeUnit'.$obj->unit ? $obj->unit : $unitKey);
|
||||
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
$i++;
|
||||
}
|
||||
} else {
|
||||
dol_print_error($this->db);
|
||||
return '';
|
||||
}
|
||||
@@ -396,7 +399,7 @@ class FormAdmin
|
||||
}
|
||||
foreach ($paperformat as $key => $value)
|
||||
{
|
||||
if ($selected == $key)
|
||||
if ($selected == $key)
|
||||
{
|
||||
$out .= '<option value="'.$key.'" selected>'.$value.'</option>';
|
||||
} else {
|
||||
|
||||
Reference in New Issue
Block a user