mirror of
https://gitlab.easter-eggs.com/ee/ldapsaisie.git
synced 2024-11-29 21:24:51 +01:00
LScli :: show : handle form layout (if defined)
This commit is contained in:
parent
448d977f14
commit
fa3742c609
1 changed files with 43 additions and 17 deletions
|
@ -1922,18 +1922,45 @@ class LSldapObject {
|
||||||
/**
|
/**
|
||||||
* CLI helper to show the object info
|
* CLI helper to show the object info
|
||||||
*
|
*
|
||||||
* @param[in] $raw-values bool Show attributes raw values (instead of display ones)
|
* @param[in] $raw_values bool Show attributes raw values (instead of display ones)
|
||||||
*
|
*
|
||||||
* @retval void
|
* @retval void
|
||||||
**/
|
**/
|
||||||
public function _cli_show($raw_values) {
|
public function _cli_show($raw_values=false) {
|
||||||
echo $this -> type_name." (".($this -> dn?$this -> dn:'new').") :\n";
|
echo $this -> type_name." (".($this -> dn?$this -> dn:'new').") :\n";
|
||||||
|
if (is_array($this -> getConfig('LSform.layout'))) {
|
||||||
|
foreach($this -> getConfig('LSform.layout') as $tab_name => $tab) {
|
||||||
|
echo " - ".(isset($tab['label'])?$tab['label']:$tab_name)." :\n";
|
||||||
|
foreach ($tab['args'] as $attr_name) {
|
||||||
|
$this -> _cli_show_attr($attr_name, $raw_values, " ");
|
||||||
|
}
|
||||||
|
echo "\n";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else {
|
||||||
foreach ($this -> attrs as $attr_name => $attr) {
|
foreach ($this -> attrs as $attr_name => $attr) {
|
||||||
echo " - $attr_name :";
|
$this -> _cli_show_attr($attr_name, $raw_values);
|
||||||
$values = ($raw_values?$attr->getValue():$attr->getDisplayValue());
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* CLI helper to show the attribute
|
||||||
|
*
|
||||||
|
* @param[in] $attr_name string The attribute name
|
||||||
|
* @param[in] $raw_values bool Show attributes raw values (instead of display ones)
|
||||||
|
* @param[in] $prefix string Prefix for each line displayed (optional, default: no prefix)
|
||||||
|
*
|
||||||
|
* @retval void
|
||||||
|
**/
|
||||||
|
public function _cli_show_attr($attr_name, $raw_values=false, $prefix="") {
|
||||||
|
if (!isset($this -> attrs[$attr_name]))
|
||||||
|
return;
|
||||||
|
echo "$prefix - $attr_name :";
|
||||||
|
$values = ($raw_values?$this -> attrs[$attr_name]->getValue():$this -> attrs[$attr_name]->getDisplayValue());
|
||||||
if (empty($values)) {
|
if (empty($values)) {
|
||||||
echo " empty\n";
|
echo " empty\n";
|
||||||
continue;
|
return true;
|
||||||
}
|
}
|
||||||
if (!is_array($values)) $values = array($values);
|
if (!is_array($values)) $values = array($values);
|
||||||
|
|
||||||
|
@ -1941,12 +1968,11 @@ class LSldapObject {
|
||||||
for ($i=0; $i < count($values); $i++)
|
for ($i=0; $i < count($values); $i++)
|
||||||
if (strlen($values[$i]) > 70)
|
if (strlen($values[$i]) > 70)
|
||||||
$values[$i] = substr($values[$i], 0, 65)."[...]";
|
$values[$i] = substr($values[$i], 0, 65)."[...]";
|
||||||
echo (count($values) > 1?"\n - ":" ");
|
echo (count($values) > 1?"\n$prefix - ":" ");
|
||||||
echo implode("\n - ", $values);
|
echo implode("\n$prefix - ", $values);
|
||||||
echo "\n";
|
echo "\n";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Error Codes
|
* Error Codes
|
||||||
|
|
Loading…
Reference in a new issue