- LSform : Correction de bugs d'affichage

- LSattr_html_select_object : Correction d'un problème de chargement de de type
  d'objet
- LSformElement_select : Affichage d'un texte lorsque l'attribut n'a pas de
  valeur
- LSformElement_text :
  -> Ajout d'une possibilité de suppression des accents lors de l'autogénération
  -> Ajout d'un bouton pour l'autogénération manuelle
- LSaddons.supann : Ajout d'un addon pour le support Suppan
- LSsmoothbox : Affichage d'une image durant l'ouverture d'une page
This commit is contained in:
Benjamin Renard 2008-10-06 13:11:14 +00:00
parent f7f35108eb
commit d42aef9e4d
8 changed files with 194 additions and 5 deletions

View file

@ -0,0 +1,139 @@
<?php
/*******************************************************************************
* Copyright (C) 2007 Easter-eggs
* http://ldapsaisie.labs.libre-entreprise.org
*
* Author: See AUTHORS file in top-level directory.
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License version 2
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
******************************************************************************/
/**
* Données de configuration pour le support SUPANN
*/
// Nom de l'attribut LDAP nom
define('LS_SUPANN_LASTNAME_ATTR','sn');
// Nom de l'attribut LDAP prenom
define('LS_SUPANN_FIRSTNAME_ATTR','givenname');
// Message d'erreur
$GLOBALS['LSerror_code']['SUPANN_SUPPORT_01']= array (
'msg' => _("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 <brenard@easter-eggs.com>
*
* @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 <brenard@easter-eggs.com>
*
* @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 <brenard@easter-eggs.com>
*
* @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');
}
?>

View file

@ -83,7 +83,12 @@ class LSattr_html_select_object extends LSattr_html{
$conf=$this -> config['selectable_object']; $conf=$this -> config['selectable_object'];
if (!isset($conf['object_type'])) { if (!isset($conf['object_type'])) {
$GLOBALS['LSerror'] -> addErrorCode(102,$this -> name); $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)) { if (is_array($values)) {

View file

@ -68,6 +68,9 @@ class LSformElement_select extends LSformElement {
foreach ($this -> values as $value) { foreach ($this -> values as $value) {
$return['html'].="<li>".$this -> params['text_possible_values'][$value]."</strong></li>"; $return['html'].="<li>".$this -> params['text_possible_values'][$value]."</strong></li>";
} }
if (empty($this -> values)) {
$return['html'] .= "<li>"._('Aucune valeur definie')."</li>\n";
}
$return['html'].="</ul>\n"; $return['html'].="</ul>\n";
} }
return $return; return $return;

View file

@ -44,7 +44,7 @@ class LSformElement_text extends LSformElement {
// value // value
if (!$this -> isFreeze()) { if (!$this -> isFreeze()) {
$return['html'] = "<ul class='LSform LSformElement_text'>\n"; $return['html'] = "<ul class='LSform LSformElement_text'>\n";
if ($this -> params['html_options']['generate_value_format']!="") { if (isset($this -> params['html_options'])) {
$GLOBALS['LSsession'] -> addJSconfigParam($this -> name,$this -> params['html_options']); $GLOBALS['LSsession'] -> addJSconfigParam($this -> name,$this -> params['html_options']);
} }
if (empty($this -> values)) { if (empty($this -> values)) {

View file

@ -27,6 +27,11 @@ var LSformElement_text_field = new Class({
},this); },this);
this.oldBg=this.input.getStyle('background-color'); this.oldBg=this.input.getStyle('background-color');
this.fx = new Fx.Tween(this.input,{property: 'background-color',duration:600}); 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() { refreshValue: function() {
if (this._auto) { 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); this.fx.start(this.onChangeColor);
(function() {this.fx.start(this.oldBg);}).delay(1000,this); (function() {this.fx.start(this.oldBg);}).delay(1000,this);
} }

View file

@ -78,6 +78,10 @@ var LSsmoothbox = new Class({
this._open=0; this._open=0;
this._scrolling=0; this._scrolling=0;
this.openOptions = {};
this.frame.set('html','');
}, },
position: function(){ position: function(){
@ -335,12 +339,13 @@ var LSsmoothbox = new Class({
}, },
openURL: function(href,openOptions) { openURL: function(href,openOptions) {
this.load.bind(this)();
var options = { var options = {
method: 'post', method: 'post',
update: this.frame, update: this.frame,
url: href, url: href,
evalScripts: true, evalScripts: true,
onComplete: varLSdefault.ajaxDisplayDebugAndError() onComplete: (function(){varLSdefault.ajaxDisplayDebugAndError();this.resize()}).bind(this)
}; };
this.displayValidBtn(); this.displayValidBtn();
new Request.HTML(options).send(); new Request.HTML(options).send();

View file

@ -73,3 +73,25 @@ function getFData(format,data,meth) {
} }
return format; 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<accent.length; i++) {
var reg_exp= RegExp(accent[i], "gi");
new_str = new_str.replace (reg_exp, sans_accent[i]);
}
}
return new_str;
}

View file

@ -42,12 +42,16 @@ ul.LSform li {
/* /*
* Champs du formulaire * Champs du formulaire
*/ */
.LSform input, .LSform select, .LSform textarea { .LSform input[type=text], .LSform input[type=file], .LSform input[type=submit], .LSform input[type=password], .LSform select, .LSform textarea {
border: 1px solid #ccc; border: 1px solid #ccc;
width: 300px; width: 300px;
background-color: #b5e4f6; background-color: #b5e4f6;
} }
.LSform input[type=radio] {
width: undefinded;
}
input[type='submit'].LSform { input[type='submit'].LSform {
border: 1px outset #ccc; border: 1px outset #ccc;
margin-top: 1em; margin-top: 1em;