*/ class LSformElement_ssh_key extends LSformElement { var string $template = 'LSformElement_ssh_key.tpl'; var string $fieldTemplate = 'LSformElement_ssh_key_field.tpl'; /** * Parse one value * * @param string $value The value to parse * @param boolean $details Enable/disable details return (optional, default: true) * * @return array|string Parsed value as array is $details is enabled, the raw value otherwise */ public function parseValue($value, $details=true) { if (!$details) return $value; if (preg_match('/^ssh-([a-z0-9]+) +([^ ]+) +(.*)$/', $value, $regs)) { return array( 'type' => $regs[1], 'mail' => $regs[3], 'value' => $value ); } return array( 'type' => null, 'mail' => null, 'value' => $value ); } /** * Retourne les infos d'affichage de l'élément * * Cette méthode retourne les informations d'affichage de l'élement * * @return array */ public function getDisplay(){ LStemplate :: addCssFile('LSformElement_ssh_key.css'); $return = $this -> getLabelInfos(); $params = array(); if (!$this -> isFreeze()) { $params['values_txt'] = $this -> values; } else { LStemplate :: addJSscript('LSformElement_ssh_key.js'); LStemplate :: addHelpInfo( 'LSformElement_ssh_key', array( 'display' => _("Display the full key.") ) ); $values_txt = array(); foreach ($this -> values as $value) { $parsedValue = $this -> parseValue($value); $parsedValue['shortTxt'] = substr($value, 0, 15); $values_txt[] = $parsedValue; } $params['values_txt'] = $values_txt; $params['unknowTypeTxt'] = _('Unknown type'); } $return['html'] = $this -> fetchTemplate(NULL,$params); return $return; } }