- LSformElement_ssh_key

-> Refonte en utilisant les templates
This commit is contained in:
Benjamin Renard 2008-10-16 14:27:07 +00:00
parent fae498c014
commit 7ee28a4a78
3 changed files with 41 additions and 36 deletions

View file

@ -32,6 +32,9 @@
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
*
@ -42,50 +45,36 @@ class LSformElement_ssh_key extends LSformElement {
function getDisplay(){
$GLOBALS['LSsession'] -> addCssFile('LSformElement_ssh_key.css');
$return = $this -> getLabelInfos();
// value
$return['html'] = "<ul class='LSform'>\n";
$params = array();
if (!$this -> isFreeze()) {
if (empty($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 {
if (empty($this -> values)) {
$return['html'].="<li>"._('Aucune valeur definie')."</li>\n";
$params['values_txt'] = $this -> values;
}
else {
$GLOBALS['LSsession'] -> addJSscript('LSformElement_ssh_key.js');
$values_txt = array();
foreach ($this -> values as $value) {
if (ereg('^ssh-([a-z]+) (.*)== (.*)$',$value,$regs)) {
$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";
$values_txt[] = array(
'type' => $regs[1],
'shortTxt' => substr($regs[2],0,10),
'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";
$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;
}
/**
* 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;
}
}
?>

View 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>

View 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}