mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-22 18:09:06 +01:00
LSformElement :: select_object : Add sort feature (with sort and sortDirection parameters)
This commit is contained in:
parent
f24f574430
commit
04f2518d35
2 changed files with 45 additions and 7 deletions
|
@ -12,7 +12,9 @@
|
||||||
'object_type' => '[Type d'LSobject selectionnable]',
|
'object_type' => '[Type d'LSobject selectionnable]',
|
||||||
'display_name_format' => '[LSformat du nom d'affichage des LSobjects]',
|
'display_name_format' => '[LSformat du nom d'affichage des LSobjects]',
|
||||||
'value_attribute' => '[Nom de l'attribut clé des LSobjects]'
|
'value_attribute' => '[Nom de l'attribut clé des LSobjects]'
|
||||||
)
|
),
|
||||||
|
'sort' => [Booléen],
|
||||||
|
'sortDirection' => '[ASC|DESC]'
|
||||||
),]]>
|
),]]>
|
||||||
...
|
...
|
||||||
</programlisting>
|
</programlisting>
|
||||||
|
@ -35,18 +37,14 @@
|
||||||
<simpara>Nom du type d'&LSobject; en référence.</simpara>
|
<simpara>Nom du type d'&LSobject; en référence.</simpara>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
|
||||||
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>display_name_format</term>
|
<term>display_name_format</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
<simpara>&LSformat; du nom d'affichage des objets lors de leur sélection.</simpara>
|
<simpara>&LSformat; du nom d'affichage des objets lors de leur sélection.</simpara>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
|
||||||
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>value_attribute</term>
|
<term>value_attribute</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -55,9 +53,7 @@
|
||||||
<emphasis>uid</emphasis>).</simpara>
|
<emphasis>uid</emphasis>).</simpara>
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
</variablelist>
|
|
||||||
|
|
||||||
<variablelist>
|
|
||||||
<varlistentry>
|
<varlistentry>
|
||||||
<term>filter</term>
|
<term>filter</term>
|
||||||
<listitem>
|
<listitem>
|
||||||
|
@ -70,6 +66,23 @@
|
||||||
</listitem>
|
</listitem>
|
||||||
</varlistentry>
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>sort</term>
|
||||||
|
<listitem>
|
||||||
|
<simpara>Booléen définissant si la liste des objets choisis doit être
|
||||||
|
triée ou non (Vrai par défaut). Le trie est effectué sur les libellés
|
||||||
|
des objets choisis.</simpara>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
|
<varlistentry>
|
||||||
|
<term>sortDirection</term>
|
||||||
|
<listitem>
|
||||||
|
<simpara>Mot clé déterminant le sens du trie des objets choisis.</simpara>
|
||||||
|
<simpara>Valeurs possibles : <literal>ASC</literal> ou <literal>DESC</literal> (<literal>ASC</literal> par défaut).</simpara>
|
||||||
|
</listitem>
|
||||||
|
</varlistentry>
|
||||||
|
|
||||||
</variablelist>
|
</variablelist>
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -89,6 +89,11 @@ class LSformElement_select_object extends LSformElement {
|
||||||
LSselect :: loadDependenciesDisplay();
|
LSselect :: loadDependenciesDisplay();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!isset($this -> params['html_options']['sort']) || $this -> params['html_options']['sort']) {
|
||||||
|
uasort($this -> values,array($this,'_sortTwoValues'));
|
||||||
|
}
|
||||||
|
|
||||||
$return['html'] = $this -> fetchTemplate(NULL,array(
|
$return['html'] = $this -> fetchTemplate(NULL,array(
|
||||||
'selectableObject' => $this -> selectableObject,
|
'selectableObject' => $this -> selectableObject,
|
||||||
'unrecognizedValues' => $this -> attr_html -> unrecognizedValues,
|
'unrecognizedValues' => $this -> attr_html -> unrecognizedValues,
|
||||||
|
@ -97,6 +102,26 @@ class LSformElement_select_object extends LSformElement {
|
||||||
return $return;
|
return $return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Function use with uasort to sort two values
|
||||||
|
*
|
||||||
|
* @param[in] $va string One value
|
||||||
|
* @param[in] $vb string One value
|
||||||
|
*
|
||||||
|
* @retval int Value for uasort
|
||||||
|
**/
|
||||||
|
private function _sortTwoValues(&$va,&$vb) {
|
||||||
|
if (isset($this -> params['html_options']['sortDirection']) && $this -> params['html_options']['sortDirection']=='DESC') {
|
||||||
|
$dir=-1;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
$dir=1;
|
||||||
|
}
|
||||||
|
if ($va == $vb) return 0;
|
||||||
|
$val = strcoll(strtolower($va), strtolower($vb));
|
||||||
|
return $val*$dir;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Return the values of the object form the session variable
|
* Return the values of the object form the session variable
|
||||||
*/
|
*/
|
||||||
|
|
Loading…
Reference in a new issue