public assets

main
Robert 3 weeks ago
parent fbabdb4df4
commit b7b18a924d
  1. 13
      src/Framework/Assets.php
  2. 5
      src/Framework/View.php

@ -36,7 +36,8 @@ class Assets
*/ */
private static function attemptsRootDir(?string $path): bool { private static function attemptsRootDir(?string $path): bool {
// up from src and back up to public // up from src and back up to public
$open_base_dir_path = dirname(BaseDir, 1) . '/public/'; $open_base_dir_path = BaseDir. '/public/';
if ($path === null || $path === '') { if ($path === null || $path === '') {
return false; return false;
} }
@ -107,7 +108,7 @@ class Assets
public static function wrapAsset(string $file, string $scope = 'project') { public static function wrapAsset(string $file, string $scope = 'project') {
$scope = StringFacade::strtolower($scope); $scope = StringFacade::strtolower($scope);
if ($scope === 'cdn') { if ($scope === 'cdn') {
$proto = bootstrap\safer_io::get_clean_server_var('SERVER_PROTOCOL'); $proto = $_SERVER['SERVER_PROTOCOL'];
if ($proto === null) { if ($proto === null) {
$protocol = '://'; $protocol = '://';
} else { } else {
@ -116,7 +117,7 @@ class Assets
return (str_contains($file, '://') === true) ? $file : $protocol . $file; return (str_contains($file, '://') === true) ? $file : $protocol . $file;
} }
if ($scope === 'project' || $scope === 'app') { if ($scope === 'project' || $scope === 'app') {
$path = PROJECT_ASSETS_DIR . "/"; $path = PROJECT_ASSETS_DIR;
$ism = self::isMinified($path, $file); $ism = self::isMinified($path, $file);
return ($ism !== false) ? PROJECT_ASSETS_BASE_REF . "/" . $ism : false; return ($ism !== false) ? PROJECT_ASSETS_BASE_REF . "/" . $ism : false;
} }
@ -138,14 +139,14 @@ class Assets
if ($scope === 'cdn') { if ($scope === 'cdn') {
return ""; return "";
} else if ($scope === 'project' || $scope === 'app') { } else if ($scope === 'project' || $scope === 'app') {
$path = PROJECT_ASSETS_DIR . "/"; $path = PROJECT_ASSETS_DIR;
} else if ($scope === 'assets') { } else if ($scope === 'assets') {
$path = ASSETS_DIR . "/"; $path = ASSETS_DIR . "/";
} else { } else {
return ""; return "";
} }
$check = self::is_minified($path, $file); $check = self::isMinified($path, $file);
return ($check !==false) ? self::get_ver($path . $check) : false; return ($check !==false) ? self::getVer($path . $check) : false;
} }
/** /**

@ -140,8 +140,9 @@ final class View
{ {
if (!empty($render_page)) { if (!empty($render_page)) {
$render_page = str_replace('.php', '', $render_page); $render_page = str_replace('.php', '', $render_page);
$templ = "/Templates/{$render_page}"; $templ = "Templates/{$render_page}";
if (bootstrap\requires::safer_file_exists(IO_CORNERSTONE_PROJECT . $templ . '.php') !== false) {
if (Requires::saferFileExists(IO_CORNERSTONE_PROJECT . $templ . '.php') !== false) {
$this->template = $templ; $this->template = $templ;
return true; return true;
} }

Loading…
Cancel
Save