diff --git a/debian/changelog b/debian/changelog index deca249b..56677ecd 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,28 @@ +ldapsaisie (1.8-1) unstable; urgency=medium + + * LSdefault : encode LSjsConfig data in Base64 + * LSattr_html : + + password : add get_mail_attr_function parameter + + valueWithUnit : add translate_labels, store_integer and round_down parameters + + jsonCompositeAttribute : + + Add help_info and multiple parameters on components + + Fix foreach syntax for retro-compat with old Smarty versions + + fix JS clear value method + + select_list : + + add possiblity to use values of other attribute as possible values + + fix warning on empty jsonCompositeAttribute possible values + + fix invalid possible values on empty other attribute value + * LSldap : fix/improve getAttr() method + * LSformElement.js : do not handle sub li elements during initialization + * Translation : fix error when trying to translate empty string + * ldapsaisie-generate-lang-file (generate_lang_file.php) : + + improve to handle new config parameters + + add interactive mode + + add output file feature + + add short parameters + + -- Benjamin Renard Wed, 16 May 2018 17:42:02 +0200 + ldapsaisie (1.7-2) unstable; urgency=medium * Fix cron and doc about new tmp dir path diff --git a/doc/conf/LSattribute/LSattr_html.docbook b/doc/conf/LSattribute/LSattr_html.docbook index 4a9df3c0..827b0bc0 100644 --- a/doc/conf/LSattribute/LSattr_html.docbook +++ b/doc/conf/LSattribute/LSattr_html.docbook @@ -7,6 +7,7 @@ &conf-LSattr_html_date; &conf-LSattr_html_image; &conf-LSattr_html_jsonCompositeAttribute; + &conf-LSattr_html_labeledValue; &conf-LSattr_html_mail; &conf-LSattr_html_maildir; &conf-LSattr_html_mailQuota; diff --git a/doc/conf/LSattribute/LSattr_html/LSattr_html.entities.xml b/doc/conf/LSattribute/LSattr_html/LSattr_html.entities.xml index e29c60a3..55440ae3 100644 --- a/doc/conf/LSattribute/LSattr_html/LSattr_html.entities.xml +++ b/doc/conf/LSattribute/LSattr_html/LSattr_html.entities.xml @@ -3,6 +3,7 @@ + @@ -20,4 +21,5 @@ +LSattr_html_jsonCompositeAttribute"> LSattr_html_select_list"> diff --git a/doc/conf/LSattribute/LSattr_html/LSattr_html_jsonCompositeAttribute.docbook b/doc/conf/LSattribute/LSattr_html/LSattr_html_jsonCompositeAttribute.docbook index 09fe1097..1eeb58a8 100644 --- a/doc/conf/LSattribute/LSattr_html/LSattr_html_jsonCompositeAttribute.docbook +++ b/doc/conf/LSattribute/LSattr_html/LSattr_html_jsonCompositeAttribute.docbook @@ -19,8 +19,10 @@ 'components' => array ( '[clé composant 1]' => array ( 'label' => '[Label du composant]', + 'help_info' => '[Message d'aide sur le composant]', 'type' => '[Type de la valeur stocké]', 'required' => [Booléen], + 'multiple' => [Booléen], 'check_data' => => array ( // Régle de vérification syntaxique des données saisies ), @@ -57,6 +59,14 @@ + + help_info + + Message d'aide sur le composant (affiché uniquement en mode édition). + + + + type @@ -77,6 +87,22 @@ + + multiple + + Booléen définissant si ce composant peut stocker plusieurs valeurs (Défaut : + Faux). + + + + + required + + Booléen définissant si ce composant doit obligatoirement être défini (Défaut : + Faux). + + + check_data diff --git a/doc/conf/LSattribute/LSattr_html/LSattr_html_labeledValue.docbook b/doc/conf/LSattribute/LSattr_html/LSattr_html_labeledValue.docbook new file mode 100644 index 00000000..bcd7ea62 --- /dev/null +++ b/doc/conf/LSattribute/LSattr_html/LSattr_html_labeledValue.docbook @@ -0,0 +1,33 @@ + + LSattr_html_labeledValue + Ce type est utilisé pour la gestion des attributs dont la valeur est + prefixé d'un label et qui respecte le format suivant : + [label]valeur. + + +Structure... + array( + 'labels' => array ( // Liste des labels possible + 'label1' => 'Libellé label1', + 'label2' => 'Libellé label2', + [...] + ), +),]]> +... + + + +Paramètres de configuration + + + labels + + Tableau associatif obligatoire contenant en valeur clé, le + label utilisé dans la valeur stockée et en valeur + associée, le valeur d'affichage du label. + + + + + + diff --git a/doc/conf/LSattribute/LSattr_html/LSattr_html_select_list.docbook b/doc/conf/LSattribute/LSattr_html/LSattr_html_select_list.docbook index ae41e1d3..f75596e5 100644 --- a/doc/conf/LSattribute/LSattr_html/LSattr_html_select_list.docbook +++ b/doc/conf/LSattribute/LSattr_html/LSattr_html_select_list.docbook @@ -22,6 +22,19 @@ 'basedn' => '[Basedn de la recherche]', 'onlyAccessible' => '[Booléen]' ), + 'OTHER_ATTRIBUTE' => '[attr]', + // Or : + 'OTHER_ATTRIBUTE' => array( + '[attr1]' => '[label1]', + '[attr2]' => '[label2]', + [...] + ), + // Or : + 'OTHER_ATTRIBUTE' => array( + 'attr' => [attr], + 'json_component_key' => '[Composant JSON clé]', + 'json_component_label' => '[Composant JSON label]', + ), array ( 'label' => '[LSformat du nom du groupe de valeurs]', 'possible_values' => array ( @@ -128,6 +141,37 @@ + Si la valeur clé est égale à OTHER_ATTRIBTE, une liste + de valeur possible sera composée à l'aide des valeurs d'un (ou plusieurs) autre + attribut de l'objet courant. La valeur associée peut être alors : + + + + soit le nom d'un attribut dont les valeurs seront utilisées comme valeurs + possibles (la valeur affichée est égale à la valeur stockée). + + + + soit un tableau associatif dont les valeurs clés sont les noms des attributs + dont les valeurs seront utilisés comme valeurs possibles et dont les valeurs associés + seront les labels sous lesquels ces valeurs seront regroupées (la valeur + affichée est égale à la valeur stockée). + + + + soit un tableau associatif référençant un attribut sous la clé attr + dont les valeurs seront utilisées comme valeurs possibles. Cet attribut + peut-être du type &LSattr_html_jsonCompositeAttribute;. Il sera alors possible d'utiliser + les valeurs d'un composant en particulier en le référençant à l'aide de la clé + json_component_key. Il est également possible de référencer un autre composant + à l'aide de la clé json_component_label et dont les valeurs seront + utilisées comme valeurs affichées lors de la sélection. À défaut, les valeurs affichées + seront identiques à celles stockées. + + + + + diff --git a/doc/conf/LSattribute/LSattr_ldap.docbook b/doc/conf/LSattribute/LSattr_ldap.docbook index d7d563a1..aced44c1 100644 --- a/doc/conf/LSattribute/LSattr_ldap.docbook +++ b/doc/conf/LSattribute/LSattr_ldap.docbook @@ -5,6 +5,7 @@ &conf-LSattr_ldap_ascii; &conf-LSattr_ldap_boolean; + &conf-LSattr_ldap_compositeValueToJSON; &conf-LSattr_ldap_date; &conf-LSattr_ldap_image; &conf-LSattr_ldap_numeric; diff --git a/doc/conf/LSattribute/LSattr_ldap/LSattr_ldap.entities.xml b/doc/conf/LSattribute/LSattr_ldap/LSattr_ldap.entities.xml index 9cf9b70a..ee8af9b6 100644 --- a/doc/conf/LSattribute/LSattr_ldap/LSattr_ldap.entities.xml +++ b/doc/conf/LSattribute/LSattr_ldap/LSattr_ldap.entities.xml @@ -1,6 +1,7 @@ + diff --git a/doc/conf/LSattribute/LSattr_ldap/LSattr_ldap_compositeValueToJSON.docbook b/doc/conf/LSattribute/LSattr_ldap/LSattr_ldap_compositeValueToJSON.docbook new file mode 100644 index 00000000..6f9a0fd5 --- /dev/null +++ b/doc/conf/LSattribute/LSattr_ldap/LSattr_ldap_compositeValueToJSON.docbook @@ -0,0 +1,9 @@ + + LSattr_ldap_compositeValueToJSON + Ce type est utilisé pour la gestion des attributs composites dont les + valeurs respectent le format suivant : + [key1=value1][key2=value2][...] + Ce type d'attribut LDAP sera utilisé pour convertir la valeur en son + équivalent JSON pour pouvoir être traité à l'aide du type d' + attribut HTML &LSattr_html_jsonCompositeAttribute;. + diff --git a/public_html/css/default/LSformElement_jsonCompositeAttribute.css b/public_html/css/default/LSformElement_jsonCompositeAttribute.css index 28b641f3..cae1b0ca 100644 --- a/public_html/css/default/LSformElement_jsonCompositeAttribute.css +++ b/public_html/css/default/LSformElement_jsonCompositeAttribute.css @@ -7,12 +7,29 @@ ul.LSformElement_jsonCompositeAttribute li.noValue { border: none; } -ul.LSformElement_jsonCompositeAttribute p { +ul.LSformElement_jsonCompositeAttribute div { + margin: 0; + margin-bottom: 2px; +} + +ul.LSformElement_jsonCompositeAttribute div label { + display: inline-block; + height: 100%; + vertical-align: top; + width: 10em; + font-weight: bold; +} + +ul.LSformElement_jsonCompositeAttribute div ul { + display: inline-block; + list-style-type: none; + padding: 0; margin: 0; } -ul.LSformElement_jsonCompositeAttribute p label { - font-weight: bold; +ul.LSformElement_jsonCompositeAttribute div ul li { + margin-bottom: 2px; + border: none; } div.jsonCompositeAttribute_possibleValues ul { diff --git a/public_html/includes/class/class.LSattr_html_labeledValue.php b/public_html/includes/class/class.LSattr_html_labeledValue.php new file mode 100644 index 00000000..a0b36e76 --- /dev/null +++ b/public_html/includes/class/class.LSattr_html_labeledValue.php @@ -0,0 +1,32 @@ + + */ +class LSattr_html_labeledValue extends LSattr_html { + + var $LSformElement_type = 'labeledValue'; + +} diff --git a/public_html/includes/class/class.LSattr_html_select_list.php b/public_html/includes/class/class.LSattr_html_select_list.php index 396d7f63..8922d325 100644 --- a/public_html/includes/class/class.LSattr_html_select_list.php +++ b/public_html/includes/class/class.LSattr_html_select_list.php @@ -88,6 +88,10 @@ class LSattr_html_select_list extends LSattr_html{ $objInfos=self :: getLSobjectPossibleValues($val_label,$options,$name); $retInfos=self :: _array_merge($retInfos,$objInfos); } + elseif($val_key==='OTHER_ATTRIBUTE') { + $attrInfos=self :: getLSattributePossibleValues($val_label, $options, $name, $ldapObject); + $retInfos=self :: _array_merge($retInfos,$attrInfos); + } elseif (is_array($val_label)) { if (!isset($val_label['possible_values']) || !is_array($val_label['possible_values']) || !isset($val_label['label'])) continue; @@ -273,6 +277,90 @@ class LSattr_html_select_list extends LSattr_html{ return $retInfos; } + + /** + * Retourne un tableau des valeurs possibles d'un autre attribut + * + * @param[in] $attr OTHER_ATTRIBUTE configuration value + * @param[in] $options array|false Attribute options + * @param[in] $name Attribute name + * @param[in] $LSldapObject LSldapObject reference + * + * @author Benjamin Renard + * + * @retval array Tableau associatif des valeurs possible de la liste avec en clé + * la valeur des balises option et en valeur ce qui sera affiché. + */ + protected function getLSattributePossibleValues($attr, $options ,$name ,&$ldapObject) { + $retInfos=array(); + if (is_string($attr)) { + if (isset($ldapObject->attrs[$attr]) && $ldapObject->attrs[$attr] instanceof LSattribute) { + $attr_values = $ldapObject->attrs[$attr]->getValue(); + if (!$attr_values) + $attr_values = array(); + elseif (!is_array($attr_values)) + $attr_values = array($attr_values); + foreach($attr_values as $attr_value) + $retInfos[$attr_value] = __($attr_value); + } + else + LSerror :: addErrorCode('LSattr_html_select_list_02',$attr); + } + elseif (is_array($attr)) { + if (isset($attr['attr'])) { + if (isset($ldapObject->attrs[$attr['attr']]) && $ldapObject->attrs[$attr['attr']] instanceof LSattribute) { + if (isset($attr['json_component_key'])) { + if (get_class($ldapObject->attrs[$attr['attr']]->html) == 'LSattr_html_jsonCompositeAttribute') { + $attr_values = $ldapObject->attrs[$attr['attr']]->getValue(); + if (!$attr_values) + $attr_values = array(); + elseif (!is_array($attr_values)) + $attr_values = array($attr_values); + foreach($attr_values as $attr_value) { + $value_data = @json_decode($attr_value, true); + if (!isset($value_data[$attr['json_component_key']])) { + LSerror :: addErrorCode('LSattr_html_select_list_05', array('attr' => $attr['attr'], 'value' => $attr_value, 'component' => $attr['json_component_key'])); + return $retInfos; + } + $key = $value_data[$attr['json_component_key']]; + + if (isset($attr['json_component_label'])) { + if (!isset($value_data[$attr['json_component_label']])) { + LSerror :: addErrorCode('LSattr_html_select_list_05', array('attr' => $attr['attr'], 'value' => $attr_value, 'component' => $attr['json_component_label'])); + return $retInfos; + } + $label = $value_data[$attr['json_component_label']]; + } + else + $label = $key; + + $retInfos[$key] = $label; + } + } + else + LSerror :: addErrorCode('LSattr_html_select_list_03',$attr['attr']); + } + else + $retInfos = self :: getLSattributePossibleValues($attr['attr'], $options ,$name ,$ldapObject); + } + else + LSerror :: addErrorCode('LSattr_html_select_list_02',$attr['attr']); + } + else { + foreach($attr as $sub_attr => $sub_label) { + $subRetInfos = self :: getLSattributePossibleValues($sub_attr, $options ,$name ,$ldapObject); + self :: _sort($subRetInfos,$options); + $retInfos[] = array ( + 'label' => $sub_label, + 'possible_values' => $subRetInfos + ); + } + } + } + self :: _sort($retInfos,$options); + return $retInfos; + } + } /* @@ -281,3 +369,15 @@ class LSattr_html_select_list extends LSattr_html{ LSerror :: defineError('LSattr_html_select_list_01', _("LSattr_html_select_list : Configuration data are missing to generate the select list of the attribute %{attr}.") ); +LSerror :: defineError('LSattr_html_select_list_02', +_("LSattr_html_select_list : Invalid attribute %{attr} reference as OTHER_ATTRIBUTE possible values.") +); +LSerror :: defineError('LSattr_html_select_list_03', +_("LSattr_html_select_list : Attribute %{attr} referenced as OTHER_ATTRIBUTE possible values is not a jsonCompositeAttribute.") +); +LSerror :: defineError('LSattr_html_select_list_04', +_("LSattr_html_select_list : Fail to decode the following attribute %{attr} value as JSON : %{value}") +); +LSerror :: defineError('LSattr_html_select_list_05', +_("LSattr_html_select_list : No component %{component} found in the following attribute %{attr} JSON value : %{value}") +); diff --git a/public_html/includes/class/class.LSattr_ldap_compositeValueToJSON.php b/public_html/includes/class/class.LSattr_ldap_compositeValueToJSON.php new file mode 100644 index 00000000..5cf3e770 --- /dev/null +++ b/public_html/includes/class/class.LSattr_ldap_compositeValueToJSON.php @@ -0,0 +1,90 @@ + $val) + $ret[$key] = json_encode(self :: parseValue($val)); + return $ret; + } + return $data; + } + + /** + * Retourne la valeur de l'attribut après traitement lié à son type ldap + * + * @param[in] $data mixed La valeur de l'attribut + * + * @retval mixed La valeur traitée de l'attribut + */ + function getUpdateData($data) { + if ($data) { + if (!is_array($data)) + $data = array($data); + $ret = array(); + foreach($data as $key => $val) + $ret[$key] = self :: encodeValue(json_decode($val, true)); + return $ret; + } + return $data; + } + + function parseValue($value) { + if (preg_match_all('/\[([^=]*)=([^\]]*)\]/',$value,$matches)) { + $parseValue=array(); + for($i=0;$i $val) + $ret.="[$key=$val]"; + return $ret; + } + return False; + } +} diff --git a/public_html/includes/class/class.LSformElement_jsonCompositeAttribute.php b/public_html/includes/class/class.LSformElement_jsonCompositeAttribute.php index 2a480939..578cc7fe 100644 --- a/public_html/includes/class/class.LSformElement_jsonCompositeAttribute.php +++ b/public_html/includes/class/class.LSformElement_jsonCompositeAttribute.php @@ -100,6 +100,20 @@ class LSformElement_jsonCompositeAttribute extends LSformElement { ) ); LSsession :: addCssFile('LSformElement_jsonCompositeAttribute.css'); + if (!$this -> isFreeze()) { + LSsession :: addJSconfigParam( + $this -> name, + array ( + 'components' => $this -> components, + ) + ); + LSsession :: addJSscript('LSformElement_jsonCompositeAttribute_field_value_component_text_value.js'); + LSsession :: addJSscript('LSformElement_jsonCompositeAttribute_field_value_component.js'); + LSsession :: addJSscript('LSformElement_jsonCompositeAttribute_field_value.js'); + LSsession :: addJSscript('LSformElement_jsonCompositeAttribute_field.js'); + LSsession :: addJSscript('LSformElement_jsonCompositeAttribute.js'); + } + return $return; } @@ -132,19 +146,29 @@ class LSformElement_jsonCompositeAttribute extends LSformElement { * * @param[in] $c string The component name * @param[in] $value string The value + * @param[in] $inLoop boolean Internal param to control recursion * * @retval array **/ - function translateComponentValue($c,$value) { - $retval = array ( - 'translated' => $value, - 'value' => $value, - ); - if (isset($this -> components[$c])) { - if ($this -> components[$c]['type']=='select_list') { - $retval['translated'] = $this -> getSelectListComponentValueLabel($c,$value); + function translateComponentValue($c,$value,$inLoop=false) { + if (!$inLoop && isset($this -> components[$c]['multiple']) && $this -> components[$c]['multiple']) { + $retval = array(); + if (!is_array($value)) + $value = array($value); + foreach($value as $val) + $retval[] = $this -> translateComponentValue($c, $val, true); + } + else { + $retval = array ( + 'translated' => $value, + 'value' => $value, + ); + if (isset($this -> components[$c])) { + if ($this -> components[$c]['type']=='select_list') { + $retval['translated'] = $this -> getSelectListComponentValueLabel($c,$value); + } + //elseif type == 'text' => no transformation } - //elseif type == 'text' => no transformation } return $retval; } @@ -202,66 +226,73 @@ class LSformElement_jsonCompositeAttribute extends LSformElement { return true; } - $count=0; - $end=false; $return[$this -> name]=array(); - while ($end==false) { - $value=array(); - $parseValue=array(); - $errors=array(); - $unemptyComponents=array(); - foreach ($this -> components as $c => $cconf) { - if (isset($_POST[$this -> name.'__'.$c][$count])) { - $parseValue[$c]=$_POST[$this -> name.'__'.$c][$count]; - if ($cconf['required'] && empty($parseValue[$c])) { - $errors[]=getFData(__('Component %{c} must be defined'),__($cconf['label'])); - continue; - } - if (empty($parseValue[$c])) { - continue; - } - $unemptyComponents[]=$c; - if ($cconf['type']=='select_list') { - if (!$this -> getSelectListComponentValueLabel($c, $parseValue[$c])) { - $errors[]=getFData(__('Invalid value for component %{c}.'),__($cconf['label'])); - } - } - if (is_array($cconf['check_data'])) { - foreach($cconf['check_data'] as $ruleType => $rconf) { - $className='LSformRule_'.$ruleType; - if (LSsession::loadLSclass($className)) { - $r=new $className(); - if (!$r -> validate($parseValue[$c],$rconf,$this)) { - if (isset($rconf['msg'])) { - $errors[]=getFData(__($rconf['msg']),__($cconf['label'])); + if (is_array($_POST[$this -> name.'__values_uuid'])) { + foreach ($_POST[$this -> name.'__values_uuid'] as $uuid) { + $value=array(); + $parseValue=array(); + $errors=array(); + $unemptyComponents=array(); + + foreach ($this -> components as $c => $cconf) { + if (isset($_POST[$this -> name.'__'.$c.'__'.$uuid])) { + if (!is_array($_POST[$this -> name.'__'.$c.'__'.$uuid])) + $_POST[$this -> name.'__'.$c.'__'.$uuid] = array($_POST[$this -> name.'__'.$c.'__'.$uuid]); + + $parseValue[$c]=array(); + foreach($_POST[$this -> name.'__'.$c.'__'.$uuid] as $val) { + if (empty($val)) + continue; + $parseValue[$c][] = $val; + if ($cconf['type']=='select_list') { + if (!$this -> getSelectListComponentValueLabel($c, $val)) { + $errors[]=getFData(_('Invalid value "%{value}" for component %{component}.'),array('value' => $val, 'component' => __($cconf['label']))); + } + } + if (is_array($cconf['check_data'])) { + foreach($cconf['check_data'] as $ruleType => $rconf) { + $className='LSformRule_'.$ruleType; + if (LSsession::loadLSclass($className)) { + $r=new $className(); + if (!$r -> validate($val,$rconf,$this)) { + if (isset($rconf['msg'])) { + $errors[]=getFData(__($rconf['msg']),__($cconf['label'])); + } + else { + $errors[]=getFData(_('Invalid value "%{value}" for component %{component}.'),array('value' => $val, 'component' => __($cconf['label']))); + } + } } else { - $errors[]=getFData(__('Invalid value for component %{c}.'),__($cconf['label'])); + $errors[]=getFData(_("Can't validate value of component %{c}."),__($cconf['label'])); } } } - else { - $errors[]=getFData(__("Can't validate value of component %{c}."),__($cconf['label'])); - } } + + if (!isset($cconf['multiple']) || !$cconf['multiple']) { + if (count($parseValue[$c])>=1) + $parseValue[$c] = $parseValue[$c][0]; + else + $parseValue[$c] = ''; + } + + if ($cconf['required'] && empty($parseValue[$c])) { + $errors[]=getFData(_('Component %{c} must be defined'),__($cconf['label'])); + continue; + } + $unemptyComponents[]=$c; + + $value[$c]=$parseValue[$c]; } - $value[$c]=$parseValue[$c]; - } - else { - // end of value break - $end=true; - break; } - } - if (!$end) { if (!empty($unemptyComponents)) { foreach($errors as $e) { $this -> form -> setElementError($this -> attr_html,$e); } $return[$this -> name][]=json_encode($value); } - $count++; } } return true; diff --git a/public_html/includes/class/class.LSformElement_labeledValue.php b/public_html/includes/class/class.LSformElement_labeledValue.php new file mode 100644 index 00000000..47333205 --- /dev/null +++ b/public_html/includes/class/class.LSformElement_labeledValue.php @@ -0,0 +1,128 @@ + + */ + +class LSformElement_labeledValue extends LSformElement { + + var $template = 'LSformElement_labeledValue.tpl'; + var $fieldTemplate = 'LSformElement_labeledValue_field.tpl'; + + /** + * Retourne les infos d'affichage de l'élément + * + * Cette méthode retourne les informations d'affichage de l'élement + * + * @retval array + */ + function getDisplay(){ + $return = $this -> getLabelInfos(); + + $parseValues=array(); + foreach($this -> values as $val) { + $parseValues[]=$this -> parseValue($val); + } + $return['html'] = $this -> fetchTemplate(NULL,array( + 'labels' => $this -> params['html_options']['labels'], + 'parseValues' => $parseValues, + 'unrecognizedValueTxt' => __('(unrecognized value)'), + 'unrecognizedLabelTxt' => __('(unrecognized label)'), + )); + return $return; + } + + /** + * Retourne le code HTML d'un champ vide + * + * @retval string Code HTML d'un champ vide. + */ + function getEmptyField() { + return $this -> fetchTemplate($this -> fieldTemplate,array( + 'labels' => $this -> params['html_options']['labels'], + )); + } + + + /** + * Parse une valeur + * + * @param[in] $value La valeur + * + * @retval array Un tableau cle->valeur contenant value et label + **/ + function parseValue($value) { + $ret=array('raw_value' => $value); + if (preg_match('/^\[([^\]]*)\](.*)$/',$value,$m)) { + $ret['label'] = $m[1]; + if (isset($this -> params['html_options']['labels'][$ret['label']])) + $ret['translated_label'] = $this -> params['html_options']['labels'][$ret['label']]; + $ret['value'] = $m[2]; + } + return $ret; + } + + /** + * Recupère la valeur de l'élement passée en POST + * + * Cette méthode vérifie la présence en POST de la valeur de l'élément et la récupère + * pour la mettre dans le tableau passer en paramètre avec en clef le nom de l'élément + * + * @param[] array Pointeur sur le tableau qui recupèrera la valeur. + * + * @retval boolean true si la valeur est présente en POST, false sinon + */ + function getPostData(&$return) { + if($this -> isFreeze()) { + return true; + } + if (isset($_POST[$this -> name."_labels"]) && isset($_POST[$this -> name."_values"])) { + $return[$this -> name]=array(); + if(!is_array($_POST[$this -> name."_labels"])) { + $_POST[$this -> name."_labels"] = array($_POST[$this -> name."_labels"]); + } + if(!is_array($_POST[$this -> name."_values"])) { + $_POST[$this -> name."_values"] = array($_POST[$this -> name."_values"]); + } + foreach($_POST[$this -> name."_labels"] as $key => $label) { + $val=$_POST[$this -> name."_values"][$key]; + if (!empty($label) && (!empty($val)||(is_string($val)&&($val=="0")))) { + $return[$this -> name][$key] = "[$label]$val"; + } + } + return true; + } + else { + $return[$this -> name] = array(); + return true; + } + } + +} diff --git a/public_html/includes/class/class.LSldap.php b/public_html/includes/class/class.LSldap.php index 43cf14c5..6c387067 100644 --- a/public_html/includes/class/class.LSldap.php +++ b/public_html/includes/class/class.LSldap.php @@ -194,12 +194,7 @@ class LSldap { $infos = ldap_explode_dn($dn,0); if((!$infos)||($infos['count']==0)) return; - $basedn=''; - for ($i=1;$i<$infos['count'];$i++) { - $sep=($basedn=='')?'':','; - $basedn.=$sep.$infos[$i]; - } - $return=self :: search($infos[0],$basedn); + $return=self :: search('(objectClass=*)',$dn); return $return[0]['attrs']; } diff --git a/public_html/includes/class/class.LSsession.php b/public_html/includes/class/class.LSsession.php index 304e4c48..5b5af697 100644 --- a/public_html/includes/class/class.LSsession.php +++ b/public_html/includes/class/class.LSsession.php @@ -1364,7 +1364,7 @@ class LSsession { self :: addJSconfigParam('keepLSsessionActive',ini_get('session.gc_maxlifetime')); } - LStemplate :: assign('LSjsConfig',json_encode(self :: $_JSconfigParams)); + LStemplate :: assign('LSjsConfig',base64_encode(json_encode(self :: $_JSconfigParams))); if (LSdebug) { $JSscript_txt.="\n"; diff --git a/public_html/includes/class/class.LStemplate.php b/public_html/includes/class/class.LStemplate.php index 9f816f38..de5d97aa 100644 --- a/public_html/includes/class/class.LStemplate.php +++ b/public_html/includes/class/class.LStemplate.php @@ -122,6 +122,7 @@ class LStemplate { self :: registerFunction("tr", "LStemplate_smarty_tr"); self :: registerFunction("img", "LStemplate_smarty_img"); self :: registerFunction("css", "LStemplate_smarty_css"); + self :: registerFunction("uniqid", "LStemplate_smarty_uniqid"); return True; } @@ -297,6 +298,12 @@ function LStemplate_smarty_css($params) { echo LStemplate :: getCSSPath($name); } +function LStemplate_smarty_uniqid($params, &$smarty) { + if (!isset($params['var'])) + $params['var'] = 'uniqid'; + $smarty -> assign($params['var'], uniqid()); +} + // Errors LSerror :: defineError('LStemplate_01', _("LStemplate : Template %{file} not found.") diff --git a/public_html/includes/functions.php b/public_html/includes/functions.php index 3cd0c01a..47f6981a 100644 --- a/public_html/includes/functions.php +++ b/public_html/includes/functions.php @@ -473,6 +473,7 @@ function LSdebugDefined() { } function __($msg) { + if (empty($msg)) return $msg; if (isset($GLOBALS['LSlang'][$msg])) { return $GLOBALS['LSlang'][$msg]; } diff --git a/public_html/includes/js/LSdefault.js b/public_html/includes/js/LSdefault.js index 3a1b6478..2d42b180 100644 --- a/public_html/includes/js/LSdefault.js +++ b/public_html/includes/js/LSdefault.js @@ -24,7 +24,7 @@ var LSdefault = new Class({ // LSjsConfig this.LSjsConfigEl = $('LSjsConfig'); if ($type(this.LSjsConfigEl)) { - this.LSjsConfig = JSON.decode(this.LSjsConfigEl.innerHTML); + this.LSjsConfig = JSON.decode(atob(this.LSjsConfigEl.innerHTML)); } else { this.LSjsConfig = []; diff --git a/public_html/includes/js/LSformElement.js b/public_html/includes/js/LSformElement.js index 1ed6e758..2bd74bbe 100644 --- a/public_html/includes/js/LSformElement.js +++ b/public_html/includes/js/LSformElement.js @@ -10,7 +10,7 @@ var LSformElement = new Class({ initializeLSformElement: function(li) { if (typeof(li) == 'undefined') { - var elements = this.ul.getElements('li'); + var elements = this.ul.getChildren('li'); } else { var elements = [li]; @@ -50,7 +50,7 @@ var LSformElement = new Class({ }, onRemoveFieldBtnClick: function(field) { - if (this.ul.getElements('li').length == 1) { + if (this.ul.getChildren('li').length == 1) { field.clearValue.bind(field)(); } else { diff --git a/public_html/includes/js/LSformElement_jsonCompositeAttribute.js b/public_html/includes/js/LSformElement_jsonCompositeAttribute.js new file mode 100644 index 00000000..637f4c3c --- /dev/null +++ b/public_html/includes/js/LSformElement_jsonCompositeAttribute.js @@ -0,0 +1,18 @@ +var LSformElement_jsonCompositeAttribute = new Class({ + initialize: function(){ + this.fields = []; + this.initialiseLSformElement_jsonCompositeAttribute(); + }, + + initialiseLSformElement_jsonCompositeAttribute: function(el) { + if (!$type(el)) { + el = document; + } + el.getElements('ul.LSformElement_jsonCompositeAttribute').each(function(ul) { + this.fields[ul.id] = new LSformElement_jsonCompositeAttribute_field(ul); + }, this); + } +}); +window.addEvent(window.ie ? 'load' : 'domready', function() { + varLSformElement_jsonCompositeAttribute = new LSformElement_jsonCompositeAttribute(); +}); diff --git a/public_html/includes/js/LSformElement_jsonCompositeAttribute_field.js b/public_html/includes/js/LSformElement_jsonCompositeAttribute_field.js new file mode 100644 index 00000000..2cfedc5d --- /dev/null +++ b/public_html/includes/js/LSformElement_jsonCompositeAttribute_field.js @@ -0,0 +1,32 @@ +var LSformElement_jsonCompositeAttribute_field = new Class({ + initialize: function(ul){ + this.ul=ul; + this.dd=ul.getParent(); + this.name = ul.id; + this.values = []; + this.field_type = ul.get('data-fieldType'); + this.initializeLSformElement_jsonCompositeAttribute_field(); + varLSform.addField(this.name,this); + }, + + initializeLSformElement_jsonCompositeAttribute_field: function(el) { + if (!$type(el)) { + el = this.ul; + } + el.getChildren('li').each(function(li) { + this.values.push(new LSformElement_jsonCompositeAttribute_field_value(li,this.name,this.field_type)); + }, this); + }, + + clearValue: function() { + if (this.values.length>1) { + for(var i=1; i<=this.values.length; i++) { + $(this.values[i].li).dispose(); + } + this.values[0].clear(); + } + else if (this.values.length==1) { + this.values[0].clear(); + } + } +}); diff --git a/public_html/includes/js/LSformElement_jsonCompositeAttribute_field_value.js b/public_html/includes/js/LSformElement_jsonCompositeAttribute_field_value.js new file mode 100644 index 00000000..6277b4c7 --- /dev/null +++ b/public_html/includes/js/LSformElement_jsonCompositeAttribute_field_value.js @@ -0,0 +1,31 @@ +var LSformElement_jsonCompositeAttribute_field_value = new Class({ + initialize: function(li,name,field_type){ + this.li=li; + this.name = name; + this.input_uuid = li.getElement('input[name='+name+'__values_uuid[]]'); + this.uuid = this.input_uuid.get('value'); + this.components = {}; + this.field_type = field_type; + this.initializeLSformElement_jsonCompositeAttribute_field_value(); + varLSform.addModule(field_type,this); + }, + + initializeLSformElement_jsonCompositeAttribute_field_value: function(el) { + if (!$type(el)) { + el = this.li; + } + el.getElements('div').each(function(div) { + this.components[div.get('data-component')]=new LSformElement_jsonCompositeAttribute_field_value_component(div,div.get('data-component'),this.name,this.uuid); + }, this); + }, + + reinitialize: function(el) { + this.initializeLSformElement_jsonCompositeAttribute_field_value(el); + }, + + clear: function() { + for (c in this.components) { + this.components[c].clear(); + } + } +}); diff --git a/public_html/includes/js/LSformElement_jsonCompositeAttribute_field_value_component.js b/public_html/includes/js/LSformElement_jsonCompositeAttribute_field_value_component.js new file mode 100644 index 00000000..a8dec162 --- /dev/null +++ b/public_html/includes/js/LSformElement_jsonCompositeAttribute_field_value_component.js @@ -0,0 +1,62 @@ +var LSformElement_jsonCompositeAttribute_field_value_component = new Class({ + initialize: function(div,name,field_name,field_uuid){ + this.div = div; + + this.field_name = field_name; + this.field_uuid = field_uuid; + this.field_params = varLSdefault.LSjsConfig[this.field_name]; + + this.name = name; + this.params = this.field_params['components'][this.name]; + + this.label = div.getElement('label'); + if (this.params.type == 'select_list') { + this.select = div.getElement('select'); + } + else { + // Type text + this.ul = div.getElement('ul'); + this.lis = {}; + this.values = {}; + this.ul.getElements('li').each(function(li) { + this.initTextComponentValue(li); + }, this); + } + }, + + initTextComponentValue: function(li) { + var uuid = generate_uuid(); + this.lis[uuid] = li; + this.values[uuid] = new LSformElement_jsonCompositeAttribute_field_value_component_text_value(this,li); + }, + + onAddTextValueBtnClick: function(after) { + var li = new Element('li'); + var input = new Element('input'); + input.type='text'; + input.name=this.field_name+'__'+this.name+'__'+this.field_uuid+'[]'; + input.injectInside(li); + li.injectAfter(after.li); + this.initTextComponentValue(li); + }, + + onRemoveTextValueBtnClick: function(value) { + if (this.ul.getElements('li').length == 1) { + value.clear.bind(value)(); + } + else { + value.remove.bind(value)(); + } + }, + + clear: function() { + if (this.params.type == 'select_list') { + this.select.selectedIndex=-1; + } + else { + Object.each(this.values, function(value) { + value.clear(); + }, this); + } + } +}); diff --git a/public_html/includes/js/LSformElement_jsonCompositeAttribute_field_value_component_text_value.js b/public_html/includes/js/LSformElement_jsonCompositeAttribute_field_value_component_text_value.js new file mode 100644 index 00000000..29f2dfa9 --- /dev/null +++ b/public_html/includes/js/LSformElement_jsonCompositeAttribute_field_value_component_text_value.js @@ -0,0 +1,30 @@ +var LSformElement_jsonCompositeAttribute_field_value_component_text_value = new Class({ + initialize: function(component,li) { + this.component = component; + this.li = li; + + this.input = li.getElement('input'); + + if (this.component.params.multiple) { + this.addValueBtn = new Element('img'); + this.addValueBtn.src = varLSdefault.imagePath('add'); + this.addValueBtn.addClass('btn'); + this.addValueBtn.addEvent('click',this.component.onAddTextValueBtnClick.bind(this.component,this)); + this.addValueBtn.injectInside(this.li); + + this.removeValueBtn = new Element('img'); + this.removeValueBtn.src = varLSdefault.imagePath('remove'); + this.removeValueBtn.addClass('btn'); + this.removeValueBtn.addEvent('click',this.component.onRemoveTextValueBtnClick.bind(this.component,this)); + this.removeValueBtn.injectInside(this.li); + } + }, + + clear: function() { + this.input.value = ''; + }, + + remove: function() { + this.li.destroy(); + } +}); diff --git a/public_html/includes/js/functions.js b/public_html/includes/js/functions.js index 3ba04543..923056cf 100644 --- a/public_html/includes/js/functions.js +++ b/public_html/includes/js/functions.js @@ -244,3 +244,105 @@ function urlAddVar(url,name,value) { } return url; } + +/* + * Generate UUID + */ +function generate_uuid() { + function s4() { + return Math.floor((1 + Math.random()) * 0x10000) + .toString(16) + .substring(1); + } + return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4(); +} + +/* + * Base64 compatibility + * + * Source : http://ntt.cc/2008/01/19/base64-encoder-decoder-with-javascript.html + */ +if ($type(atob) != 'function') { + B64keyStr = "ABCDEFGHIJKLMNOP" + + "QRSTUVWXYZabcdef" + + "ghijklmnopqrstuv" + + "wxyz0123456789+/" + + "="; + + function btoa(input) { + input = escape(input); + var output = ""; + var chr1, chr2, chr3 = ""; + var enc1, enc2, enc3, enc4 = ""; + var i = 0; + + do { + chr1 = input.charCodeAt(i++); + chr2 = input.charCodeAt(i++); + chr3 = input.charCodeAt(i++); + + enc1 = chr1 >> 2; + enc2 = ((chr1 & 3) << 4) | (chr2 >> 4); + enc3 = ((chr2 & 15) << 2) | (chr3 >> 6); + enc4 = chr3 & 63; + + if (isNaN(chr2)) { + enc3 = enc4 = 64; + } else if (isNaN(chr3)) { + enc4 = 64; + } + + output = output + + B64keyStr.charAt(enc1) + + B64keyStr.charAt(enc2) + + B64keyStr.charAt(enc3) + + B64keyStr.charAt(enc4); + chr1 = chr2 = chr3 = ""; + enc1 = enc2 = enc3 = enc4 = ""; + } while (i < input.length); + + return output; + } + + function atob(input) { + var output = ""; + var chr1, chr2, chr3 = ""; + var enc1, enc2, enc3, enc4 = ""; + var i = 0; + + // remove all characters that are not A-Z, a-z, 0-9, +, /, or = + var base64test = /[^A-Za-z0-9\+\/\=]/g; + if (base64test.exec(input)) { + alert("There were invalid base64 characters in the input text.\n" + + "Valid base64 characters are A-Z, a-z, 0-9, '+', '/',and '='\n" + + "Expect errors in decoding."); + } + input = input.replace(/[^A-Za-z0-9\+\/\=]/g, ""); + + do { + enc1 = B64keyStr.indexOf(input.charAt(i++)); + enc2 = B64keyStr.indexOf(input.charAt(i++)); + enc3 = B64keyStr.indexOf(input.charAt(i++)); + enc4 = B64keyStr.indexOf(input.charAt(i++)); + + chr1 = (enc1 << 2) | (enc2 >> 4); + chr2 = ((enc2 & 15) << 4) | (enc3 >> 2); + chr3 = ((enc3 & 3) << 6) | enc4; + + output = output + String.fromCharCode(chr1); + + if (enc3 != 64) { + output = output + String.fromCharCode(chr2); + } + if (enc4 != 64) { + output = output + String.fromCharCode(chr3); + } + + chr1 = chr2 = chr3 = ""; + enc1 = enc2 = enc3 = enc4 = ""; + + } while (i < input.length); + + return unescape(output); + } +} diff --git a/public_html/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.mo b/public_html/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.mo index 50ad200d..f079e6c3 100644 Binary files a/public_html/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.mo and b/public_html/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.mo differ diff --git a/public_html/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.po b/public_html/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.po index 8df41cce..5bfc280b 100644 --- a/public_html/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.po +++ b/public_html/lang/fr_FR.UTF8/LC_MESSAGES/ldapsaisie.po @@ -7,8 +7,8 @@ msgid "" msgstr "" "Project-Id-Version: LdapSaisie\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-02-08 18:12+0100\n" -"PO-Revision-Date: 2018-02-08 18:13+0100\n" +"POT-Creation-Date: 2018-04-26 11:40+0200\n" +"PO-Revision-Date: 2018-04-26 11:44+0200\n" "Last-Translator: Benjamin Renard \n" "Language-Team: LdapSaisie \n" @@ -435,7 +435,7 @@ msgstr "Affichier la clé en entier." msgid "Unknown type" msgstr "Type inconnu" -#: includes/class/class.LSformElement_valueWithUnit.php:190 +#: includes/class/class.LSformElement_valueWithUnit.php:200 msgid "" "LSformElement_valueWithUnit : Units configuration data are missing for the " "attribute %{attr}." @@ -490,12 +490,12 @@ msgstr "LStemplate : Impossible de charger le fichier de support de Smarty 3." msgid "LStemplate : Smarty version not recognized." msgstr "LStemplate : Version de Smarty non reconnue." -#: includes/class/class.LStemplate.php:129 +#: includes/class/class.LStemplate.php:130 msgid "LStemplate : Can't load Smarty." msgstr "" "LStemplate : Impossible de charger le moteur de gestion de template Smarty." -#: includes/class/class.LStemplate.php:302 +#: includes/class/class.LStemplate.php:309 msgid "LStemplate : Template %{file} not found." msgstr "LStemplate : le template %{file} est introuvable." @@ -1609,7 +1609,7 @@ msgstr "Cliquer pour supprimer cette photo." msgid "Chat with this person." msgstr "Discuter avec cette personne." -#: includes/class/class.LSattr_html_select_list.php:282 +#: includes/class/class.LSattr_html_select_list.php:366 msgid "" "LSattr_html_select_list : Configuration data are missing to generate the " "select list of the attribute %{attr}." @@ -1617,6 +1617,38 @@ msgstr "" "LSattr_html_select_list : Des données de configuration sont manquantes pour " "générer la liste de sélection de l'attribut %{attr}." +#: includes/class/class.LSattr_html_select_list.php:369 +msgid "" +"LSattr_html_select_list : Invalid attribute %{attr} reference as " +"OTHER_ATTRIBUTE possible values." +msgstr "" +"LSattr_html_select_list : Référence invalide à l'attribut %{attr} comme " +"valeurs possibles (OTHER_ATTRIBUTE)." + +#: includes/class/class.LSattr_html_select_list.php:372 +msgid "" +"LSattr_html_select_list : Attribute %{attr} referenced as OTHER_ATTRIBUTE " +"possible values is not a jsonCompositeAttribute." +msgstr "" +"LSattr_html_select_list : L'attribute %{attr} référencé comme valeurs " +"possibles (OTHER_ATTRIBUTE) n'est pas du type jsonCompositeAttribute." + +#: includes/class/class.LSattr_html_select_list.php:375 +msgid "" +"LSattr_html_select_list : Fail to decode the following attribute %{attr} " +"value as JSON : %{value}" +msgstr "" +"LSattr_html_select_list : Impossible de décodé la valeur JSON suivante de " +"l'attribut %{attr} : %{value}" + +#: includes/class/class.LSattr_html_select_list.php:378 +msgid "" +"LSattr_html_select_list : No component %{component} found in the following " +"attribute %{attr} JSON value : %{value}" +msgstr "" +"LSattr_html_select_list : Le composant %{component} n'a pas été trouvé dans " +"la valeur JSON de l'attribut %{attr} : %{value}" + #: includes/class/class.LSformRule_inarray.php:56 msgid "" "LSformRule_inarray : Possible values has not been configured to validate " @@ -1625,6 +1657,19 @@ msgstr "" "LSformRule_inarray : Les valeurs possibles n'ont pas été configurées pour " "valider les données." +#: includes/class/class.LSformElement_jsonCompositeAttribute.php:249 +#: includes/class/class.LSformElement_jsonCompositeAttribute.php:262 +msgid "Invalid value \"%{value}\" for component %{component}." +msgstr "Valeur invalide pour le composant %{component} : \"%{value}\"" + +#: includes/class/class.LSformElement_jsonCompositeAttribute.php:267 +msgid "Can't validate value of component %{c}." +msgstr "Impossible de valider la valeur du composant %{c}." + +#: includes/class/class.LSformElement_jsonCompositeAttribute.php:281 +msgid "Component %{c} must be defined" +msgstr "Le composant %{c} est obligatoire." + #: includes/class/class.LSformRule_date.php:59 msgid "LSformRule_date : No date format specify." msgstr "LSformRule_date : Aucun format de date spécifié." diff --git a/public_html/lang/generate_lang_file.php b/public_html/lang/generate_lang_file.php index b2b9922c..b5a1cb65 100755 --- a/public_html/lang/generate_lang_file.php +++ b/public_html/lang/generate_lang_file.php @@ -32,6 +32,8 @@ require_once('conf/config.inc.php'); $withoutselectlist=False; $copyoriginalvalue=False; +$interactive=False; +$output=False; $additionalfileformat=False; $lang=False; $encoding=False; @@ -46,16 +48,19 @@ if ($argc > 1) { $translations[$msg]=$trans; } } - elseif($argv[$i]=='--without-select-list') { + elseif($argv[$i]=='--without-select-list' || $argv[$i]=='-W') { $withoutselectlist=True; } - elseif($argv[$i]=='--copy-original-value') { + elseif($argv[$i]=='--copy-original-value' || $argv[$i]=='-c') { $copyoriginalvalue=True; } - elseif($argv[$i]=='--additional-file-format') { + elseif($argv[$i]=='--interactive' || $argv[$i]=='-i') { + $interactive=True; + } + elseif($argv[$i]=='--additional-file-format' || $argv[$i]=='-a') { $additionalfileformat=True; } - elseif($argv[$i]=='--lang') { + elseif($argv[$i]=='--lang' || $argv[$i]=='-l') { $i++; $parse_lang=explode('.',$argv[$i]); if (count($parse_lang)==2) { @@ -66,12 +71,18 @@ if ($argc > 1) { die("Invalid --lang parameter. Must be compose in format : [lang].[encoding]\n"); } } + elseif($argv[$i]=='--output' || $argv[$i]=='-o') { + $i++; + $output = $argv[$i]; + } elseif($argv[$i]=='-h') { echo "Usage : ".$argv[0]." [file1] [file2] [-h] [options]\n"; - echo " --without-select-list Don't add possibles values of select list\n"; - echo " --copy-original-value Copy original value as translated value when no translated value exists\n"; - echo " --additional-file-format Additional file format output\n"; - echo " --lang Load this specify lang (format : [lang].[encoding])\n"; + echo " -W/--without-select-list Don't add possibles values of select list\n"; + echo " -c/--copy-original-value Copy original value as translated value when no translated value exists\n"; + echo " -i/--interactive Interactive mode : ask user to enter translated on each translation needed\n"; + echo " -a/--additional-file-format Additional file format output\n"; + echo " -l/--lang Load this specify lang (format : [lang].[encoding])\n"; + echo " -o/--output Output file (default : stdout)\n"; exit(0); } } @@ -82,8 +93,36 @@ $data=array(); function add($msg) { if ($msg!='' && _($msg) == "$msg") { - global $data, $translations; - $data[$msg]=$translations[$msg]; + global $data, $translations, $interactive, $copyoriginalvalue; + if (array_key_exists($msg, $data)) { + return True; + } + elseif (array_key_exists($msg, $translations)) { + $data[$msg]=$translations[$msg]; + } + elseif ($interactive) { + if ($copyoriginalvalue) { + fwrite(STDERR, "\"$msg\"\n\n => Please enter translated string (or leave empty to copy original string) : "); + $in = trim(fgets(STDIN)); + if ($in) + $data[$msg]=$in; + else + $data[$msg]=$msg; + } + else { + fwrite(STDERR, "\"$msg\"\n\n => Please enter translated string (or 'c' to copy original message, leave empty to pass) : "); + $in = trim(fgets(STDIN)); + if ($in) { + if ($in=="c") + $data[$msg]=$msg; + else + $data[$msg]=$in; + } + } + } + else { + $data[$msg]=""; + } } } @@ -185,10 +224,22 @@ if (loadDir(LS_OBJECTS_DIR) && loadDir(LS_LOCAL_DIR.LS_OBJECTS_DIR)) { if (is_array($pname['possible_values'])) { foreach($pname['possible_values'] as $pk => $pn) { if ($pk == 'OTHER_OBJECT') continue; - add($pn); + elseif ($pk == 'OTHER_ATTRIBUTE') { + if (is_array($pn) && ! isset($pn['attr'])) { + foreach($pn as $pattr => $plabel) + add($plabel); + } + } + else add($pn); } } } + elseif ($pkey == 'OTHER_ATTRIBUTE') { + if (is_array($pname) && ! isset($pname['attr'])) { + foreach($pname as $pattr => $plabel) + add($plabel); + } + } elseif ($pkey != 'OTHER_OBJECT') { add($pname); } @@ -202,10 +253,18 @@ if (loadDir(LS_OBJECTS_DIR) && loadDir(LS_LOCAL_DIR.LS_OBJECTS_DIR)) { } } + // LSattr_html_labeledValue + if (is_array($attr['html_options']['labels'])) { + foreach($attr['html_options']['labels'] as $klabel => $plabel) { + add($plabel); + } + } + // LSattr_html_jsonCompositeAttribute if (is_array($attr['html_options']['components'])) { foreach($attr['html_options']['components'] as $c => $cconfig) { add($cconfig['label']); + add($cconfig['help_info']); // Component type select_list if (is_array($cconfig['options']['possible_values'])) { @@ -215,10 +274,22 @@ if (loadDir(LS_OBJECTS_DIR) && loadDir(LS_LOCAL_DIR.LS_OBJECTS_DIR)) { if (is_array($pname['possible_values'])) { foreach($pname['possible_values'] as $pk => $pn) { if ($pk == 'OTHER_OBJECT') continue; - add($pn); + elseif ($pk == 'OTHER_ATTRIBUTE') { + if (is_array($pn) && ! isset($pn['attr'])) { + foreach($pn as $pattr => $plabel) + add($plabel); + } + } + else add($pn); } } } + elseif ($pkey == 'OTHER_ATTRIBUTE') { + if (is_array($pname) && ! isset($pname['attr'])) { + foreach($pname as $pattr => $plabel) + add($plabel); + } + } elseif ($pkey != 'OTHER_OBJECT') { add($pname); } @@ -343,9 +414,25 @@ find_and_parse_addon_file(LS_LOCAL_DIR.LS_ADDONS_DIR); ksort($data); -echo "getMessage(), "\n"); + } + if (!$fd) { + fwrite(STDERR, "Use stdout out instead.\n"); + $fd = STDOUT; + $output = false; + } +} +else + $fd = STDOUT; -if (!$additionalfileformat) print "\$GLOBALS['LSlang'] = array (\n"; +fwrite($fd, " $val) { if ($copyoriginalvalue && $val=="") { @@ -354,13 +441,14 @@ foreach($data as $key => $val) { $key=str_replace('"','\\"',$key); $val=str_replace('"','\\"',$val); if ($additionalfileformat) { - print "\$GLOBALS['LSlang'][\"$key\"] = \"$val\";\n"; + fwrite($fd, "\$GLOBALS['LSlang'][\"$key\"] = \"$val\";\n"); } else { - print "\n\"$key\" =>\n \"$val\",\n"; + fwrite($fd, "\n\"$key\" =>\n \"$val\",\n"); } } -if (!$additionalfileformat) echo "\n);\n"; +if (!$additionalfileformat) fwrite($fd, "\n);\n"); -?> +if ($output) + fclose($fd); diff --git a/public_html/lang/ldapsaisie.pot b/public_html/lang/ldapsaisie.pot index 87980c5d..31569c0c 100644 --- a/public_html/lang/ldapsaisie.pot +++ b/public_html/lang/ldapsaisie.pot @@ -8,7 +8,7 @@ msgid "" msgstr "" "Project-Id-Version: PACKAGE VERSION\n" "Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2018-02-08 18:12+0100\n" +"POT-Creation-Date: 2018-04-26 11:39+0200\n" "PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" "Last-Translator: FULL NAME \n" "Language-Team: LANGUAGE \n" @@ -388,7 +388,7 @@ msgstr "" msgid "Unknown type" msgstr "" -#: includes/class/class.LSformElement_valueWithUnit.php:190 +#: includes/class/class.LSformElement_valueWithUnit.php:200 msgid "" "LSformElement_valueWithUnit : Units configuration data are missing for the " "attribute %{attr}." @@ -435,11 +435,11 @@ msgstr "" msgid "LStemplate : Smarty version not recognized." msgstr "" -#: includes/class/class.LStemplate.php:129 +#: includes/class/class.LStemplate.php:130 msgid "LStemplate : Can't load Smarty." msgstr "" -#: includes/class/class.LStemplate.php:302 +#: includes/class/class.LStemplate.php:309 msgid "LStemplate : Template %{file} not found." msgstr "" @@ -1385,18 +1385,55 @@ msgstr "" msgid "Chat with this person." msgstr "" -#: includes/class/class.LSattr_html_select_list.php:282 +#: includes/class/class.LSattr_html_select_list.php:366 msgid "" "LSattr_html_select_list : Configuration data are missing to generate the " "select list of the attribute %{attr}." msgstr "" +#: includes/class/class.LSattr_html_select_list.php:369 +msgid "" +"LSattr_html_select_list : Invalid attribute %{attr} reference as " +"OTHER_ATTRIBUTE possible values." +msgstr "" + +#: includes/class/class.LSattr_html_select_list.php:372 +msgid "" +"LSattr_html_select_list : Attribute %{attr} referenced as OTHER_ATTRIBUTE " +"possible values is not a jsonCompositeAttribute." +msgstr "" + +#: includes/class/class.LSattr_html_select_list.php:375 +msgid "" +"LSattr_html_select_list : Fail to decode the following attribute %{attr} " +"value as JSON : %{value}" +msgstr "" + +#: includes/class/class.LSattr_html_select_list.php:378 +msgid "" +"LSattr_html_select_list : No component %{component} found in the following " +"attribute %{attr} JSON value : %{value}" +msgstr "" + #: includes/class/class.LSformRule_inarray.php:56 msgid "" "LSformRule_inarray : Possible values has not been configured to validate " "data." msgstr "" +#: includes/class/class.LSformElement_jsonCompositeAttribute.php:249 +#: includes/class/class.LSformElement_jsonCompositeAttribute.php:262 +msgid "Invalid value \"%{value}\" for component %{component}." +msgstr "" + +#: includes/class/class.LSformElement_jsonCompositeAttribute.php:267 +msgid "Can't validate value of component %{c}." +msgstr "" + +#: includes/class/class.LSformElement_jsonCompositeAttribute.php:281 +msgid "Component %{c} must be defined" +msgstr "" + #: includes/class/class.LSformRule_date.php:59 msgid "LSformRule_date : No date format specify." msgstr "" diff --git a/public_html/templates/default/LSdefault.tpl b/public_html/templates/default/LSdefault.tpl index 881ee909..44eecf06 100644 --- a/public_html/templates/default/LSdefault.tpl +++ b/public_html/templates/default/LSdefault.tpl @@ -1,6 +1,4 @@ -
-{$LSjsConfig} -
+
{$LSjsConfig}
{$LSinfos}
diff --git a/public_html/templates/default/LSformElement_jsonCompositeAttribute_field.tpl b/public_html/templates/default/LSformElement_jsonCompositeAttribute_field.tpl index 31030e13..8b58d99e 100644 --- a/public_html/templates/default/LSformElement_jsonCompositeAttribute_field.tpl +++ b/public_html/templates/default/LSformElement_jsonCompositeAttribute_field.tpl @@ -2,35 +2,73 @@ {if isset($parseValue)} {foreach $components as $c => $cconf} {if !isset($parseValue[$c])}{continue}{/if} -

