Compare commits

..

6 commits

Author SHA1 Message Date
Benjamin Renard
c98e31b7c6
LSsearch: fix/improve handling session data
- avoid PHP warning about unset key
- make purge methods accepting more specific object type/context
- store cache in dedicated sub-array to avoid purging params when 
purging cache
- fix strange problem about not preserved params due to too large purges 
in some contexts
2023-05-24 20:13:02 +02:00
Benjamin Renard
cc9942019f
light-blue.css: Fix LSobject-list links color on line hover 2023-05-24 19:07:01 +02:00
Benjamin Renard
513ed9a024
Fix default ASC & DESC images color to fit with clear themes 2023-05-24 19:05:46 +02:00
Benjamin Renard
6ca8427d5d
CI: add a test job for doc 2023-05-24 18:30:41 +02:00
Benjamin Renard
548315b248
CI: fix PHP tests jobs rules 2023-05-24 18:30:02 +02:00
Benjamin Renard
4003fdfcfc
globalSearch: defaulty display extraDisplayedColumns
The new globalSearch_extraDisplayedColumns parameter permit to control 
it for each LSobject types.
2023-05-24 18:18:23 +02:00
10 changed files with 284 additions and 21 deletions

View file

@ -9,7 +9,7 @@ tests:bullseye:
stage: tests stage: tests
rules: rules:
- changes: - changes:
- src/* - src/**/*.php
script: script:
- rm -fr vendor - rm -fr vendor
- composer install - composer install
@ -35,7 +35,7 @@ tests:buster:
stage: tests stage: tests
rules: rules:
- changes: - changes:
- src/* - src/**/*.php
script: script:
- rm -fr vendor - rm -fr vendor
- composer install - composer install
@ -76,10 +76,22 @@ tests:jessie:
stage: tests stage: tests
rules: rules:
- changes: - changes:
- src/* - src/**/*.php
script: script:
- cd /tmp/ - cd /tmp/
- composer require overtrue/phplint --dev - composer require overtrue/phplint --dev
- cd - - cd -
- rm -f .phplint-cache - rm -f .phplint-cache
- /tmp/vendor/bin/phplint src - /tmp/vendor/bin/phplint src
tests:doc:
image: registry.gitlab.com/pipeline-components/xmllint:latest
stage: tests
rules:
- changes:
- doc/*.docbook
- doc/*.xml
- doc/**/*.docbook
- doc/**/*.xml
script:
- xmllint --valid --noout doc/LdapSaisie.docbook

View file

