2
0
forked from Wavyzz/dolibarr
develop_dict
This commit is contained in:
Regis Houssin
2017-07-26 08:58:56 +02:00
85 changed files with 4430 additions and 2950 deletions

View File

@@ -627,18 +627,26 @@ function dol_buildpath($path, $type=0)
/**
* Create a clone of instance of object (new instance with same value for properties)
* Property that are reference are also new object (true clone)
* With native = 0: Property that are reference are also new object (true clone). This means $this->db is not valid.
* With native = 1: Use PHP clone. Property that are reference are same pointer. This means $this->db is still valid.
*
* @param object $object Object to clone
* @param int $native Native method or true method
* @return object Object clone
* @see https://php.net/manual/language.oop5.cloning.php
*/
function dol_clone($object)
function dol_clone($object, $native=0)
{
//dol_syslog(__FUNCTION__ . " is deprecated", LOG_WARNING);
//$myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable
$myclone=unserialize(serialize($object));
if (empty($native))
{
$myclone=unserialize(serialize($object));
}
else
{
$myclone = clone $object; // PHP clone is a shallow copy only, not a real clone, so properties of references will keep references (refer to the same target/variable)
}
return $myclone;
}
@@ -1130,7 +1138,7 @@ function dol_get_fiche_end($notab=0)
* @param string $paramid Name of parameter to use to name the id into the URL next/previous link
* @param string $morehtml More html content to output just before the nav bar
* @param int $shownav Show Condition (navigation is shown if value is 1)
* @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field)
* @param string $fieldid Nom du champ en base a utiliser pour select next et previous (we make the select max and min on this field). Use 'none' for no prev/next search.
* @param string $fieldref Nom du champ objet ref (object->ref) a utiliser pour select next et previous
* @param string $morehtmlref More html to show after ref
* @param string $moreparam More param to add in nav link url.
@@ -1281,7 +1289,8 @@ function dol_banner_tab($object, $paramid, $morehtml='', $shownav=1, $fieldid='r
if ($object->element == 'project' && ! $object->public) $picto = 'project'; // instead of projectpub
$nophoto=img_picto('', 'object_'.$picto, '', false, 1);
}
$morehtmlleft.='<!-- No photo to show --><div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$modulepart.($cssclass?' '.$cssclass:'').'" alt="No photo" border="0"'.($width?' width="'.$width.'"':'').' src="'.$nophoto.'"></div></div>';
$morehtmlleft.='<!-- No photo to show -->';
$morehtmlleft.='<div class="floatleft inline-block valignmiddle divphotoref"><div class="photoref"><img class="photo'.$modulepart.($cssclass?' '.$cssclass:'').'" alt="No photo" border="0"'.($width?' width="'.$width.'"':'').' src="'.$nophoto.'"></div></div>';
$morehtmlleft.='</div>';
}
}
@@ -2548,7 +2557,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
if ($pictoisfullpath)
{
// Clean parameters
if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto .= '.png';
if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) $picto .= '.png';
$fullpathpicto = $picto;
}
else
@@ -2570,7 +2579,7 @@ function img_picto($titlealt, $picto, $moreatt = '', $pictoisfullpath = false, $
}
// Clean parameters
if (! preg_match('/(\.png|\.gif)$/i',$picto)) $picto .= '.png';
if (! preg_match('/(\.png|\.gif|\.svg)$/i',$picto)) $picto .= '.png';
// If alt path are defined, define url where img file is, according to physical path
foreach ($conf->file->dol_document_root as $type => $dirroot) // ex: array(["main"]=>"/home/maindir/htdocs", ["alt0"]=>"/home/moddir0/htdocs", ...)
{
@@ -4769,22 +4778,57 @@ function dol_string_nohtmltag($StringHtml,$removelinefeed=1,$pagecodeto='UTF-8')
* Return first line of text. Cut will depends if content is HTML or not.
*
* @param string $text Input text
* @param int $nboflines Nb of lines to get (default is 1 = first line only)
* @return string Output text
* @see dol_nboflines_bis, dol_string_nohtmltag, dol_escape_htmltag
*/
function dolGetFirstLineOfText($text)
function dolGetFirstLineOfText($text, $nboflines=1)
{
if (dol_textishtml($text))
if ($nboflines == 1)
{
$firstline=preg_replace('/<br[^>]*>.*$/s','',$text); // The s pattern modifier means the . can match newline characters
$firstline=preg_replace('/<div[^>]*>.*$/s','',$firstline); // The s pattern modifier means the . can match newline characters
if (dol_textishtml($text))
{
$firstline=preg_replace('/<br[^>]*>.*$/s','',$text); // The s pattern modifier means the . can match newline characters
$firstline=preg_replace('/<div[^>]*>.*$/s','',$firstline); // The s pattern modifier means the . can match newline characters
}
else
{
$firstline=preg_replace('/[\n\r].*/','',$text);
}
return $firstline.((strlen($firstline) != strlen($text))?'...':'');
}
else
{
$firstline=preg_replace('/[\n\r].*/','',$text);
$ishtml=0;
if (dol_textishtml($text))
{
$text=preg_replace('/\n/','',$text);
$ishtml=1;
$repTable = array("\t" => " ", "\n" => " ", "\r" => " ", "\0" => " ", "\x0B" => " ");
}
else
{
$repTable = array("\t" => " ", "\n" => "<br>", "\r" => " ", "\0" => " ", "\x0B" => " ");
}
$text = strtr($text, $repTable);
if ($charset == 'UTF-8') { $pattern = '/(<br[^>]*>)/Uu'; } // /U is to have UNGREEDY regex to limit to one html tag. /u is for UTF8 support
else $pattern = '/(<br[^>]*>)/U'; // /U is to have UNGREEDY regex to limit to one html tag.
$a = preg_split($pattern, $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
$firstline='';
$i=0;
$nba = count($a); // 2x nb of lines in $a because $a contains also a line for each new line separator
while (($i < $nba) && ($i < ($nboflines * 2)))
{
if ($i % 2 == 0) $firstline .= $a[$i];
elseif (($i < (($nboflines * 2) - 1)) && ($i < ($nba - 1))) $firstline .= ($ishtml?"<br>\n":"\n");
$i++;
}
unset($a);
return $firstline.(($i < $nba)?'...':'');
}
return $firstline.((strlen($firstline) != strlen($text))?'...':'');
}
@@ -4946,7 +4990,7 @@ function dol_nboflines($s,$maxchar=0)
/**
* Return nb of lines of a formated text with \n and <br> (we can't have both \n and br)
* Return nb of lines of a formated text with \n and <br> (WARNING: string must not have mixed \n and br separators)
*
* @param string $text Text
* @param int $maxlinesize Largeur de ligne en caracteres (ou 0 si pas de limite - defaut)
@@ -4982,6 +5026,8 @@ function dol_nboflines_bis($text,$maxlinesize=0,$charset='UTF-8')
}
}
}
unset($a);
return $nblines;
}