- Replaced underscores in file path caching with a tilde instead.

This commit is contained in:
Dave Mc Nicoll 2019-12-19 09:53:15 -05:00
parent 0ce9955631
commit 079d8b058d
3 changed files with 57 additions and 4 deletions

View File

@ -54,7 +54,7 @@ class Opcache implements Cache {
}
if ( file_exists($path = $this->cachePath($viewPath)) ) {
$this->compiled[$viewPath] = require_once($path);
$this->compiled[$viewPath] = include($path);
return true;
}
@ -82,6 +82,6 @@ class Opcache implements Cache {
protected function cachePath(string $fileName = "") : string
{
return implode(DIRECTORY_SEPARATOR, array_filter([ $this->cachePath, $this->cacheFolder, $fileName ? str_replace([ "/", DIRECTORY_SEPARATOR ], "_", $fileName . ".php") : null ]));
return implode(DIRECTORY_SEPARATOR, array_filter([ $this->cachePath, $this->cacheFolder, $fileName ? str_replace([ "/", DIRECTORY_SEPARATOR ], "~", $fileName . ".php") : null ]));
}
}

View File

@ -13,7 +13,7 @@ class OrToken implements ControlStructure {
$key = count( $context->iterationStack ) - 1;
$context->iterationStack[$key]['or'] = true;
return "<?php {$context->iterationStack[$key]['token']}; if(false === {$context->iterationStack[$key]['uid']} ?? false): ?>";
return "<?php {$context->iterationStack[$key]['token']}; if( false === ({$context->iterationStack[$key]['uid']} ?? false) ): ?>";
}
}

View File

@ -4,10 +4,63 @@ namespace Picea\Extension;
class UrlExtension implements Extension {
protected string $urlBase;
public array $tokens = [ "url" , "route" ];
public function __construct(string $urlBase = "") {
$this->urlBase = $urlBase;
}
public function addRoute(string $routeName, string $url, array $parameters = [])
{
}
public function parse(/*\Picae\Compiler\Context*/ &$context, ?string $arguments, string $token) {
return "<?php /* echo url ?? */ ?>";
}
/**
* Return URI formatted
*/
public function uri($query_string = false) {
$uri = $_SERVER['REQUEST_URI'] ?? $this->php_self() . ($query_string ? $this->query_string() : "");
if ( ! $query_string ) {
$uri = explode('?', $uri, 2)[0];
}
if (($base = $this->config['base'] ?? false) && ( stripos($uri, $base) === 0 )) {
$uri = substr($uri, strlen($base));
}
return '/' . ltrim($uri, '/');
}
public function php_self() {
return isset($_SERVER['PHP_SELF']) ? str_replace(NEX . '/', '', $_SERVER['PHP_SELF']) : null;
}
/**
* Return query string
*/
public function query_string() {
return isset($_SERVER['QUERY_STRING']) ? '?' . $_SERVER['QUERY_STRING'] : "";
}
/**
* Check if Uri's segments are valid
* @param array $segments The uri's segments
*/
public function secure($segments = []) {
return array_diff($segments, ['..', '://']);
}
public function domain() {
$domain_list = (array) $this->config('Eckinox.system.url.root');
$current = strtolower($_SERVER['HTTP_HOST']);
return $domain = in_array($current, $domain_list) ? $current : $domain_list[0];
}
}