mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-16 15:33:02 +01:00
- LSformElement_ssh_key
-> Refonte en utilisant les templates
This commit is contained in:
parent
fae498c014
commit
7ee28a4a78
3 changed files with 41 additions and 36 deletions
|
@ -32,6 +32,9 @@
|
||||||
|
|
||||||
class LSformElement_ssh_key extends LSformElement {
|
class LSformElement_ssh_key extends LSformElement {
|
||||||
|
|
||||||
|
var $template = 'LSformElement_ssh_key.tpl';
|
||||||
|
var $fieldTemplate = 'LSformElement_ssh_key_field.tpl';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Retourne les infos d'affichage de l'élément
|
* Retourne les infos d'affichage de l'élément
|
||||||
*
|
*
|
||||||
|
@ -42,50 +45,36 @@ class LSformElement_ssh_key extends LSformElement {
|
||||||
function getDisplay(){
|
function getDisplay(){
|
||||||
$GLOBALS['LSsession'] -> addCssFile('LSformElement_ssh_key.css');
|
$GLOBALS['LSsession'] -> addCssFile('LSformElement_ssh_key.css');
|
||||||
$return = $this -> getLabelInfos();
|
$return = $this -> getLabelInfos();
|
||||||
// value
|
$params = array();
|
||||||
$return['html'] = "<ul class='LSform'>\n";
|
|
||||||
if (!$this -> isFreeze()) {
|
if (!$this -> isFreeze()) {
|
||||||
if (empty($this -> values)) {
|
$params['values_txt'] = $this -> values;
|
||||||
$return['html'] .= "<li>".$this -> getEmptyField()."</li>\n";
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
foreach($this -> values as $value) {
|
|
||||||
$multiple = $this -> getMultipleData();
|
|
||||||
$id = "LSform_".$this -> name."_".rand();
|
|
||||||
$return['html'].="<li class='LSformElement_ssh_key'><textarea name='".$this -> name."[]' id='".$id."' class='LSform LSformElement_ssh_key'>".$value."</textarea>\n".$multiple."</li>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (empty($this -> values)) {
|
$GLOBALS['LSsession'] -> addJSscript('LSformElement_ssh_key.js');
|
||||||
$return['html'].="<li>"._('Aucune valeur definie')."</li>\n";
|
$values_txt = array();
|
||||||
}
|
foreach ($this -> values as $value) {
|
||||||
else {
|
if (ereg('^ssh-([a-z]+) (.*)== (.*)$',$value,$regs)) {
|
||||||
$GLOBALS['LSsession'] -> addJSscript('LSformElement_ssh_key.js');
|
$values_txt[] = array(
|
||||||
foreach ($this -> values as $value) {
|
'type' => $regs[1],
|
||||||
if (ereg('^ssh-([a-z]+) (.*)== (.*)$',$value,$regs)) {
|
'shortTxt' => substr($regs[2],0,10),
|
||||||
$return['html'].="<li><span class='LSformElement_ssh_key_short_display' title='"._("Cliquer pour afficher la valeur complète")."'>".substr($regs[2],0,10)."...</span> (Type : ".$regs[1].") <a href='mailto:".$regs[3]."'>".$regs[3]."</a><p class='LSformElement_ssh_key_value'>".$value."</p></li>\n";
|
'mail' => $regs[3],
|
||||||
}
|
'value' => $value
|
||||||
else {
|
);
|
||||||
$return['html'].="<li><span class='LSformElement_ssh_key_short_display'>".substr($value,0,15)."...</span> ("._('Type non reconnu').")<p class='LSformElement_ssh_key_value'>".$value."</p></li>\n";
|
}
|
||||||
}
|
else {
|
||||||
|
$values_txt[] = array(
|
||||||
|
'shortTxt' => substr($value,0,15),
|
||||||
|
'value' => $value
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
$params['values_txt'] = $values_txt;
|
||||||
|
$params['unknowTypeTxt'] = _('Type non reconnu');
|
||||||
}
|
}
|
||||||
$return['html'] .= "</ul>\n";
|
$return['html'] = $this -> fetchTemplate(NULL,$params);
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Retourne le code HTML d'un champ vide
|
|
||||||
*
|
|
||||||
* @retval string Code HTML d'un champ vide.
|
|
||||||
*/
|
|
||||||
function getEmptyField() {
|
|
||||||
$multiple = $this -> getMultipleData();
|
|
||||||
return "<textarea name='".$this -> name."[]' id='LSform".$this -> name."_".rand()."' class='LSform LSformElement_ssh_key'></textarea>\n".$multiple;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
||||||
|
|
7
trunk/templates/default/LSformElement_ssh_key.tpl
Normal file
7
trunk/templates/default/LSformElement_ssh_key.tpl
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
<ul class='LSform{if $multiple && !$freeze} LSformElement_multiple'{/if}' id='{$attr_name}'>
|
||||||
|
{foreach from=$values_txt item=value}
|
||||||
|
<li>{include file=$fieldTemplate}</li>
|
||||||
|
{foreachelse}
|
||||||
|
<li>{include file=$fieldTemplate}</li>
|
||||||
|
{/foreach}
|
||||||
|
</ul>
|
9
trunk/templates/default/LSformElement_ssh_key_field.tpl
Normal file
9
trunk/templates/default/LSformElement_ssh_key_field.tpl
Normal file
|
@ -0,0 +1,9 @@
|
||||||
|
{if $freeze}
|
||||||
|
{if $value.type}
|
||||||
|
<span class='LSformElement_ssh_key_short_display' title='{$span_title}'>{$value.shortTxt}...</span> (Type : {$value.type}) <a href='mailto:{$value.mail}'>{$value.mail}</a><p class='LSformElement_ssh_key_value'>{$value.value}</p>
|
||||||
|
{else}
|
||||||
|
<span class='LSformElement_ssh_key_short_display'>{$value.shortTxt}...</span> ({$unknowTypeTxt})<p class='LSformElement_ssh_key_value'>{$value.value}</p>
|
||||||
|
{/if}
|
||||||
|
{else}
|
||||||
|
<textarea name='{$attr_name}[]' class='LSform LSformElement_ssh_key'>{$value}</textarea>
|
||||||
|
{/if}
|
Loading…
Reference in a new issue