From 2167a69a5013cd460f47e770e440be3e8fd5dada Mon Sep 17 00:00:00 2001 From: Deltik Date: Fri, 9 Feb 2018 04:57:01 -0600 Subject: [PATCH] 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. --- e107_handlers/admin_ui.php | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/e107_handlers/admin_ui.php b/e107_handlers/admin_ui.php index 68b36158f..d8e1305af 100755 --- a/e107_handlers/admin_ui.php +++ b/e107_handlers/admin_ui.php @@ -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 .= " -
".e107::getParser()->lanVars(LAN_UI_TOTAL_RECORDS,number_format($this->listTotal))."
+
".e107::getParser()->lanVars(LAN_UI_TOTAL_RECORDS,number_format($this->getController()->getTreeModel()->getTotal()))."
";