Admin.php Refactoring

Extracting methods

The first step of the ADMIN.php refactoring is to extract methods from ADMIN.php to helper classes, cleaning the admin class and providing reusable methods for the rest of the system. This task is almost done, although some work is still necessary (there is more code to extract) and it was not well tested yet.

Many object logic and almost all database access were moved to 12 helper classes: BLOG_DB, PLUGIN_DB, MEMBER_DB, ITEM_DB, COMMENT_DB, TEAM_DB, CATEGORY_DB, BAN_DB, SKIN_DB, TEMPLATE_DB, CONFIG_DB and LOG_DB.

Improvements on ADMIN.php and the helper classes so far:

  • phpDocumentor comments were added to all methods
  • Almost all code formatting was done following the Code Cleanup Project (brackets were added to if statements were they were missing, a standard way to open/close brackets was applied etc)
  • ADMIN.php is 1000 lines smaller

Some thoughts

  • The _DB sufix seems to be not very accurate sometimes. In some cases a method just performs some system logic, but doesn't access a database.
  • There is now a method add() in CATEGORY_DB, to add new categories. But BLOG also has a createNewCategory() method. They are slightly different - the method extracted from ADMIN.php, and called when a new blog is created, don't evoque the PreAddCategory event (a bug, perhaps). We need to merge both, since there is no sense to to have two methods in two different places to perform the same action. Conclusion: move the code from BLOG to the helper class, but keep the BLOG method as an alias, marking it as @deprecated and make a note pointing to the helper class method (as suggested by Teranex).
  • The same happens with the BLOG method additem(), which should be moved to ITEM_DB.

Also: deprecated functions

Proposed libraries

Here's a list of proposed libraries for the admin area that can also be useful for plugins. Please add others you think are worth. They should be preferably:

  • small enough (or “not too big”);
  • well known (or “in a stable state for at least one year or so”);
  • well documented (or “you can find some info about how to use them”);
  • still maintained (or “the latest release is not one year old or so”).


Name & links Description Info
phpSavant
docs
Summary:
A “pure-php” template system.
Benefits:
* separates business logic from presentation.
* makes code cleaner and easier to maintain.
* allows easy theming (for those not scared whith a <?php tag).
* allows the use of plugins. you can build, by example, a date/time form widget to use in the entire application.
* allows to build a customized markup compiler (so the templates won't be pure php).
* may be used both to build the admin area and for plugins output.
Size: 144 KB / 49 KB zipped
(including all plugins and filters)
Latest release: 2006-01-01
PEAR::Pager
end-user docs
API docs
Summary:
A class to page an array of data.
Benefits:
* allows complete customization of the output.
* allows internationalization.
* allows various widgets (“go to page X”, “display X results per page”).
* allows different pagination styles (it comes with two, but more can be added).
* it even works with mod_rewrite.
* may be used both to build admin area's lists and to page plugin results.
Size: 69 KB / 19KB zipped
(including two pagination styles)
Latest release: 2005-09-28
newadmin/admin_refactoring.txt · Last modified: 2006/07/05 13:03 (external edit)
 
Except where otherwise noted, content on this wiki is licensed under the following license: CC Attribution-Noncommercial-Share Alike 3.0 Unported
Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki