mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2026-01-06 09:02:59 +01:00
Merge branch 'develop' of github.com:Dolibarr/dolibarr into dev_sign_soeciete_rib
This commit is contained in:
@@ -3133,7 +3133,7 @@ function dol_print_size($size, $shortvalue = 0, $shortunit = 0)
|
||||
* @param string $morecss More CSS
|
||||
* @return string HTML Link
|
||||
*/
|
||||
function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0, $morecss = 'float')
|
||||
function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0, $morecss = '')
|
||||
{
|
||||
global $langs;
|
||||
|
||||
@@ -3141,26 +3141,30 @@ function dol_print_url($url, $target = '_blank', $max = 32, $withpicto = 0, $mor
|
||||
return '';
|
||||
}
|
||||
|
||||
$link = '<a href="';
|
||||
$linkstart = '<a href="';
|
||||
if (!preg_match('/^http/i', $url)) {
|
||||
$link .= 'http://';
|
||||
$linkstart .= 'http://';
|
||||
}
|
||||
$link .= $url;
|
||||
$link .= '"';
|
||||
$linkstart .= $url;
|
||||
$linkstart .= '"';
|
||||
if ($target) {
|
||||
$link .= ' target="'.$target.'"';
|
||||
$linkstart .= ' target="'.$target.'"';
|
||||
}
|
||||
$link .= '>';
|
||||
$linkstart .= ' title="'.$langs->trans("URL").': '.$url.'"';
|
||||
$linkstart .= '>';
|
||||
|
||||
$link = '';
|
||||
if (!preg_match('/^http/i', $url)) {
|
||||
$link .= 'http://';
|
||||
}
|
||||
$link .= dol_trunc($url, $max);
|
||||
$link .= '</a>';
|
||||
|
||||
if ($morecss == 'float') {
|
||||
$linkend = '</a>';
|
||||
|
||||
if ($morecss == 'float') { // deprecated
|
||||
return '<div class="nospan'.($morecss ? ' '.$morecss : '').'" style="margin-right: 10px">'.($withpicto ?img_picto($langs->trans("Url"), 'globe').' ' : '').$link.'</div>';
|
||||
} else {
|
||||
return '<span class="nospan'.($morecss ? ' '.$morecss : '').'" style="margin-right: 10px">'.($withpicto ?img_picto($langs->trans("Url"), 'globe').' ' : '').$link.'</span>';
|
||||
return $linkstart.'<span class="nospan'.($morecss ? ' '.$morecss : '').'" style="margin-right: 10px">'.($withpicto ?img_picto('', 'globe').' ' : '').$link.'</span>'.$linkend;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3706,7 +3710,7 @@ function dol_print_phone($phone, $countrycode = '', $cid = 0, $socid = 0, $addli
|
||||
*/
|
||||
function dol_print_ip($ip, $mode = 0)
|
||||
{
|
||||
global $conf, $langs;
|
||||
global $langs;
|
||||
|
||||
$ret = '';
|
||||
|
||||
@@ -7337,7 +7341,7 @@ function dolGetFirstLineOfText($text, $nboflines = 1, $charset = 'UTF-8')
|
||||
* @param int $nl2brmode 0=Adding br before \n, 1=Replacing \n by br
|
||||
* @param bool $forxml false=Use <br>, true=Use <br />
|
||||
* @return string String encoded
|
||||
* @see dol_nboflines(), dolGetFirstLineOfText()
|
||||
* @see dol_htmlentitiesbr(), dol_nboflines(), dolGetFirstLineOfText()
|
||||
*/
|
||||
function dol_nl2br($stringtoencode, $nl2brmode = 0, $forxml = false)
|
||||
{
|
||||
@@ -7461,7 +7465,7 @@ function dol_htmlwithnojs($stringtoencode, $nouseofiframesandbox = 0, $check = '
|
||||
* is used to build PDF, nl2brmode must be 1.
|
||||
* Note: When we output string on pages, we should use
|
||||
* - dol_htmlwithnojs(dol_string_onlythesehtmltags(dol_htmlentitiesbr(), 1, 1, 1)) for notes,
|
||||
* - dol_escape_htmltag() for simple labels.
|
||||
* - dol_escape_htmltag(dol_htmlentitiesbr()) for simple labels.
|
||||
*
|
||||
* @param string $stringtoencode String to encode
|
||||
* @param int $nl2brmode 0=Adding br before \n, 1=Replacing \n by br (for use with FPDF writeHTMLCell function for example)
|
||||
|
||||
@@ -615,6 +615,52 @@ function reWriteAllPermissions($file, $permissions, $key, $right, $objectname, $
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Converts a formatted properties string into an associative array.
|
||||
*
|
||||
* @param string $string The formatted properties string.
|
||||
* @return array The resulting associative array.
|
||||
*/
|
||||
function parsePropertyString($string)
|
||||
{
|
||||
|
||||
$string = str_replace("'", '', $string);
|
||||
|
||||
// Uses a regular expression to capture keys and values
|
||||
preg_match_all('/\s*([^\s=>]+)\s*=>\s*([^,]+),?/', $string, $matches, PREG_SET_ORDER);
|
||||
$propertyArray = [];
|
||||
|
||||
foreach ($matches as $match) {
|
||||
$key = trim($match[1]);
|
||||
$value = trim($match[2]);
|
||||
|
||||
if (strpos($value, 'array(') === 0) {
|
||||
$nestedArray = substr($value, 6);
|
||||
$nestedArray = parsePropertyString($nestedArray);
|
||||
$value = $nestedArray;
|
||||
} elseif (strpos($value, '"Id")') !== false) {
|
||||
$value = str_replace(')', '', $value);
|
||||
} else {
|
||||
if (is_numeric($value)) {
|
||||
if (strpos($value, '.') !== false) {
|
||||
$value = (float) $value;
|
||||
} else {
|
||||
$value = (int) $value;
|
||||
}
|
||||
} else {
|
||||
if ($value === 'true') {
|
||||
$value = true;
|
||||
} elseif ($value === 'false') {
|
||||
$value = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
$propertyArray[$key] = $value;
|
||||
}
|
||||
|
||||
return $propertyArray;
|
||||
}
|
||||
|
||||
/**
|
||||
* Write all properties of the object in AsciiDoc format
|
||||
* @param string $file path of the class
|
||||
@@ -626,7 +672,7 @@ function writePropsInAsciiDoc($file, $objectname, $destfile)
|
||||
{
|
||||
|
||||
// stock all properties in array
|
||||
$attributesUnique = array ('label', 'type', 'arrayofkeyval', 'notnull', 'default', 'index', 'foreignkey', 'position', 'enabled', 'visible', 'noteditable', 'alwayseditable', 'searchall', 'isameasure', 'css','cssview','csslist', 'help', 'showoncombobox', 'validate','comment','picto' );
|
||||
$attributesUnique = array ('type','label', 'enabled', 'position', 'notnull', 'visible', 'noteditable', 'index', 'default' , 'foreignkey', 'arrayofkeyval', 'alwayseditable','validate', 'searchall','comment', 'isameasure', 'css', 'cssview','csslist', 'help', 'showoncombobox','picto' );
|
||||
|
||||
$start = "public \$fields=array(";
|
||||
$end = ");";
|
||||
@@ -657,32 +703,53 @@ function writePropsInAsciiDoc($file, $objectname, $destfile)
|
||||
$table .= "|".$attUnique;
|
||||
}
|
||||
$table .="\n";
|
||||
$valuesModif = array();
|
||||
foreach ($keys as $string) {
|
||||
$string = trim($string, "'");
|
||||
$string = rtrim($string, ",");
|
||||
$array = eval("return [$string];");
|
||||
|
||||
// check if is array after cleaning string
|
||||
$array = parsePropertyString($string);
|
||||
|
||||
// Iterate through the array to merge all key to one array
|
||||
$code = '';
|
||||
foreach ($array as $key => $value) {
|
||||
if (is_array($value)) {
|
||||
$code = $key;
|
||||
continue;
|
||||
} else {
|
||||
$array[$code][$key] = $value;
|
||||
unset($array[$key]);
|
||||
}
|
||||
}
|
||||
// check if is array after parsing the string
|
||||
if (!is_array($array)) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
$field = array_keys($array);
|
||||
if ($field[0] === '') {
|
||||
$field[0] = 'label';
|
||||
}
|
||||
$values = array_values($array)[0];
|
||||
|
||||
// check each field has all properties and add it if missed
|
||||
foreach ($attributesUnique as $attUnique) {
|
||||
if ($attUnique == 'type' && $field[0] === 'label') {
|
||||
$values[$attUnique] = 'varchar(255)';
|
||||
}
|
||||
if (!array_key_exists($attUnique, $values)) {
|
||||
$values[$attUnique] = '';
|
||||
$valuesModif[$attUnique] = '';
|
||||
} else {
|
||||
$valuesModif[$attUnique] = $values[$attUnique];
|
||||
}
|
||||
}
|
||||
|
||||
$table .= "|*" . $field[0] . "*|";
|
||||
$table .= implode("|", $values) . "\n";
|
||||
$table .= implode("|", $valuesModif) . "\n";
|
||||
}
|
||||
|
||||
// end table
|
||||
$table .= "|===\n";
|
||||
$table .= "__ end table for object $objectname\n";
|
||||
|
||||
//write in file
|
||||
$writeInFile = dolReplaceInFile($destfile, array('== DATA SPECIFICATIONS' => $table));
|
||||
if ($writeInFile<0) {
|
||||
@@ -691,13 +758,14 @@ function writePropsInAsciiDoc($file, $objectname, $destfile)
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Delete property from documentation if we delete object
|
||||
* Delete property and permissions from documentation if we delete object
|
||||
* @param string $file file or path
|
||||
* @param string $objectname name of object wants to deleted
|
||||
* @return void
|
||||
*/
|
||||
function deletePropsFromDoc($file, $objectname)
|
||||
function deletePropsAndPermsFromDoc($file, $objectname)
|
||||
{
|
||||
|
||||
$start = "== Table of fields and their properties for object *".ucfirst($objectname)."* : ";
|
||||
@@ -706,8 +774,16 @@ function deletePropsFromDoc($file, $objectname)
|
||||
$search = '/' . preg_quote($start, '/') . '(.*?)' . preg_quote($end, '/') . '/s';
|
||||
$new_contents = preg_replace($search, '', $str);
|
||||
file_put_contents($file, $new_contents);
|
||||
|
||||
//perms If Exist
|
||||
$perms = "|*".strtolower($objectname)."*|";
|
||||
$search_pattern_perms = '/' . preg_quote($perms, '/') . '.*?\n/';
|
||||
$new_contents = preg_replace($search_pattern_perms, '', $new_contents);
|
||||
file_put_contents($file, $new_contents);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Search a string and return all lines needed from file
|
||||
* @param string $file file for searching
|
||||
|
||||
@@ -214,7 +214,7 @@ function project_prepare_head(Project $project, $moreparam = '')
|
||||
if (isModEnabled('ticket') && $user->hasRight('ticket', 'read')) {
|
||||
require_once DOL_DOCUMENT_ROOT.'/ticket/class/ticket.class.php';
|
||||
$Tickettatic = new Ticket($db);
|
||||
$nbTicket = count($Tickettatic->getAllItemsLinkedByObjectID($project->id, '*', 'fk_project', 'ticket'));
|
||||
$nbTicket = $Tickettatic->getCountOfItemsLinkedByObjectID($project->id, 'fk_project', 'ticket');
|
||||
$head[$h][0] = DOL_URL_ROOT.'/ticket/list.php?projectid='.((int) $project->id);
|
||||
$head[$h][1] = $langs->trans("Ticket");
|
||||
if ($nbTicket > 0) {
|
||||
|
||||
Reference in New Issue
Block a user