+

- {$parseValue[$c].translated} -

+
    + {if $cconf.multiple && is_array($parseValue[$c])} + {foreach from=$parseValue[$c] item=cval} +
  • {$cval.translated}
  • + {/foreach} + {else} +
  • {$parseValue[$c].translated}
  • + {/if} +
+
{/foreach} {else} {$noValueTxt} {/if} {else} - {foreach $components as $c => $cconf} -

- + {uniqid var="uuid"} + + {foreach from=$components key=c item=cconf name=components} +

+ {if $cconf.type=='select_list'} - {foreach from=$cconf.possible_values key=key item=label} {if is_array($label)} {if count($label.possible_values)>0} - {html_options options=$label.possible_values selected=$parseValue[$c].value} + {if $cconf.multiple && is_array($parseValue[$c])} + {html_options options=$label.possible_values selected=$parseValue[$c]} + {else} + {html_options options=$label.possible_values selected=$parseValue[$c].value} + {/if} {/if} {else} - + {assign var="selected" value=0} + {if $cconf.multiple && is_array($parseValue[$c])} + {foreach from=$parseValue[$c] item=cval} + {if $key==$cval.value}{assign var="selected" value=1}{/if} + {/foreach} + {else} + {if $key == $parseValue[$c].value} + {assign var="selected" value=1} + {/if} + {/if} + {/if} {/foreach} {else} - +
    + {if $cconf.multiple && is_array($parseValue[$c])} + {foreach from=$parseValue[$c] item=cval} +
  • + {foreachelse} +
  • + {/foreach} + {else} +
  • + {/if} +
{/if} -

