Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implemented custom sorting for e_tree_model #3031

Merged
merged 3 commits into from
Feb 9, 2018
Merged

Implemented custom sorting for e_tree_model #3031

merged 3 commits into from
Feb 9, 2018

Conversation

Deltik
Copy link
Member

@Deltik Deltik commented Feb 9, 2018

In #3025, e_tree_model sorting was reimplemented in pure PHP, but this broke custom sorting (like ?field=cat_name&asc=desc).

This pull request introduces a hack that simulates a subset of MySQL/MariaDB ORDER BY clauses, which should be sufficient for all known custom sorting that can be requested.

Tree formatting is always preserved, but custom sorting will apply for all items at a certain depth under the same parent.

This pull request also contains some minor formatting fixes and makes a minor change to some regex to make use of non-capturing groups.

Fixes: #3029

In #3025, e_tree_model sorting was reimplemented in pure PHP, but this
broke custom sorting (like `?field=cat_name&asc=desc`).

This commit introduces a hack that simulates a subset of MySQL/MariaDB
ORDER BY clauses, which should be sufficient for all known custom
sorting that can be requested.

Tree formatting is always preserved, but custom sorting will apply for
all items at a certain depth under the same parent.

This commit also contains some minor formatting fixes and makes a minor
change to some regex to make use of non-capturing groups.

Fixes: #3029
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.
@CaMer0n CaMer0n merged commit 2823087 into e107inc:master Feb 9, 2018
@CaMer0n
Copy link
Member

CaMer0n commented Feb 9, 2018

👍 Thank you!!

@Deltik Deltik deleted the fix-3029 branch February 9, 2018 18:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Admin UI Does not order the results
2 participants