I have been thinking about this for around a week or so, and I am going to post all the thoughts I have in my head here. My system uses a lot of OOP and arrays(I'm sure nobody's against arrays but I think some people are against OOP
) (In objects, properties are variables and methods are functions in case you don't know)
All modules have their own objects, extended from class Module. In the module handling page, there is a function called init_modules(), which basically creates instances of all the modules, and puts them into $modules, which is an array. It also reads prefs.php inside the module's directory, and finds out whether it's "magical" or not, and other things, and also puts them into the array $modules. The array structure will be something like this - $modules["category"]["name"]["object"] . Methods, when needed, are directly called from the module handling page, like this - $modules["normal"]["news"]["object"]->constructor(); I will explain what constructor() and "normal" means later.
There are two types of modules - magical(I think I should come up with a better name) and non-magical/normal. Magical modules are things that don't really output anything, and mainly deals with the DB. Templates, auth, DBAL, user handling, groups, etc. will be "magical". They are always used on every page.
GPC variables are always suffixed by something like this - name_modname_public. "name" is the name, "modname" is the module's name, and "public" describes whether it's public or private - whether it's accessible by other modules. Other properties and methods that are to be private are prefixed by a single _, like $_private_var or _private_method().
The order the modules are called depend on their admins. They are basically called in this order - invisible/silent modules(usually magical), page header, left bar, main, right bar, and footer. The invisible/silent modules include the DBAL, which makes the connection to the DB. Sessions are also started. The page header includes the page header(obviously), and the left bar may contain navigation links, etc. The main is where the main thing happens. Depending on what page they want to look at, this is the part where news, calender, etc. will be shown. The right bar doesn't have to be included(the left bar doesn't have to be shown either, and in fact, only the invisible/silent(usually magical) modules and the main modules are required). The page footer shows, well, the page fotoer. The MAIN module is decided on the GET/POST vars passed to the module handler page.
To be continued...(probably tomorrow - December 4 9 P.M. EST) Comments are welcome on the finished section of my proposal.
All modules/objects should have methods called constructor() and destructor() (with the exception of magical modules, they are not required). constructor() will be called something like this -
bool/void constructor(array get_vars, array post_vars, array cookie_vars)
As said earlier, some suffixes get added to GPC variables, and these suffixes are stripped off(with the exception of public vars from other modules). The function constructor() should do anything it needs to do according to the GPC variables.
destructor() is called this way - void destructor(void) It cleans up anything the module has been doing(e.g. end transactions). It is called when the module is out of use for the page(when it will not be used anymore on the page).
Administration page of the module is put into a file called admin.php(I suppose) and is still undecided whether it should be object-oriented or not. Since OOP is used extensively through the system, I think it would be better to NOT have it object-oriented. It will work similiar to phpBB's administration module system.
There's a problem with this system, though-
1. If a header needs to be sent/a cookie needs to be set in the main section of the page, it'll just spit out an error that it's impossible because output's already started.
Soultions - 1. Edit the template system somehow and implement pseudo-output buffering(it should be pretty easy)
2. Have the page header module cache everything, and echo it when is triggered by the main module
Any comments? (now that it's finished)