public static function routeCodepages() { $filename = static::findFileForRoute(Route::requestUri(), Conf::get('glueExtras/RouteTools/codepages/path'), array('php')); if ($filename) { Route::any(Route::requestUri(), function () use($filename) { require $filename; }); } }
protected static function tidy($request) { if (is_array($request)) { foreach ($request as $key => $value) { $request[$key] = static::tidy($value); } return $request; } $request = preg_replace_callback('/@@[a-z0-9\\/\\-_]+@@/i', function ($matches) { $return = str_replace('@@', '', $matches[0]); $return = Conf::get($return); return $return; }, $request); return $request; }
public static function render($tName = false, $values = false) { if (!$tName) { $tName = static::getTemplate(); } if (!$values) { $values = static::getFields(); } if (!static::$twigLoader) { static::$twigLoader = new Twig_Loader_Filesystem(array_reverse(Conf::get('Template/dirs'))); } if (!static::$twigEnv) { static::$twigEnv = new Twig_Environment(static::$twigLoader, array()); } $template = static::$twigEnv->loadTemplate(Template::getTemplate()); echo $template->render(Template::getFields()); }
/** * This function is used in glue.php to load routes */ function glue_load_routes() { //routes consist of Route/routes with Route/system appended $routes = Conf::get('Route/routes'); $sysroutes = array_reverse(Conf::get('Route/system')); foreach ($sysroutes as $route) { $routes[] = $route; } //Site routes can override system routes foreach ($routes as $value) { $paths = array(SITE_PATH . '/routes/' . $value . '.php', GLUE_PATH . '/routes/' . $value . '.php'); foreach ($paths as $file) { if (file_exists($file)) { Route::loadfile($file); break; } } } }
use glue\Template; use glueExtras\RouteTools; if (!Route::processed()) { if (Conf::get('glueExtras/RouteTools/content/enabled')) { RouteTools::routeRedirects(); RouteTools::routeMarkdown(); RouteTools::routeStatic(); } } if (!Route::processed()) { if (Conf::get('glueExtras/RouteTools/codepages/enabled')) { RouteTools::routeCodepages(); } } if (!Route::processed()) { if (Conf::get('glueExtras/RouteTools/autoroute/enabled')) { RouteTools::routeAutoRoute(); } } //Warn if GLUE_PATH or SITE_PATH are in the document root if (!Conf::get('environment/suppress_public_path_warnings')) { $nDOC_ROOT = str_replace('\\', '/', $_SERVER['DOCUMENT_ROOT']); $nGLUE_PATH = str_replace('\\', '/', GLUE_PATH); $nSITE_PATH = str_replace('\\', '/', SITE_PATH); if (strpos($nGLUE_PATH, $nDOC_ROOT) === 0) { echo "<div><strong>Warning:</strong> Your GLUE_PATH is inside the document root.\n It's protected by a .htaccess file, but best practice is to move it outside your public web directory.\n <br/>You can suppress this warning by setting <em>suppress_public_path_warnings: true</em>\n in environment.yaml.</div>"; } if (strpos($nSITE_PATH, $nDOC_ROOT) === 0) { echo "<div><strong>Warning:</strong> Your SITE_PATH is inside the document root.\n It's protected by a .htaccess file, but best practice is to move it outside your public web directory.\n <br/>You can suppress this warning by setting <em>suppress_public_path_warnings: true</em> in\n environment.yaml.</div>"; } }