mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 18:09:06 +01:00
LSattr_html :: select_list : add possiblity to use values of other attribute as possible values
This commit is contained in:
parent
64071f55e6
commit
d06593cf14
6 changed files with 202 additions and 5 deletions
|
@ -20,4 +20,5 @@
|
||||||
<!ENTITY conf-LSattr_html_valueWithUnit SYSTEM "LSattr_html_valueWithUnit.docbook">
|
<!ENTITY conf-LSattr_html_valueWithUnit SYSTEM "LSattr_html_valueWithUnit.docbook">
|
||||||
<!ENTITY conf-LSattr_html_xmpp SYSTEM "LSattr_html_xmpp.docbook">
|
<!ENTITY conf-LSattr_html_xmpp SYSTEM "LSattr_html_xmpp.docbook">
|
||||||
|
|
||||||
|
<!ENTITY LSattr_html_jsonCompositeAttribute "<link linkend='config-LSattr_html_jsonCompositeAttribute'>LSattr_html_jsonCompositeAttribute</link>">
|
||||||
<!ENTITY LSattr_html_select_list "<link linkend='config-LSattr_html_select_list'>LSattr_html_select_list</link>">
|
<!ENTITY LSattr_html_select_list "<link linkend='config-LSattr_html_select_list'>LSattr_html_select_list</link>">
|
||||||
|
|
|
@ -22,6 +22,19 @@
|
||||||
'basedn' => '[Basedn de la recherche]',
|
'basedn' => '[Basedn de la recherche]',
|
||||||
'onlyAccessible' => '[Booléen]'
|
'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 (
|
array (
|
||||||
'label' => '[LSformat du nom du groupe de valeurs]',
|
'label' => '[LSformat du nom du groupe de valeurs]',
|
||||||
'possible_values' => array (
|
'possible_values' => array (
|
||||||
|
@ -128,6 +141,37 @@
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
|
<para>Si la valeur clé est égale à <literal>OTHER_ATTRIBTE</literal>, 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 :
|
||||||
|
|
||||||
|
<itemizedlist>
|
||||||
|
<listitem>
|
||||||
|
<simpara>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).</simpara>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<simpara>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).</simpara>
|
||||||
|
</listitem>
|
||||||
|
|
||||||
|
<listitem>
|
||||||
|
<simpara>soit un tableau associatif référençant un attribut sous la clé <emphasis>attr
|
||||||
|
</emphasis> 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é <emphasis>
|
||||||
|
json_component_key</emphasis>. Il est également possible de référencer un autre composant
|
||||||
|
à l'aide de la clé <emphasis>json_component_label</emphasis> 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.</simpara>
|
||||||
|
</listitem>
|
||||||
|
</itemizedlist>
|
||||||
|
|
||||||
|
</para>
|
||||||
|
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,10 @@ class LSattr_html_select_list extends LSattr_html{
|
||||||
$objInfos=self :: getLSobjectPossibleValues($val_label,$options,$name);
|
$objInfos=self :: getLSobjectPossibleValues($val_label,$options,$name);
|
||||||
$retInfos=self :: _array_merge($retInfos,$objInfos);
|
$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)) {
|
elseif (is_array($val_label)) {
|
||||||
if (!isset($val_label['possible_values']) || !is_array($val_label['possible_values']) || !isset($val_label['label']))
|
if (!isset($val_label['possible_values']) || !is_array($val_label['possible_values']) || !isset($val_label['label']))
|
||||||
continue;
|
continue;
|
||||||
|
@ -273,6 +277,86 @@ class LSattr_html_select_list extends LSattr_html{
|
||||||
|
|
||||||
return $retInfos;
|
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 <brenard@easter-eggs.com>
|
||||||
|
*
|
||||||
|
* @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 (!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 (!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 +365,15 @@ class LSattr_html_select_list extends LSattr_html{
|
||||||
LSerror :: defineError('LSattr_html_select_list_01',
|
LSerror :: defineError('LSattr_html_select_list_01',
|
||||||
_("LSattr_html_select_list : Configuration data are missing to generate the select list of the attribute %{attr}.")
|
_("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}")
|
||||||
|
);
|
||||||
|
|
Binary file not shown.
|
@ -7,8 +7,8 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: LdapSaisie\n"
|
"Project-Id-Version: LdapSaisie\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2018-04-26 11:34+0200\n"
|
"POT-Creation-Date: 2018-04-26 11:40+0200\n"
|
||||||
"PO-Revision-Date: 2018-04-26 11:35+0200\n"
|
"PO-Revision-Date: 2018-04-26 11:44+0200\n"
|
||||||
"Last-Translator: Benjamin Renard <brenard@zionetrix.net>\n"
|
"Last-Translator: Benjamin Renard <brenard@zionetrix.net>\n"
|
||||||
"Language-Team: LdapSaisie <ldapsaisie-users@lists.labs.libre-entreprise."
|
"Language-Team: LdapSaisie <ldapsaisie-users@lists.labs.libre-entreprise."
|
||||||
"org>\n"
|
"org>\n"
|
||||||
|
@ -1609,7 +1609,7 @@ msgstr "Cliquer pour supprimer cette photo."
|
||||||
msgid "Chat with this person."
|
msgid "Chat with this person."
|
||||||
msgstr "Discuter avec cette personne."
|
msgstr "Discuter avec cette personne."
|
||||||
|
|
||||||
#: includes/class/class.LSattr_html_select_list.php:282
|
#: includes/class/class.LSattr_html_select_list.php:366
|
||||||
msgid ""
|
msgid ""
|
||||||
"LSattr_html_select_list : Configuration data are missing to generate the "
|
"LSattr_html_select_list : Configuration data are missing to generate the "
|
||||||
"select list of the attribute %{attr}."
|
"select list of the attribute %{attr}."
|
||||||
|
@ -1617,6 +1617,38 @@ msgstr ""
|
||||||
"LSattr_html_select_list : Des données de configuration sont manquantes pour "
|
"LSattr_html_select_list : Des données de configuration sont manquantes pour "
|
||||||
"générer la liste de sélection de l'attribut %{attr}."
|
"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
|
#: includes/class/class.LSformRule_inarray.php:56
|
||||||
msgid ""
|
msgid ""
|
||||||
"LSformRule_inarray : Possible values has not been configured to validate "
|
"LSformRule_inarray : Possible values has not been configured to validate "
|
||||||
|
|
|
@ -8,7 +8,7 @@ msgid ""
|
||||||
msgstr ""
|
msgstr ""
|
||||||
"Project-Id-Version: PACKAGE VERSION\n"
|
"Project-Id-Version: PACKAGE VERSION\n"
|
||||||
"Report-Msgid-Bugs-To: \n"
|
"Report-Msgid-Bugs-To: \n"
|
||||||
"POT-Creation-Date: 2018-04-26 11:33+0200\n"
|
"POT-Creation-Date: 2018-04-26 11:39+0200\n"
|
||||||
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n"
|
||||||
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n"
|
||||||
"Language-Team: LANGUAGE <LL@li.org>\n"
|
"Language-Team: LANGUAGE <LL@li.org>\n"
|
||||||
|
@ -1385,12 +1385,36 @@ msgstr ""
|
||||||
msgid "Chat with this person."
|
msgid "Chat with this person."
|
||||||
msgstr ""
|
msgstr ""
|
||||||
|
|
||||||
#: includes/class/class.LSattr_html_select_list.php:282
|
#: includes/class/class.LSattr_html_select_list.php:366
|
||||||
msgid ""
|
msgid ""
|
||||||
"LSattr_html_select_list : Configuration data are missing to generate the "
|
"LSattr_html_select_list : Configuration data are missing to generate the "
|
||||||
"select list of the attribute %{attr}."
|
"select list of the attribute %{attr}."
|
||||||
msgstr ""
|
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
|
#: includes/class/class.LSformRule_inarray.php:56
|
||||||
msgid ""
|
msgid ""
|
||||||
"LSformRule_inarray : Possible values has not been configured to validate "
|
"LSformRule_inarray : Possible values has not been configured to validate "
|
||||||
|
|
Loading…
Reference in a new issue