Commit 69d6b88b authored by Côme Chilliet's avatar Côme Chilliet
Browse files

feat(core) Clean up divSelectBox, Adapt Ordered height to content

issue #5135
parent e53a0374
......@@ -30,15 +30,14 @@
*/
class divSelectBox
{
var $headers = FALSE;
var $a_entries;
var $summary;
var $cols;
protected $headers = FALSE;
protected $a_entries;
protected $summary;
protected $cols;
private $id;
protected $id;
// Members for page managment
var $height = '200px';
protected $height = '200px';
/*!
* \brief Default divSelectBox constructor
......@@ -70,7 +69,7 @@ class divSelectBox
*
* \param array $a_entriedata
*/
function AddEntry($a_entriedata)
function addEntry($a_entriedata)
{
$this->a_entries[] = $a_entriedata;
}
......@@ -80,7 +79,7 @@ class divSelectBox
*
* \param array $headers
*/
function SetHeaders($headers)
function setHeaders($headers)
{
$this->headers = $headers;
}
......@@ -88,7 +87,7 @@ class divSelectBox
/*!
* \brief Draw the list
*/
function DrawList()
function drawList()
{
$s_return = '';
$s_return .= '<div style="border:1px solid rgb(170,170,170);padding-right:1px;height:'.$this->height.';width:100%">'."\n";
......@@ -102,7 +101,7 @@ class divSelectBox
'border:none; '.
'"'.
">\n";
$s_return .= $this->_generatePage();
$s_return .= $this->generatePage();
$s_return .= '</table></div></div>';
if ($this->headers !== FALSE) {
$s_return .=
......@@ -113,20 +112,12 @@ class divSelectBox
return $s_return;
}
/*!
* \brief Get the number of entries
*/
function _numentries()
{
return count($this->a_entries);
}
/*!
* \brief Set summary
*
* \param string $msg
*/
function SetSummary($msg)
function setSummary($msg)
{
$this->s_summary = $msg;
}
......@@ -134,7 +125,7 @@ class divSelectBox
/*!
* \brief Generate the page
*/
function _generatePage()
protected function generatePage()
{
$display = '';
if ($this->headers !== FALSE) {
......@@ -147,13 +138,13 @@ class divSelectBox
}
$display .= '</tr></thead>'."\n";
}
return $display.'<tbody>'.$this->_generateBody().'</tbody>';
return $display.'<tbody>'.$this->generateBody().'</tbody>';
}
/*!
* \brief Generate the body
*/
function _generateBody()
protected function generateBody()
{
/* If divselectbox is empty, append a single white entry */
if (count($this->a_entries) == 0) {
......
......@@ -371,7 +371,6 @@ class OrderedArrayAttribute extends SetAttribute
{
protected $order;
protected $edit_enabled;
protected $height = 90;
protected $headers = FALSE;
/*! \brief The constructor of OrderedArrayAttribute
......@@ -388,11 +387,6 @@ class OrderedArrayAttribute extends SetAttribute
$this->edit_enabled = $edit_enabled;
}
function setHeight($h)
{
$this->height = $h;
}
function setHeaders($h)
{
$this->headers = $h;
......@@ -447,11 +441,18 @@ class OrderedArrayAttribute extends SetAttribute
function renderOnlyFormInput ()
{
if (($this->size < 15) && ($this->size < count($this->value))) {
$this->size = min(15, count($this->value));
}
$id = $this->getHtmlId();
$div = new divSelectBox('rows'.$id);
$smarty = get_smarty();
$div->SetHeight($this->height);
$div->SetHeaders($this->headers);
$height = ($this->size * 26) + 6;
if ($this->headers) {
$height += 29;
}
$div->setHeight($height);
$div->setHeaders($this->headers);
foreach ($this->value as $key => $value) {
$fields = array();
foreach ($this->getAttributeArrayValue($key, $value) as $field) {
......@@ -468,9 +469,9 @@ class OrderedArrayAttribute extends SetAttribute
list ($img, $nbicons) = $this->genRowIcons($key, $value);
$fields[] = array("html" => $img, "attach" => 'style="border:0px;width:'.($nbicons * 20).'px;"');
$div->AddEntry($fields);
$div->addEntry($fields);
}
$smarty->assign("div_$id", $div->DrawList());
$smarty->assign("div_$id", $div->drawList());
return '{$div_'.$id.'}'."\n";
}
......
......@@ -196,11 +196,11 @@ class ACLEditionDialog extends GenericDialog
$field1 = array('html' => $infos['description'], 'attach' => 'style="width:140px"');
$field2 = array('html' => $summary);
$field3 = array('html' => $action, 'attach' => 'style="border-right:0px;width:40px"');
$aclList->AddEntry(array($field1, $field2, $field3));
$aclList->addEntry(array($field1, $field2, $field3));
}
$smarty->assign('headline', _('List of available ACL categories'));
$smarty->assign('aclEdition', $aclList->DrawList());
$smarty->assign('aclEdition', $aclList->drawList());
} elseif ($this->dialogState == 'edit') {
/* Collect objects for selected category */
$aclObjects = array();
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment