mirror of
https://github.com/Dolibarr/dolibarr.git
synced 2025-12-11 12:01:23 +01:00
Feature: La fonction trunc peut tronquer a droite ou a gauche
This commit is contained in:
@@ -775,18 +775,37 @@ function dolibarr_print_phone($phone,$country="FR")
|
|||||||
\param size Longueur max de la chaine. Si 0, pas de limite.
|
\param size Longueur max de la chaine. Si 0, pas de limite.
|
||||||
\return string Chaine tronqu<71>e
|
\return string Chaine tronqu<71>e
|
||||||
*/
|
*/
|
||||||
function dolibarr_trunc($string,$size=40)
|
function dolibarr_trunc($string,$size=40,$trunc='right')
|
||||||
{
|
{
|
||||||
if ($size==0) return $string;
|
if ($size==0) return $string;
|
||||||
if ((!defined('USE_SHORT_TITLE')) || defined('USE_SHORT_TITLE') && USE_SHORT_TITLE)
|
if ((!defined('USE_SHORT_TITLE')) || defined('USE_SHORT_TITLE') && USE_SHORT_TITLE)
|
||||||
{
|
{
|
||||||
if (strlen($string) > $size)
|
// We go always here
|
||||||
return substr($string,0,$size).'...';
|
if ($trunc == 'right')
|
||||||
else
|
{
|
||||||
|
if (strlen($string) > $size)
|
||||||
|
return substr($string,0,$size).'...';
|
||||||
|
else
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
|
if ($trunc == 'center')
|
||||||
|
{
|
||||||
|
// \TODO A developper.
|
||||||
|
|
||||||
return $string;
|
return $string;
|
||||||
|
}
|
||||||
|
if ($trunc == 'left')
|
||||||
|
{
|
||||||
|
if (strlen($string) > $size)
|
||||||
|
return '...'.substr($string,strlen($string) - $size,$size);
|
||||||
|
else
|
||||||
|
return $string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
{
|
||||||
return $string;
|
return $string;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user