');
$navigation = $navigation->nav;
$cpt = array(
'controller' => 0
);
$projectDirectory = $xml->projectDirectory;
if ($projectDirectory->count() <= 0)
{
throw new Exception('No projectDirectory');
exit();
}
function fillNav($module, $current_node, $navigation)
{
global $cpt, $acl, $module_controller_separator;
$attributes = $current_node->attributes();
$tmp = 'controller' . $cpt['controller'];
$navigation->addChild('controller' . $cpt['controller']++);
$navigation->$tmp->addChild('label', $attributes['controllerName']);
$navigation->$tmp->addChild('controller', $attributes['controllerName']);
$navigation->$tmp->addChild('module', $module);
if ($acl)
$navigation->$tmp->addChild('ressources', $module . $module_controller_separator . $attributes['controllerName']);
if ($current_node->count() > 0)
{
$first = true;
$node = $navigation->$tmp;
foreach($current_node->actionMethod as $action)
{
$actionAttrs = $action->attributes();
if ($first)
{
$first = false;
$node->addChild('action', $actionAttrs['actionName']);
if ($acl)
$node->addChild('privilege', $actionAttrs['actionName']);
}
else
{
if ($node->pages->count() == 0)
{
$node->addChild('pages');
}
$tmp = 'controller' . $cpt['controller'];
$node->pages->addChild('controller' . $cpt['controller']++);
$node->pages->$tmp->addChild('label', $attributes['controllerName']);
$node->pages->$tmp->addChild('controller', $attributes['controllerName']);
$node->pages->$tmp->addChild('module', $module);
$node->pages->$tmp->addChild('action', $actionAttrs['actionName']);
if ($acl)
{
$node->pages->$tmp->addChild('ressources', $module . $module_controller_separator . $attributes['controllerName']);
$node->pages->$tmp->addChild('privilege', $actionAttrs['actionName']);
}
}
}
}
else
{
$navigation->$tmp->addChild('action', 'index');
if ($acl)
$navigation->$tmp->addChild('privilege', 'index');
}
return $navigation;
}
foreach($projectDirectory->applicationDirectory->controllersDirectory->controllerFile as $controller)
{
$navigation = fillNav('default', $controller, $navigation);
}
foreach($projectDirectory->applicationDirectory->modulesDirectory->moduleDirectory as $module)
{
$attributes = $module->attributes();
if ($module->controllersDirectory->controllerFile->count() == 0)
{
//pas de controller ... ajout index/index
$tmp = 'controller' . $cpt['controller'];
$navigation->addChild('controller' . $cpt['controller']++);
$navigation->$tmp->addChild('label', 'index');
$navigation->$tmp->addChild('controller', 'index');
$navigation->$tmp->addChild('module', $attributes['moduleName']);
$navigation->$tmp->addChild('action', 'index');
if ($acl)
{
$navigation->$tmp->addChild('ressources', $attributes['moduleName'] . $module_controller_separator . 'index');
$navigation->$tmp->addChild('privilege', 'index');
}
}
else
{
foreach($module->controllersDirectory as $controller)
{
$navigation = fillNav($attributes['moduleName'], $controller, $navigation);
}
}
}
header ('Content-Type:text/xml');
echo '' . $navigation->asXml() . '';
# EOF