From d42aef9e4d04f46bcf7033b7f02dd696b1e05124 Mon Sep 17 00:00:00 2001 From: Benjamin Renard Date: Mon, 6 Oct 2008 13:11:14 +0000 Subject: [PATCH] =?UTF-8?q?-=20LSform=20:=20Correction=20de=20bugs=20d'aff?= =?UTF-8?q?ichage=20-=20LSattr=5Fhtml=5Fselect=5Fobject=20:=20Correction?= =?UTF-8?q?=20d'un=20probl=C3=A8me=20de=20chargement=20de=20de=20type=20?= =?UTF-8?q?=20=20d'objet=20-=20LSformElement=5Fselect=20:=20Affichage=20d'?= =?UTF-8?q?un=20texte=20lorsque=20l'attribut=20n'a=20pas=20de=20=20=20vale?= =?UTF-8?q?ur=20-=20LSformElement=5Ftext=20:=20=20=20->=20Ajout=20d'une=20?= =?UTF-8?q?possibilit=C3=A9=20de=20suppression=20des=20accents=20lors=20de?= =?UTF-8?q?=20l'autog=C3=A9n=C3=A9ration=20=20=20->=20Ajout=20d'un=20bouto?= =?UTF-8?q?n=20pour=20l'autog=C3=A9n=C3=A9ration=20manuelle=20-=20LSaddons?= =?UTF-8?q?.supann=20:=20Ajout=20d'un=20addon=20pour=20le=20support=20Supp?= =?UTF-8?q?an=20-=20LSsmoothbox=20:=20Affichage=20d'une=20image=20durant?= =?UTF-8?q?=20l'ouverture=20d'une=20page?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- trunk/includes/addons/LSaddons.supann.php | 139 ++++++++++++++++++ .../class/class.LSattr_html_select_object.php | 7 +- .../class/class.LSformElement_select.php | 3 + .../class/class.LSformElement_text.php | 2 +- trunk/includes/js/LSformElement_text_field.js | 13 +- trunk/includes/js/LSsmoothbox.js | 7 +- trunk/includes/js/functions.js | 22 +++ trunk/templates/css/LSform.css | 6 +- 8 files changed, 194 insertions(+), 5 deletions(-) create mode 100644 trunk/includes/addons/LSaddons.supann.php diff --git a/trunk/includes/addons/LSaddons.supann.php b/trunk/includes/addons/LSaddons.supann.php new file mode 100644 index 00000000..e4b284b2 --- /dev/null +++ b/trunk/includes/addons/LSaddons.supann.php @@ -0,0 +1,139 @@ + _("SUPANN Support : La constante %{const} n'est pas définie."), + 'level' => 'c' + ); + + $GLOBALS['LSerror_code']['SUPANN_01']= array ( + 'msg' => _("SUPANN Support : L'attribut %{dependency} est introuvable. Impossible de générer l'attribut %{attr}."), + 'level' => 'c' + ); + + /** + * Fin des données de configuration + */ + + + /** + * Verification du support SUPANN par ldapSaisie + * + * @author Benjamin Renard + * + * @retval boolean true si SUPANN est pleinement supporté, false sinon + */ + function LSaddon_supann_support() { + $retval = true; + + $MUST_DEFINE_CONST= array( + 'LS_SUPANN_LASTNAME_ATTR', + 'LS_SUPANN_FIRSTNAME_ATTR' + ); + + foreach($MUST_DEFINE_CONST as $const) { + if ( constant($const) == '' ) { + $GLOBALS['LSerror'] -> addErrorCode('SUPANN_SUPPORT_01',$const); + $retval=false; + } + } + + return $retval; + } + + /** + * Generation du displayName + * + * @author Benjamin Renard + * + * @param[in] $ldapObject L'objet ldap + * + * @retval string Le displayName ou false si il y a un problème durant la génération + */ + function generate_displayName($ldapObject) { + if ( get_class($ldapObject -> attrs[ LS_SUPANN_LASTNAME_ATTR ]) != 'LSattribute' ) { + $GLOBALS['LSerror'] -> addErrorCode('SUPANN_01',array('dependency' => LS_SUPANN_LASTNAME_ATTR, 'attr' => 'cn')); + return; + } + if ( get_class($ldapObject -> attrs[ LS_SUPANN_FIRSTNAME_ATTR ]) != 'LSattribute' ) { + $GLOBALS['LSerror'] -> addErrorCode('SUPANN_01',array('dependency' => LS_SUPANN_FIRSTNAME_ATTR, 'attr' => 'cn')); + return; + } + + $nom = $ldapObject -> attrs[ LS_SUPANN_LASTNAME_ATTR ] -> getValue(); + $prenom = $ldapObject -> attrs[ LS_SUPANN_FIRSTNAME_ATTR ] -> getValue(); + + return ($prenom.' '.$nom); + } + + /** + * Generation du CN + * + * @author Benjamin Renard + * + * @param[in] $ldapObject L'objet ldap + * + * @retval string Le CN ou false si il y a un problème durant la génération + */ + function generate_cn($ldapObject) { + if ( get_class($ldapObject -> attrs[ LS_SUPANN_LASTNAME_ATTR ]) != 'LSattribute' ) { + $GLOBALS['LSerror'] -> addErrorCode('SUPANN_01',array('dependency' => LS_SUPANN_LASTNAME_ATTR, 'attr' => 'cn')); + return; + } + if ( get_class($ldapObject -> attrs[ LS_SUPANN_FIRSTNAME_ATTR ]) != 'LSattribute' ) { + $GLOBALS['LSerror'] -> addErrorCode('SUPANN_01',array('dependency' => LS_SUPANN_FIRSTNAME_ATTR, 'attr' => 'cn')); + return; + } + + $nom = $ldapObject -> attrs[ LS_SUPANN_LASTNAME_ATTR ] -> getValue(); + $prenom = $ldapObject -> attrs[ LS_SUPANN_FIRSTNAME_ATTR ] -> getValue(); + + return (replaceAccents($nom).' '.replaceAccents($prenom)); + } + + + /** + * Supprime les accents d'une chaine + * + * @param[in] $string La chaine originale + * + * @retval string La chaine sans les accents + */ + function replaceAccents($string){ + return strtr($string, 'àáâãäçèéêëìíîïñòóôõöùúûüýÿÀÁÂÃÄÇÈÉÊËÌÍÎÏÑÒÓÔÕÖÙÚÛÜÝ', + 'aaaaaceeeeiiiinooooouuuuyyAAAAACEEEEIIIINOOOOOUUUUY'); + } + + +?> diff --git a/trunk/includes/class/class.LSattr_html_select_object.php b/trunk/includes/class/class.LSattr_html_select_object.php index 7ff9ef99..30bed0a9 100644 --- a/trunk/includes/class/class.LSattr_html_select_object.php +++ b/trunk/includes/class/class.LSattr_html_select_object.php @@ -83,7 +83,12 @@ class LSattr_html_select_object extends LSattr_html{ $conf=$this -> config['selectable_object']; if (!isset($conf['object_type'])) { $GLOBALS['LSerror'] -> addErrorCode(102,$this -> name); - break; + return; + } + + if (!$GLOBALS['LSsession'] -> loadLSobject($conf['object_type'])) { + $GLOBALS['LSerror'] -> addErrorCode(1004,$conf['object_type']); + return; } if (is_array($values)) { diff --git a/trunk/includes/class/class.LSformElement_select.php b/trunk/includes/class/class.LSformElement_select.php index a71d34a5..f058d93f 100644 --- a/trunk/includes/class/class.LSformElement_select.php +++ b/trunk/includes/class/class.LSformElement_select.php @@ -68,6 +68,9 @@ class LSformElement_select extends LSformElement { foreach ($this -> values as $value) { $return['html'].="
  • ".$this -> params['text_possible_values'][$value]."
  • "; } + if (empty($this -> values)) { + $return['html'] .= "
  • "._('Aucune valeur definie')."
  • \n"; + } $return['html'].="\n"; } return $return; diff --git a/trunk/includes/class/class.LSformElement_text.php b/trunk/includes/class/class.LSformElement_text.php index 76475a52..54fa35d2 100644 --- a/trunk/includes/class/class.LSformElement_text.php +++ b/trunk/includes/class/class.LSformElement_text.php @@ -44,7 +44,7 @@ class LSformElement_text extends LSformElement { // value if (!$this -> isFreeze()) { $return['html'] = "
      \n"; - if ($this -> params['html_options']['generate_value_format']!="") { + if (isset($this -> params['html_options'])) { $GLOBALS['LSsession'] -> addJSconfigParam($this -> name,$this -> params['html_options']); } if (empty($this -> values)) { diff --git a/trunk/includes/js/LSformElement_text_field.js b/trunk/includes/js/LSformElement_text_field.js index 069c0a73..6a36751c 100644 --- a/trunk/includes/js/LSformElement_text_field.js +++ b/trunk/includes/js/LSformElement_text_field.js @@ -27,6 +27,11 @@ var LSformElement_text_field = new Class({ },this); this.oldBg=this.input.getStyle('background-color'); this.fx = new Fx.Tween(this.input,{property: 'background-color',duration:600}); + this.generateBtn = new Element('img'); + this.generateBtn.addClass('btn'); + this.generateBtn.src='templates/images/generate.png'; + this.generateBtn.addEvent('click',this.refreshValue.bind(this)); + this.generateBtn.injectAfter(this.input); } } } @@ -42,7 +47,13 @@ var LSformElement_text_field = new Class({ refreshValue: function() { if (this._auto) { - this.input.value=getFData(this.format,this.parent,'getValue'); + var val=getFData(this.format,this.parent,'getValue'); + if ($type(this.params['withoutAccents'])) { + if(this.params['withoutAccents']) { + val = replaceAccents(val); + } + } + this.input.value = val; this.fx.start(this.onChangeColor); (function() {this.fx.start(this.oldBg);}).delay(1000,this); } diff --git a/trunk/includes/js/LSsmoothbox.js b/trunk/includes/js/LSsmoothbox.js index 9a8ad326..27167959 100644 --- a/trunk/includes/js/LSsmoothbox.js +++ b/trunk/includes/js/LSsmoothbox.js @@ -78,6 +78,10 @@ var LSsmoothbox = new Class({ this._open=0; this._scrolling=0; + + this.openOptions = {}; + + this.frame.set('html',''); }, position: function(){ @@ -335,12 +339,13 @@ var LSsmoothbox = new Class({ }, openURL: function(href,openOptions) { + this.load.bind(this)(); var options = { method: 'post', update: this.frame, url: href, evalScripts: true, - onComplete: varLSdefault.ajaxDisplayDebugAndError() + onComplete: (function(){varLSdefault.ajaxDisplayDebugAndError();this.resize()}).bind(this) }; this.displayValidBtn(); new Request.HTML(options).send(); diff --git a/trunk/includes/js/functions.js b/trunk/includes/js/functions.js index 194d2985..95cda7fb 100644 --- a/trunk/includes/js/functions.js +++ b/trunk/includes/js/functions.js @@ -73,3 +73,25 @@ function getFData(format,data,meth) { } return format; } + +/** +* Supprime les accents d'une chaine +* +* @param[in] $string La chaine originale +* +* @retval string La chaine sans les accents +*/ +function replaceAccents(str) { + var new_str = String(str); + var accent = + new Array("à","á","â","ã","ä","ç","è","é","ê","ë","ì","í","î","ï","ñ","ò","ó","ô","õ","ö","ù","ú","û","ü","ý","ÿ","À","Á","Â","Ã","Ä","Ç","È","É","Ê","Ë","Ì","Í","Î","Ï","Ñ","Ò","Ó","Ô","Õ","Ö","Ù","Ú","Û","Ü","Ý"); + var sans_accent = + new 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"); + if (str && str!= "") { + for (i=0; i