示例#1
0
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);
}
示例#2
0
    $_struct = new structure('xml/structure.xml');
    $_out = new out();
    $_sec = $_struct->getCurrentSection();
    $m = new modules($_site, 'modules');
    $m->run();
    $_sec->getModules()->run();
    $_out->xmlInclude($_struct);
    $_out->xmlInclude($_site->getSiteInfo());
    $_tpl = $_sec->getTemplate();
    //$_out->save('temp.xml');
    echo $_tpl->transform($_out);
} catch (Exception $e) {
    switch ($e->getCode()) {
        case EXCEPTION_404:
            header("HTTP/1.0 404 Not Found");
            $_site = new site('xml/site.xml');
            $_struct = new structure('xml/structure.xml');
            $_out = new out();
            $_out->setMeta('title', '404 Page not found');
            $_sec = $_struct->addSection('error404', '404');
            $_sec->setSelected(true);
            $_out->xmlInclude($_struct);
            $_out->xmlInclude($_site->getSiteInfo());
            $_tpl = new template($_struct->getTemplatePath() . 'default.xsl');
            $_tpl->addTemplate($_struct->getTemplatePath() . '404.xsl');
            echo $_tpl->transform($_out);
            break;
        default:
            echo 'Exception: ' . $e->getMessage();
    }
}