@ -69,6 +69,7 @@
), // fin LSsearch ), // fin LSsearch
'globalSearch' => [booleen], 'globalSearch' => [booleen],
'globalSearch_extraDisplayedColumns' => [booleen],
// ioFormat // ioFormat
'ioFormat' => array ( 'ioFormat' => array (
@ -274,6 +275,16 @@
</listitem> </listitem>
</varlistentry> </varlistentry>
<varlistentry>
<term>globalSearch_extraDisplayedColumns</term>
<listitem>
<simpara>Afficher ou non les colonnes supplémentaires pour ce type d'objet dans le résultat des
recherches globales (Par défaut : <literal>True</literal>). Pour plus de détails les colonnes
supplémentaires, <link linkend="config-LSobject-LSsearch">voir la section dédiée</link>.
</simpara>
</listitem>
</varlistentry>
<varlistentry> <varlistentry>
<term>ioFormat</term> <term>ioFormat</term>
<listitem> <listitem>

View file

@ -356,7 +356,7 @@ body, input, select, textarea, #status, th.LSobject-list, table.LStable th, th.L
} }
/* ---- Contrasted grey ---- */ /* ---- Contrasted grey ---- */
tr.LSobject-list:hover, tr.LSobject-list:hover th, table.LStable tr:hover, table.LStable tr:hover th, tr.LSobject-list:hover a.LSobject-list, table.LStable tbody tr:hover a, .LSform input[type=submit], input[type='submit'].LSview_search, button, li.LSform_layout_current { tr.LSobject-list:hover, tr.LSobject-list:hover th, table.LStable tr:hover, table.LStable tr:hover th, tr.LSobject-list:hover a.LSobject-list, table.LStable tbody tr:hover a, .LSform input[type=submit], input[type='submit'].LSview_search, button, li.LSform_layout_current, tr.LSobject-list:hover a {
color: var(--contrasted-text-color); color: var(--contrasted-text-color);
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 224 B

View file

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="9"
height="16"
viewBox="0 0 2.3812499 4.2333335"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="ASC.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="44.8"
inkscape:cx="4.7483255"
inkscape:cy="6.8589809"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
units="px"
inkscape:window-width="1920"
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1">
<path
sodipodi:type="star"
style="fill:#aaaaaa;fill-opacity:1;stroke:none;stroke-width:0.939523;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path833"
sodipodi:sides="3"
sodipodi:cx="1.068243"
sodipodi:cy="1.2323078"
sodipodi:r1="0.29255828"
sodipodi:r2="0.14627914"
sodipodi:arg1="-1.5691195"
sodipodi:arg2="-0.52192198"
inkscape:flatsided="false"
inkscape:rounded="0"
inkscape:randomized="0"
d="M 1.0687336,0.93974992 1.1950469,1.1593807 1.3213603,1.3790116 1.0679977,1.3785867 0.81463519,1.3781619 0.94168439,1.1589559 Z"
inkscape:transform-center-x="0.0011530484"
inkscape:transform-center-y="-0.30748628"
transform="matrix(4.6992936,0,0,4.2163556,-3.82821,-2.7716948)" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 267 B

View file

@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<svg
xmlns:dc="http://purl.org/dc/elements/1.1/"
xmlns:cc="http://creativecommons.org/ns#"
xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd"
xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape"
width="9"
height="16"
viewBox="0 0 2.3812499 4.2333335"
version="1.1"
id="svg8"
inkscape:version="1.0.2 (e86c870879, 2021-01-15)"
sodipodi:docname="DESC.svg">
<defs
id="defs2" />
<sodipodi:namedview
id="base"
pagecolor="#ffffff"
bordercolor="#666666"
borderopacity="1.0"
inkscape:pageopacity="0.0"
inkscape:pageshadow="2"
inkscape:zoom="44.8"
inkscape:cx="4.7483255"
inkscape:cy="6.8589809"
inkscape:document-units="mm"
inkscape:current-layer="layer1"
inkscape:document-rotation="0"
showgrid="false"
units="px"
inkscape:window-width="1920"
inkscape:window-height="1016"
inkscape:window-x="0"
inkscape:window-y="0"
inkscape:window-maximized="1" />
<metadata
id="metadata5">
<rdf:RDF>
<cc:Work
rdf:about="">
<dc:format>image/svg+xml</dc:format>
<dc:type
rdf:resource="http://purl.org/dc/dcmitype/StillImage" />
<dc:title></dc:title>
</cc:Work>
</rdf:RDF>
</metadata>
<g
inkscape:label="Calque 1"
inkscape:groupmode="layer"
id="layer1">
<path
sodipodi:type="star"
style="fill:#aaaaaa;fill-opacity:1;stroke:none;stroke-width:0.939523;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
id="path833"
sodipodi:sides="3"
sodipodi:cx="1.068243"
sodipodi:cy="1.2323078"
sodipodi:r1="0.29255828"
sodipodi:r2="0.14627914"
sodipodi:arg1="-1.5691195"
sodipodi:arg2="-0.52192198"
inkscape:flatsided="false"
inkscape:rounded="0"
inkscape:randomized="0"
d="M 1.0687336,0.93974992 1.1950469,1.1593807 1.3213603,1.3790116 1.0679977,1.3785867 0.81463519,1.3781619 0.94168439,1.1589559 Z"
inkscape:transform-center-x="0.0011530484"
inkscape:transform-center-y="0.30748629"
transform="matrix(4.6992936,0,0,-4.2163556,-3.82821,7.0050282)" />
</g>
</svg>

After

Width:  |  Height:  |  Size: 2.3 KiB

View file

@ -156,7 +156,7 @@ class LSsearch extends LSlog_staticLoggerClass {
} }
} }
else { else {
$this -> purgeParams($LSobject); $this -> purgeParams($LSobject, $context);
$this -> loadDefaultParameters(); $this -> loadDefaultParameters();
} }
@ -214,7 +214,14 @@ class LSsearch extends LSlog_staticLoggerClass {
* @return boolean True if params has been loaded from session or False * @return boolean True if params has been loaded from session or False
*/ */
private function loadParamsFromSession() { private function loadParamsFromSession() {
if (isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'][$this -> context]) && is_array($_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'][$this -> context])) { if (
isset($_SESSION['LSsession'])
&& isset($_SESSION['LSsession']['LSsearch'])
&& isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject])
&& isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'])
&& isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'][$this -> context])
&& is_array($_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'][$this -> context])
) {
self :: log_debug('Load params from session for context '.$this -> context); self :: log_debug('Load params from session for context '.$this -> context);
$params = $_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'][$this -> context]; $params = $_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'][$this -> context];
@ -236,15 +243,28 @@ class LSsearch extends LSlog_staticLoggerClass {
* @return void * @return void
*/ */
private function saveParamsInSession() { private function saveParamsInSession() {
self :: log_debug('Save context params session '.$this -> context); self :: log_debug(
'saveParamsInSession(".$this -> LSobject."): Save context params session '.$this -> context);
$params = $this -> params; $params = $this -> params;
if ($params['filter'] instanceof Net_LDAP2_Filter) { if ($params['filter'] instanceof Net_LDAP2_Filter) {
$params['filter'] = $params['filter'] -> asString(); $params['filter'] = $params['filter'] -> asString();
} }
if (!isset($_SESSION['LSsession']))
$_SESSION['LSsession'] = array();
if (!isset($_SESSION['LSsession']['LSsearch']))
$_SESSION['LSsession']['LSsearch'] = array();
if (!isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject]))
$_SESSION['LSsession']['LSsearch'][$this -> LSobject] = array();
if (!isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params']))
$_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'] = array();
if (!isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'][$this -> context]))
$_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'][$this -> context] = array();
foreach ($params as $param => $value) { foreach ($params as $param => $value) {
if ( !isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'][$this -> context][$param]) || $_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'][$this -> context][$param]!=$value) { if (
self :: log_trace("$param => ".varDump($value)); !isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'][$this -> context][$param])
|| $_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'][$this -> context][$param] != $value
) {
self :: log_trace("saveParamsInSession(".$this -> LSobject."): $param => ".varDump($value));
$_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'][$this -> context][$param]=$value; $_SESSION['LSsession']['LSsearch'][$this -> LSobject]['params'][$this -> context][$param]=$value;
} }
} }
@ -253,29 +273,60 @@ class LSsearch extends LSlog_staticLoggerClass {
/** /**
* Purge parameters in session * Purge parameters in session
* *
* @param string $LSobject The LSobject type * @param string $LSobject The LdapObject type
* @param string|null $context The context of the search (optional, default: null)
* *
* @return void * @return void
*/ */
public static function purgeParams($LSobject) { public static function purgeParams($LSobject, $context=null) {
if (!isset($_SESSION['LSsession'])) return;
if (!isset($_SESSION['LSsession']['LSsearch'])) return;
if (!isset($_SESSION['LSsession']['LSsearch'][$LSobject])) return;
if (!isset($_SESSION['LSsession']['LSsearch'][$LSobject]['params'])) return;
if ($context) {
if (isset($_SESSION['LSsession']['LSsearch'][$LSobject]['params'][$context]))
unset($_SESSION['LSsession']['LSsearch'][$LSobject]['params'][$context]);
}
else
unset($_SESSION['LSsession']['LSsearch'][$LSobject]['params']); unset($_SESSION['LSsession']['LSsearch'][$LSobject]['params']);
} }
/** /**
* Purge cache * Purge cache
* *
* @param string $LSobject The LdapObject type
* @param string|null $hash The hash of the search (optional, default: null)
*
* @return void * @return void
*/ */
public static function purgeCache($LSobject) { public static function purgeCache($LSobject, $hash=null) {
unset($_SESSION['LSsession']['LSsearch'][$LSobject]); if (!isset($_SESSION['LSsession'])) return;
if (!isset($_SESSION['LSsession']['LSsearch'])) return;
if (!isset($_SESSION['LSsession']['LSsearch'][$LSobject])) return;
if (!isset($_SESSION['LSsession']['LSsearch'][$LSobject]['cache'])) return;
if ($hash) {
if (isset($_SESSION['LSsession']['LSsearch'][$LSobject]['cache'][$hash]))
unset($_SESSION['LSsession']['LSsearch'][$LSobject]['cache'][$hash]);
}
else
unset($_SESSION['LSsession']['LSsearch'][$LSobject]['cache']);
} }
/** /**
* Purge session * Purge session
* *
* @param string $LSobject The LdapObject type
*
* @return void * @return void
*/ */
private function purgeSession() { private function purgeSession($LSobject=null) {
if (!isset($_SESSION['LSsession'])) return;
if (!isset($_SESSION['LSsession']['LSsearch'])) return;
if ($LSobject) {
if (isset($_SESSION['LSsession']['LSsearch'][$LSobject]))
unset($_SESSION['LSsession']['LSsearch'][$LSobject]);
}
else
unset($_SESSION['LSsession']['LSsearch']); unset($_SESSION['LSsession']['LSsearch']);
} }
@ -1121,7 +1172,15 @@ class LSsearch extends LSlog_staticLoggerClass {
if ($this -> cacheIsEnabled()) { if ($this -> cacheIsEnabled()) {
$hash = $this->getHash(); $hash = $this->getHash();
self :: log_trace("addResultToCache(): Save result in cache with hash '$hash'."); self :: log_trace("addResultToCache(): Save result in cache with hash '$hash'.");
$_SESSION['LSsession']['LSsearch'][$this -> LSobject][$hash]=$this->result; if (!isset($_SESSION['LSsession']))
$_SESSION['LSsession'] = array();
if (!isset($_SESSION['LSsession']['LSsearch']))
$_SESSION['LSsession']['LSsearch'] = array();
if (!isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject]))
$_SESSION['LSsession']['LSsearch'][$this -> LSobject] = array();
if (!isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject]['cache']))
$_SESSION['LSsession']['LSsearch'][$this -> LSobject]['cache'] = array();
$_SESSION['LSsession']['LSsearch'][$this -> LSobject]['cache'][$hash] = $this->result;
} }
else else
self :: log_trace('addResultToCache(): cache is disabled.'); self :: log_trace('addResultToCache(): cache is disabled.');
@ -1134,10 +1193,16 @@ class LSsearch extends LSlog_staticLoggerClass {
**/ **/
private function getResultFromCache() { private function getResultFromCache() {
if ($this -> cacheIsEnabled()) { if ($this -> cacheIsEnabled()) {
$hash=$this->getHash(); $hash = $this->getHash();
if (isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject][$hash])) { if (
isset($_SESSION['LSsession'])
&& isset($_SESSION['LSsession']['LSsearch'])
&& isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject])
&& isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject]['cache'])
&& isset($_SESSION['LSsession']['LSsearch'][$this -> LSobject]['cache'][$hash])
) {
self :: log_trace('getResultFromCache(): result found in cache.'); self :: log_trace('getResultFromCache(): result found in cache.');
return $_SESSION['LSsession']['LSsearch'][$this -> LSobject][$hash]; return $_SESSION['LSsession']['LSsearch'][$this -> LSobject]['cache'][$hash];
} }
self :: log_trace('getResultFromCache(): result not found in cache.'); self :: log_trace('getResultFromCache(): result not found in cache.');
} }