+
{/foreach} {/if} diff --git a/public_html/templates/default/LSformElement_labeledValue.tpl b/public_html/templates/default/LSformElement_labeledValue.tpl new file mode 100644 index 00000000..40a75c60 --- /dev/null +++ b/public_html/templates/default/LSformElement_labeledValue.tpl @@ -0,0 +1,7 @@ +
    + {foreach from=$parseValues item=parseValue} +
  • {include file="ls:$fieldTemplate"}
  • + {foreachelse} +
  • {include file="ls:$fieldTemplate"}
  • + {/foreach} +
diff --git a/public_html/templates/default/LSformElement_labeledValue_field.tpl b/public_html/templates/default/LSformElement_labeledValue_field.tpl new file mode 100644 index 00000000..e920c708 --- /dev/null +++ b/public_html/templates/default/LSformElement_labeledValue_field.tpl @@ -0,0 +1,21 @@ +{if $freeze} + {if isset($parseValue)} + {if $parseValue.label} + {if $parseValue.translated_label} + {$parseValue.translated_label} + {else} + {$parseValue.label} {$unrecognizedLabelTxt} + {/if} + : {$parseValue.value} + {else} + {$parseValue.raw_value} {$unrecognizedValueTxt} + {/if} + {else} + {$noValueTxt} + {/if} +{else} + + +{/if} diff --git a/public_html/tmp/.gitignore b/public_html/tmp/.gitignore index f605d295..b00e673f 100644 --- a/public_html/tmp/.gitignore +++ b/public_html/tmp/.gitignore @@ -1,3 +1,3 @@ -*.tpl.php +*.php *.tmp *.log