protected function parseTpl($tpl = '') { if (is_file($tpl)) { return $tpl; } // list($module,$class,$func) = explode('\\', get_class($this) ); $tpl = $tpl != '' ? $tpl : POEM_FUNC; if (strpos($tpl, '@') !== false) { // 模块 Home@Index/index list($module, $tpl) = explode('@', $tpl); $file = APP_PATH . "{$module}/view/{$tpl}.html"; // html文件路径 } elseif (strpos($tpl, ':') !== false) { // 指定文件夹 Index/index $tpl = str_replace(':', '/', $tpl); $file = APP_PATH . POEM_MODULE . "/view/{$tpl}.html"; // html文件路径 } else { $file = APP_PATH . POEM_MODULE . "/view/" . POEM_CTRL . "/{$tpl}.html"; // html文件路径 } is_file($file) or \poem\app::halt('文件不存在' . $file); return $file; }
<?php header("Content-Type: text/html;charset=utf-8"); header("X-Powered-By: PhpPoem_v2.0"); defined('APP_DEBUG') || define('APP_DEBUG', false); define('APP_RUNTIME_PATH', APP_PATH . 'runtime/'); // 运行时临时文件目录 define('POEM_PATH', __DIR__ . '/'); // phppoem目录 define('CORE_PATH', realpath(POEM_PATH . 'core') . '/'); // Framework核心代码库 define('VENDOR_PATH', POEM_PATH . 'vendor/'); // 扩展包库 define('CORE_CONF', POEM_PATH . 'config.php'); // Framework核心代码库 define('CORE_FUNC', POEM_PATH . 'function.php'); // Framework核心代码库 define('APP_CONF', APP_PATH . 'config.php'); // 运行目录配置 define('APP_FUNC', APP_PATH . 'function.php'); define('APP_ROUTE', APP_PATH . 'route.php'); define('IS_AJAX', isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest' ? true : false); define('IS_CLI', PHP_SAPI == 'cli' ? 1 : 0); require CORE_PATH . 'app.php'; \poem\app::start();
function vendor($require_class, $ext = '.php') { static $_file = array(); if (class_exists($require_class)) { return true; } if (isset($_file[$require_class])) { return true; } $file = VENDOR_PATH . $require_class . $ext; if (!is_file($file)) { \poem\app::halt('文件不存在: ' . $file); } $_file[$require_class] = true; require $file; }