define('PATH_TPL_CLIENT', PATH_ROOT . ABS_PATH_TPL_CLIENT); try { $_site = new site('../xml/site.xml'); $_struct = new structure('xml/structure.xml', 'xml/data', 'xml/templates'); $_out = new out(); $_events = new events('xml/events.xml'); $_events->addEvent('SectionReady'); $_events->addEvent('PageReady'); $_site->setModules(new modules($_site, 'apModules')); $modules = $_site->getModules(); if (!$modules->hasModule('ap')) { $modules->move($modules->add('ap'), 1); } $modules->run(); $_sec = $_struct->getCurrentSection(); $_events->happen('SectionReady'); $_sec->getModules()->run(); $_out->xmlInclude($_struct); $_out->xmlInclude($_site); $_events->happen('PageReady'); $_tpl = $_sec->getTemplate(); //$_out->save('temp.xml'); $tmp = explode('/', trim(parse_url($_SERVER['REQUEST_URI'], PHP_URL_PATH), '/')); array_pop($tmp); $_out->de()->setAttribute('base_url', '/' . implode('/', $tmp) . '/'); echo $_tpl->transform($_out); } catch (Exception $e) { $_out = new out(); $_out->addSectionContent('Exception: ' . $e->getMessage()); $_tpl = new template('xml/templates/error.xsl'); echo $_tpl->transform($_out);