Let me first explain how the application works in general, right now.
- index.php instantiates a class called Backbone. This is a global instance.
- Backbone handles a variety of tasks upon construction, one wich is creating an instance of a Config object, used to read/store configuration options. It is made global so it doesn't have to read from the configuration file every time it needs an option.
- The instance of Backbone is now fully constructed, index.php calls $backbone->startApplication(), wich starts preprocessing, no output is generated yet, it just checks and validates user input, and generates error messages upon validation failure.
- Backbone creates an instance of Output, made global, so all following classes can use the same instance of the output.
- Output, like the name suggests is used to assemble the XHTML output, and is reponsable for compression, caching and http headers.
- From index.php, I add elements to the document held by the global instance of Output. These are default elements for this website.
- I also set a 'default state' wich tells the Navigation class what to execute, unless told otherwise by either $_GET['state'], $_SESSION['state'] or the configured 'handler class' for a submitted form.
- index.php calls $backbone->process(), that's when the action really takes place.
- The Navigation class, in a single instance local to Backbone::process(), loads navigational items from an XML file, wich indicate what class, what method with what parameters to execute for a state, unless like I said, a form was submitted, in which case that data is read from the configuration file, which also hold the definition for all forms.
- The classes that are executed by Navigation append their output directly to the global $output.
- index.php calls $backbone->endApplication(), wich finishes up and calls $output->sendOutput().
For Ajax updates this works a little different, but let's take one thing at the time.
Any suggestions on improving performance, security or general structural improvements are more than welcome.