View file

@ -177,6 +177,10 @@ function handle_global_search($request) {
LStemplate :: assign('pagetitle', $object -> getLabel()); LStemplate :: assign('pagetitle', $object -> getLabel());
$LSsearch = new LSsearch($LSobject, 'LSview'); $LSsearch = new LSsearch($LSobject, 'LSview');
$LSsearch -> setParam(
'extraDisplayedColumns',
LSconfig::get("LSobjects.$LSobject.globalSearch_extraDisplayedColumns", true, 'bool')
);
$LSsearch -> setParamsFromRequest(); $LSsearch -> setParamsFromRequest();
$LSsearch -> run(); $LSsearch -> run();

View file

@ -34,12 +34,35 @@
{/if} {/if}
</th> </th>
{/if} {/if}
{if $LSsearch->extraDisplayedColumns}
{foreach from=$LSsearch->visibleExtraDisplayedColumns item=conf key=cid}
<th class='LSobject-list'{if isset($conf.cssStyle) && $conf.cssStyle} style='{$conf.cssStyle|escape:"htmlall"}'{/if}>
{if $LSsearch->sort}
<a href='object/{$LSsearch->LSobject|escape:"url"}?sortBy={$cid|escape:"url"}&amp;nocache={$smarty.now}'>
{if $LSsearch->sortBy == $cid}
<strong>{tr msg=$conf.label|escape:"htmlall"}</strong>
<img src='{img name=$LSsearch->sortDirection}' class='LSobject-list-ordersense' alt='{$LSsearch->sortDirection}'/>
{else}
{tr msg=$conf.label}
{/if}
</a>
{else}
{tr msg=$conf.label}
{/if}
</th>
{/foreach}
{/if}
<th class='LSobject-list'>{$LSsearch->label_actions}</th> <th class='LSobject-list'>{$LSsearch->label_actions}</th>
</tr> </tr>
{foreach from=$page.list item=object} {foreach from=$page.list item=object}
<tr class='{cycle values="LSobject-list,LSobject-list LSobject-list-bis"}'> <tr class='{cycle values="LSobject-list,LSobject-list LSobject-list-bis"}'>
<td class='LSobject-list LSobject-list-names'><a href='object/{$LSsearch->LSobject|escape:'url'}/{$object->dn|escape:'url'}' class='LSobject-list'>{$object->displayName|escape:'htmlall'}</a> </td> <td class='LSobject-list LSobject-list-names'><a href='object/{$LSsearch->LSobject|escape:'url'}/{$object->dn|escape:'url'}' class='LSobject-list'>{$object->displayName|escape:'htmlall'}</a> </td>
{if $LSsearch->displaySubDn}<td class='LSobject-list'>{$object->subDn|escape:'htmlall'}</td>{/if} {if $LSsearch->displaySubDn}<td class='LSobject-list'>{$object->subDn|escape:'htmlall'}</td>{/if}
{if $LSsearch->extraDisplayedColumns}
{foreach from=$LSsearch->visibleExtraDisplayedColumns item=conf key=cid}
<td class='LSobject-list'{if isset($conf.cssStyle) && $conf.cssStyle} style='{$conf.cssStyle|escape:"htmlall"}'{/if}>{if !isset($conf.escape) || $conf.escape}{$object->$cid|escape:"htmlall"}{else}{$object->$cid}{/if}</td>
{/foreach}
{/if}
<td class='LSobject-list LSobject-list-actions'> <td class='LSobject-list LSobject-list-actions'>
{foreach from=$object->actions item=item} {foreach from=$object->actions item=item}
<a href='{$item.url|escape:'quotes'}' class='LSobject-list-actions'><img src='{img name=$item.action|escape:'url'}' alt='{$item.label|escape:'quotes'}' title='{$item.label|escape:'quotes'}'/></a> <a href='{$item.url|escape:'quotes'}' class='LSobject-list-actions'><img src='{img name=$item.action|escape:'url'}' alt='{$item.label|escape:'quotes'}' title='{$item.label|escape:'quotes'}'/></a>