I see. At the moment, I parse a required XML file based on what is passed via $_REQUEST.
This XML file has some variables required for the given page, such as which body template, and ''blocks'' to use, which are basically structural containers for dynamic data pulled from the model.
You are talking about a front controller, so I can only assume that from my script, this is the front controller ?
PHP Code:
class Application {
function Application() {
} // class constructor not implemented
function Run( $action, $l = false /* log in result */ ) {
if( $l == (bool) false && $action['command'] != (string) 'LogIn' ) {
header( 'location:index.php?Cmd=LogIn' );
die();
}
# fetch required file that contains execute command structure
Application::Import( $action['module'] );
# create an instance of this commands controller and perform an action
$cntrl = &new $action['action']( &$action );
$cntrl -> Perform();
}
function Import( $file ) {
# check that file actually exists, if not then generate an error
if( !file_exists( $file ) ) {
ErrorReport::Invoke( 200 ); // bad file read
die();
}
require_once( $file );
}
}
class Action {
function Action() {
} // class constructor not implemented
function Respond( $action ) {
# fetch command given by a user, or use default if none found
$command = (string) ucwords( array_key_exists( 'Cmd', $action )? array_shift( $action):'CPanel' );
$filename = strtolower( $command ); // all filenames are in lowercase
# create an instance of XmlReader using this commands assocc configuration file
$conf = &new XmlReader( DOCUMENT_PATH. $filename .'.action.xml' );
# fetch root elements belonging to configuration file
$children = $conf -> FindChildrenOf( 'command', 'Command' );
$action = array();
$action['xmlreader'] = &$conf;
foreach( $children as $child ) {
# every root element requires an array position
if( $conf -> NameOf( $child ) == 'templates' ) {
# found an element typeof XML_ELEMENT_NODE
$action[$conf -> NameOf( $child )] = array();
# find all child elements
$templates = $conf -> FindChildrenOf( 'templates', 'Templates' );
foreach( $templates as $template ) {
# for each child element, extract name and contents
$node = $conf -> Extract( $template );
# store a template name and filename to array
$action[$conf -> NameOf( $child )][$conf -> NameOf( $template )] = $node['filename'];
}
}
else if( $conf -> NameOf( $child ) == 'fragments' ) {
# found an element typeof XML_ELEMENT_NODE
$action[$conf -> NameOf( $child )] = array();
# find all child elements
$fragments = $conf -> FindChildrenOf( 'fragments', 'Fragments' );
foreach( $fragments as $fragment ) {
# for each child element, extract name and contents
$node = $conf -> Extract( $fragment );
# store a template name and filename to array
$action[$conf -> NameOf( $child )][$conf -> NameOf( $fragment )] = $node['filename'];
}
}
else {
# no child elements on this iteration found
$action[$conf -> NameOf( $child )] = $conf -> ContentOf( $child );
}
}
return $action; // typeof array
}
}
Here is an example of one of those XML files I stated as well 
PHP Code:
<?xml version="1.0" encoding="iso-8859-1"?>
<module>
<forms>
<form />
</forms>
<command name='Command'>
<task />
<title>Manage your application and it's user from this control panel</title>
<action>CPanel</action>
<module>modules/administration/cpanel.class.php</module>
<heading>Administration :: Control Panel</heading>
<templates name='Templates'>
<template>
<filename>templates/cpanel.html</filename>
</template>
<header>
<filename>templates/header.html</filename>
</header>
<footer>
<filename>templates/footer.html</filename>
</footer>
<body>
<filename>templates/body.html</filename>
</body>
</templates>
<blocks name='Blocks'>
<a>
<filename />
</a>
</blocks>
</command>
</module>
Lastcraft, any thoughts? 
Thanks again.
Bookmarks