Remove media menu option and verify route handling
This commit is contained in:
69
cms/core/class/AssetManager.php
Normal file
69
cms/core/class/AssetManager.php
Normal file
@@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
class AssetManager {
|
||||
private array $css = [];
|
||||
private array $js = [];
|
||||
|
||||
public function __construct() {
|
||||
// Constructor can be extended for future use
|
||||
}
|
||||
|
||||
public function addCss(string $path): void {
|
||||
$this->css[] = $path;
|
||||
}
|
||||
|
||||
public function addJs(string $path): void {
|
||||
$this->js[] = $path;
|
||||
}
|
||||
|
||||
public function addBootstrapCss(): void {
|
||||
$this->addCss('/assets/css/bootstrap.min.css');
|
||||
$this->addCss('/assets/css/bootstrap-icons.css');
|
||||
}
|
||||
|
||||
public function addBootstrapJs(): void {
|
||||
$this->addJs('/assets/js/bootstrap.bundle.min.js');
|
||||
}
|
||||
|
||||
public function addThemeCss(): void {
|
||||
$this->addCss('/assets/css/style.css');
|
||||
$this->addCss('/assets/css/mobile.css');
|
||||
}
|
||||
|
||||
public function addAppJs(): void {
|
||||
$this->addJs('/assets/js/app.js');
|
||||
}
|
||||
|
||||
public function renderCss(): string {
|
||||
$html = '';
|
||||
foreach ($this->css as $path) {
|
||||
$fullPath = $_SERVER['DOCUMENT_ROOT'] . $path;
|
||||
$version = file_exists($fullPath) ? filemtime($fullPath) : time();
|
||||
$html .= "<link rel=\"stylesheet\" href=\"$path?v=$version\">\n";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function renderJs(): string {
|
||||
$html = '';
|
||||
foreach ($this->js as $path) {
|
||||
$fullPath = $_SERVER['DOCUMENT_ROOT'] . $path;
|
||||
$version = file_exists($fullPath) ? filemtime($fullPath) : time();
|
||||
$html .= "<script src=\"$path?v=$version\"></script>\n";
|
||||
}
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function getCssCount(): int {
|
||||
return count($this->css);
|
||||
}
|
||||
|
||||
public function getJsCount(): int {
|
||||
return count($this->js);
|
||||
}
|
||||
|
||||
public function clear(): void {
|
||||
$this->css = [];
|
||||
$this->js = [];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user