function get_footer() { Hook::TriggerEvent(Hook::GENERATE_FOOTER); }
} } throw new Exception("Load {$name} failed."); }); // 加载辅助函数 include_once LIB_DIR . "/password.php"; include_once CLASSES_DIR . "/functions.php"; include_once CLASSES_DIR . "/setup_env.php"; setup_encoding(); define('BLOG_URL', get_app_url()); // load plugins foreach (glob(APP_DIR . "/plugins/*/main.php") as $filename) { include $filename; } // 全局的配置 $config = new Config(DATA_DIR . '/config.php'); setup_default_config(); // 配置完成 Hook::TriggerEvent(Hook::CONFIG_COMPLETE, array($config)); // 使用配置来设置环境 setup_env_by_config(); $postHelper = new FilePostHelper(CACHE_DIR . '/post.meta'); $tellets = new Tellets(); // 添加预定义动作 include_once CLASSES_DIR . '/predefined_hooks.php'; // 添加预定义解析器 ParserFactory::RegisterParser(MarkdownParser::EXTENSION, 'MarkdownParser'); ParserFactory::RegisterParser(HTMLParser::EXTENSION, 'HTMLParser'); // 启动完成 Hook::TriggerEvent(Hook::BOOTSTRAP, array());
<?php session_start(); require_once __DIR__ . '/app/bootstrap.php'; if (false === isset($config['password'])) { goto FIRST_RUN; } $request = new Request(@$_GET['params']); Hook::TriggerEvent(Hook::RESOLVE_REQUEST, array($request)); function renderContext() { global $request, $config, $postHelper; $post = $request->getSinglePost(); $posts = $request->getPosts(); $configt =& $config[Config::NS_TEMPLATE]; $configp =& $config[Config::NS_PLUGINS]; // display if ($posts) { if ($request->isHome()) { include TEMPLATE_DIR . '/index.php'; } else { include TEMPLATE_DIR . '/posts.php'; } } elseif ($post) { include TEMPLATE_DIR . '/post.php'; } else { include TEMPLATE_DIR . '/message.php'; } } renderContext(); exit;
public function resolvePost($name) { /** * @var Post */ $post = NULL; Hook::TriggerEvent(Hook::RESOLVE_POST, array(&$post, $name)); return $post; }