Administration tool basics
Do not optimize when it is does not pay off!
Database administration classes
DataBrowser class
This class eases the writing of tabular data views. Here some highlights of the class
- Has been used in hundreds (really) of web applications
- Uses a generic Smarty template for all instances, no tailoring needed
- Gets an SQL SELECT statement and fetches the data
- Easy-to add column definitions for most data formats
- Option to use column specific callback functions for formatting data
- Option for CSS callbacks per column
- Automatic link generation for editing, deleting and inserting new data
- Automatic filtering/sorting/whatever using dropdowns
- Option to add new function buttons
- Option to use paging
- A generic template tailored for this very class
UpdateForm class
This class provides a simple way of generating forms for the most common tasks
- Field types for the most common tasks
- Super-simple way of adding dropdowns
- Special fields like date and time
- Easy-to-add hidden fields
- Easy-to-add JavaScript
- A generic template tailored for this class
DBUpdate class
- Simple and efficient creation of database update statements
- Understands checkboxes, text data and Smarty select date arrays
- Easy-to-add basic error handling
- No templates needed
DataBrowser.class.php, UpdateForm.class.php and DBUpdate.class.php and they should be to an appropriate directory to be included in the administration scripts. The current version has a permissive license (see the licensing page). We do not present the code here and the package is only included in a scrambled format. The PHPDocumentor generated documentation will be provided at a later stage.The Database Handling Templates
DataBrowser template
UpdateForm template
Wizardry
CREATE TABLE statement as an input, parses it, lets the user decide which fields he wants to display in the browse and how and the fields he wants to show in the update form. After getting the information the wizard creates the modules for browsing, editing and updating data.This speeds up development enormously. A one-table browse-edit-update sequence can normally be created within a few minutes. One of our developers created a small Call Center application from scratch in less then 20 minutes using the wizard.Creating the directory structure
admin site is an almost exact copy of the main level. We have added two important directories: /icon and /js. We will install a few image files to the icon directory and a huge amount of JavaScript in the other.
/[web application root] |
|
+-/admin
|
+-/cache
|
+-/include
|
+-/icon [administration icons go here]
|
+-/js [lot of JavaScript here a bit later]
|
+-/files
| |
| +-/images
|
+-/lib
| |
| +-/smarty [in Unix/Linux Symbolic link to the directory below]
| |
| +-/Smarty-3.x.x [in Windows rename this to "smarty"]
| |
| +-/libs
| |
| +-/plugins
| |
| ...
|
+-/modules
| |
| +-/simpleMenu
| |
| +-/htmlFile
| |
| +-/simpleRSS
| |
| +-/
| |
+-/templates
|
+-/templates_c
Session data in a database table (optional)
memory table using a PHP session handling class. If you do not wish to use it, then do not. CREATE TABLE sessions (
ses_id varchar(32),
ses_time int(11),
ses_start int(11),
ses_value varchar(255) DEFAULT '',
PRIMARY KEY (ses_id)
) ENGINE=MEMORY DEFAULT CHARSET=utf8;session.class.php is not shown here as it is too long and uninteresting. We will save it to /admin/include and also save the following file as "session.php" to the same place. But, as said, you do not need to add this now.Administration site index.php
Our Administration root index file looks like this:
As you may notice that we have turned on output buffering. The next thing is to have a look at what we must do with the main template.