From 45d560957b439bab559decf0f84c35ef21e47a7d Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Wed, 3 Mar 2010 18:43:22 +0100 Subject: [PATCH 1/4] LSformElement : fix translation of help infos --- public_html/includes/class/class.LSformElement.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public_html/includes/class/class.LSformElement.php b/public_html/includes/class/class.LSformElement.php index 92802a70..ad17ff07 100644 --- a/public_html/includes/class/class.LSformElement.php +++ b/public_html/includes/class/class.LSformElement.php @@ -190,7 +190,7 @@ class LSformElement { } $return['label'] = $this -> getLabel(); if (isset($this -> params['help_info'])) { - $return['help_info']=$this -> params['help_info']; + $return['help_info']=__($this -> params['help_info']); } return $return; } From 47c10a169cce8a5272683d393f9d369de017e0b1 Mon Sep 17 00:00:00 2001 From: bn8 Date: Thu, 4 Mar 2010 16:47:37 +0100 Subject: [PATCH 2/4] Functions : * Added function withoutAccents() * Improvement of getFData() function : + Extracting a portion repeated in the function _getFData_extractAndModify() + Added support to negative length in substring selection + Added support to make string uppercase or lowercase + Added support for removing accents --- public_html/includes/functions.php | 178 +++++++++++++++++++---------- 1 file changed, 119 insertions(+), 59 deletions(-) diff --git a/public_html/includes/functions.php b/public_html/includes/functions.php index 035cb35f..634fee30 100644 --- a/public_html/includes/functions.php +++ b/public_html/includes/functions.php @@ -39,7 +39,7 @@ */ function getFData($format,$data,$meth=NULL) { $unique=false; - $expr="%{([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9])+)?}"; + $expr="%{([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9]+))?(-)?(\!|\_)?(~)?}"; if(!is_array($format)) { $format=array($format); $unique=true; @@ -54,17 +54,7 @@ function getFData($format,$data,$meth=NULL) { else { $val = $data[$ch[1]]; } - if($ch[3]) { - if ($ch[5]) { - $s=$ch[3]; - $l=$ch[5]; - } - else { - $s=0; - $l=$ch[3]; - } - $val=substr((string)$val,$s,$l); - } + $val=_getFData_extractAndModify($val,$ch); $format[$i]=ereg_replace($ch[0],$val,$format[$i]); } } @@ -75,17 +65,7 @@ function getFData($format,$data,$meth=NULL) { if (is_array($value)) { $value = $value[0]; } - if($ch[3]) { - if ($ch[5]) { - $s=$ch[3]; - $l=$ch[5]; - } - else { - $s=0; - $l=$ch[3]; - } - $value=substr((string)$value,$s,$l); - } + $value=_getFData_extractAndModify($value,$ch); $format[$i]=ereg_replace($ch[0],$value,$format[$i]); } else { @@ -102,17 +82,7 @@ function getFData($format,$data,$meth=NULL) { if (is_array($value)) { $value = $value[0]; } - if($ch[3]) { - if ($ch[5]) { - $s=$ch[3]; - $l=$ch[5]; - } - else { - $s=0; - $l=$ch[3]; - } - $value=substr((string)$value,$s,$l); - } + $value=_getFData_extractAndModify($value,$ch); $format[$i]=ereg_replace($ch[0],$value,$format[$i]); } } @@ -123,17 +93,7 @@ function getFData($format,$data,$meth=NULL) { if (is_array($value)) { $value = $value[0]; } - if($ch[3]) { - if ($ch[5]) { - $s=$ch[3]; - $l=$ch[5]; - } - else { - $s=0; - $l=$ch[3]; - } - $value=substr((string)$value,$s,$l); - } + $value=_getFData_extractAndModify($value,$ch); $format[$i]=ereg_replace($ch[0],$value,$format[$i]); } else { @@ -145,20 +105,7 @@ function getFData($format,$data,$meth=NULL) { } else { while (ereg($expr,$format[$i],$ch)) { - if($ch[3]) { - if ($ch[5]) { - $s=$ch[3]; - $l=$ch[5]; - } - else { - $s=0; - $l=$ch[3]; - } - $val=substr((string)$data,$s,$l); - } - else { - $val=$data; - } + $val=_getFData_extractAndModify($data,$ch); $format[$i]=ereg_replace($ch[0],$val,$format[$i]); } } @@ -169,6 +116,54 @@ function getFData($format,$data,$meth=NULL) { return $format; } +function _getFData_extractAndModify($data,$ch) { + if($ch[3]) { + if ($ch[5]) { + if ($ch[6]) { + if ($ch[3]<0) { + $s=strlen($data)-(-1*$ch[3])-$ch[5]; + $l=$ch[5]; + } + else { + $s=$ch[3]-$ch[5]; + $l=$ch[5]; + if ($s<0) { + $l=$l-(-1*$s); + $s=0; + } + } + } + else { + $s=$ch[3]; + $l=$ch[5]; + } + } + else { + $s=0; + $l=$ch[3]; + } + $val=substr((string)$data,$s,$l); + } + else { + $val=$data; + } + + # Without Accent + if ($ch[8]) { + $val = withoutAccents($val); + } + + # Upper / Lower case + if ($ch[7]=="!") { + $val=strtoupper($val); + } + elseif ($ch[7]=='_') { + $val=strtolower($val); + } + + return $val; +} + function getFieldInFormat($format) { $fields=array(); $expr="%{([A-Za-z0-9]+)(\:(-?[0-9])+)?(\:(-?[0-9])+)?}"; @@ -470,4 +465,69 @@ function LSdebugDefined() { } } } + + /** + * Supprime les accents d'une chaine + * + * @param[in] $string La chaine originale + * + * @retval string La chaine sans les accents + */ + function withoutAccents($string){ + $replaceAccent = Array( + "à" => "a", + "á" => "a", + "â" => "a", + "ã" => "a", + "ä" => "a", + "ç" => "c", + "è" => "e", + "é" => "e", + "ê" => "e", + "ë" => "e", + "ì" => "i", + "í" => "i", + "î" => "i", + "ï" => "i", + "ñ" => "n", + "ò" => "o", + "ó" => "o", + "ô" => "o", + "õ" => "o", + "ö" => "o", + "ù" => "u", + "ú" => "u", + "û" => "u", + "ü" => "u", + "ý" => "y", + "ÿ" => "y", + "À" => "A", + "Á" => "A", + "Â" => "A", + "Ã" => "A", + "Ä" => "A", + "Ç" => "C", + "È" => "E", + "É" => "E", + "Ê" => "E", + "Ë" => "E", + "Ì" => "I", + "Í" => "I", + "Î" => "I", + "Ï" => "I", + "Ñ" => "N", + "Ò" => "O", + "Ó" => "O", + "Ô" => "O", + "Õ" => "O", + "Ö" => "O", + "Ù" => "U", + "Ú" => "U", + "Û" => "U", + "Ü" => "U", + "Ý" => "Y" + ); + return strtr($string, $replaceAccent); + } + ?> From 159b33a49f714e4436e12626694ba0b5c5f545c8 Mon Sep 17 00:00:00 2001 From: bn8 Date: Fri, 5 Mar 2010 17:44:07 +0100 Subject: [PATCH 3/4] LSsession :: loadLSobject() : Added support to LSaddons dependencies. --- public_html/includes/class/class.LSsession.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/public_html/includes/class/class.LSsession.php b/public_html/includes/class/class.LSsession.php index bc527d34..20793dd4 100644 --- a/public_html/includes/class/class.LSsession.php +++ b/public_html/includes/class/class.LSsession.php @@ -241,6 +241,20 @@ class LSsession { if (!LSconfig :: set("LSobjects.$object",$GLOBALS['LSobjects'][$object])) { $error = 1; } + else if (isset($GLOBALS['LSobjects'][$object]['LSaddons'])){ + if (is_array($GLOBALS['LSobjects'][$object]['LSaddons'])) { + foreach ($GLOBALS['LSobjects'][$object]['LSaddons'] as $addon) { + if (!self :: loadLSaddon($addon)) { + $error = 1; + } + } + } + else { + if (!self :: loadLSaddon($GLOBALS['LSobjects'][$object]['LSaddons'])) { + $error = 1; + } + } + } } if ($error) { LSerror :: addErrorCode('LSsession_04',$object); From 63c9e84ccf184303ff9aee7a2221a1c6945f3ef9 Mon Sep 17 00:00:00 2001 From: bn8 Date: Fri, 5 Mar 2010 17:50:25 +0100 Subject: [PATCH 4/4] Doc/Conf/LSobject : Added doc about LSaddons dependencies. --- doc/conf/LSobject.docbook | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/conf/LSobject.docbook b/doc/conf/LSobject.docbook index 0b906dc8..e0a9ff57 100644 --- a/doc/conf/LSobject.docbook +++ b/doc/conf/LSobject.docbook @@ -25,6 +25,8 @@ ... ), 'rdn' => 'attr1', + + 'LSaddons' => [LSaddon(s)], 'container_dn' => 'ou=people', 'container_auto_create' => array( @@ -81,6 +83,15 @@ + + LSaddons + + LSaddon(s) dont le type d'objet dépend. Ce peut être un tableau de chaînes de + caractères ou une simpe chaîne de caractères correspondant au(x) nom(s) du/des LSaddon(s) + en dépendance. + + + container_dn