1
0
mirror of https://github.com/e107inc/e107.git synced 2025-07-30 11:20:25 +02:00

Record count no longer depends on subclass impl.

Subclasses may forget to run code to do a total record count, which
leads to output showing "Total Records: 0" on some pages with lists,
like `/e107_admin/links.php`.

This commit cuts out the record counting from the getList() method of
any e_admin_form_ui subclasses and the base class so that subclasses do
not have to reimplement record counting.

The caveat with this implementation is that it violates the Law of
Demeter, as evidenced by the new chained method call:

    $this->getController()->getTreeModel()->getTotal()

Jumping through two objects to get a value is not ideal, but this is the
code we have to work with at the moment.
This commit is contained in:
Deltik
2018-02-09 04:57:01 -06:00
parent 511bb9eae9
commit 2167a69a50

View File

@@ -6484,9 +6484,6 @@ class e_admin_form_ui extends e_form
// if going through confirm screen - no JS confirm
$controller->setFieldAttr('options', 'noConfirm', $controller->deleteConfirmScreen);
$this->listTotal = $tree[$id]->getTotal();
$fields = $controller->getFields();
// checks dispatcher acess/perms for create/edit/delete access in list mode.
@@ -7017,7 +7014,7 @@ class e_admin_form_ui extends e_form
$text .= "
<div id='admin-ui-list-total-records' class='span6 col-md-6 right'><span>".e107::getParser()->lanVars(LAN_UI_TOTAL_RECORDS,number_format($this->listTotal))."</span></div>
<div id='admin-ui-list-total-records' class='span6 col-md-6 right'><span>".e107::getParser()->lanVars(LAN_UI_TOTAL_RECORDS,number_format($this->getController()->getTreeModel()->getTotal()))."</span></div>
</div>
";