Frontend, Bugfixes
This commit is contained in:
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace Elements;
|
||||
|
||||
use View;
|
||||
|
||||
abstract class Body extends View {
|
||||
public function __construct($document) {
|
||||
parent::__construct($document);
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
namespace Elements;
|
||||
|
||||
use View;
|
||||
|
||||
abstract class Head extends View {
|
||||
|
||||
protected array $sources;
|
||||
@@ -47,7 +45,7 @@ abstract class Head extends View {
|
||||
public function addKeywords($keywords) { array_merge($this->keywords, $keywords); }
|
||||
public function getTitle() { return $this->title; }
|
||||
|
||||
public function addCSS($href, $type = Link::MIME_TEXT_CSS) { $this->sources[] = new Link("stylesheet", $href, $type); }
|
||||
public function addCSS($href, $type = Link::MIME_TEXT_CSS) { $this->sources[] = new Link(Link::STYLESHEET, $href, $type); }
|
||||
public function addStyle($style) { $this->sources[] = new Style($style); }
|
||||
public function addJS($url) { $this->sources[] = new Script(Script::MIME_TEXT_JAVASCRIPT, $url, ""); }
|
||||
public function addJSCode($code) { $this->sources[] = new Script(Script::MIME_TEXT_JAVASCRIPT, "", $code); }
|
||||
|
||||
@@ -2,29 +2,16 @@
|
||||
|
||||
namespace Elements;
|
||||
|
||||
use View;
|
||||
|
||||
class Link extends View {
|
||||
class Link extends StaticView {
|
||||
|
||||
const STYLESHEET = "stylesheet";
|
||||
const MIME_TEXT_CSS = "text/css";
|
||||
|
||||
const FONTAWESOME = '/css/fontawesome.min.css';
|
||||
// const JQUERY_UI = '/css/jquery-ui.css';
|
||||
// const JQUERY_TERMINAL = '/css/jquery.terminal.min.css';
|
||||
const BOOTSTRAP = '/css/bootstrap.min.css';
|
||||
// const BOOTSTRAP_THEME = '/css/bootstrap-theme.min.css';
|
||||
// const BOOTSTRAP_DATEPICKER_CSS = '/css/bootstrap-datepicker.standalone.min.css';
|
||||
// const BOOTSTRAP_DATEPICKER3_CSS = '/css/bootstrap-datepicker.standalone.min.css';
|
||||
// const HIGHLIGHT = '/css/highlight.css';
|
||||
// const HIGHLIGHT_THEME = '/css/theme.css';
|
||||
const CORE = "/css/style.css";
|
||||
const ADMIN = "/css/admin.css";
|
||||
// const HOME = "/css/home.css";
|
||||
// const REVEALJS = "/css/reveal.css";
|
||||
// const REVEALJS_THEME_MOON = "/css/reveal_moon.css";
|
||||
// const REVEALJS_THEME_BLACK = "/css/reveal_black.css";
|
||||
const ADMINLTE = "/css/adminlte.min.css";
|
||||
const FONTAWESOME = "/css/fontawesome.min.css";
|
||||
const BOOTSTRAP = "/css/bootstrap.min.css";
|
||||
const CORE = "/css/style.css";
|
||||
const ADMIN = "/css/admin.css";
|
||||
const ADMINLTE = "/css/adminlte.min.css";
|
||||
|
||||
private string $type;
|
||||
private string $rel;
|
||||
|
||||
@@ -2,37 +2,16 @@
|
||||
|
||||
namespace Elements;
|
||||
|
||||
class Script extends \View {
|
||||
class Script extends StaticView {
|
||||
|
||||
const MIME_TEXT_JAVASCRIPT = "text/javascript";
|
||||
|
||||
const CORE = "/js/script.js";
|
||||
// const HOME = "/js/home.js";
|
||||
const ADMIN = "/js/admin.js";
|
||||
// const SORTTABLE = "/js/sorttable.js";
|
||||
const JQUERY = "/js/jquery.min.js";
|
||||
// const JQUERY_UI = "/js/jquery-ui.js";
|
||||
// const JQUERY_MASKED_INPUT = "/js/jquery.maskedinput.min.js";
|
||||
// const JQUERY_CONTEXT_MENU = "/js/jquery.contextmenu.min.js";
|
||||
// const JQUERY_TERMINAL = "/js/jquery.terminal.min.js";
|
||||
// const JQUERY_TERMINAL_UNIX = "/js/unix_formatting.js";
|
||||
// const JSCOLOR = "/js/jscolor.min.js";
|
||||
// const SYNTAX_HIGHLIGHTER = "/js/syntaxhighlighter.js";
|
||||
// const HIGHLIGHT = "/js/highlight.pack.js";
|
||||
// const GOOGLE_CHARTS = "/js/loader.js";
|
||||
// const BOOTSTRAP = "/js/bootstrap.min.js";
|
||||
// const BOOTSTRAP_DATEPICKER_JS = "/js/bootstrap-datepicker.min.js";
|
||||
// const POPPER = "/js/popper.min.js";
|
||||
// const JSMPEG = "/js/jsmpeg.min.js";
|
||||
// const MOMENT = "/js/moment.min.js";
|
||||
// const CHART = "/js/chart.js";
|
||||
// const REVEALJS = "/js/reveal.js";
|
||||
// const REVEALJS_PLUGIN_NOTES = "/js/reveal_notes.js";
|
||||
const INSTALL = "/js/install.js";
|
||||
const CORE = "/js/script.js";
|
||||
const ADMIN = "/js/admin.js";
|
||||
const JQUERY = "/js/jquery.min.js";
|
||||
const INSTALL = "/js/install.js";
|
||||
const BOOTSTRAP = "/js/bootstrap.bundle.min.js";
|
||||
|
||||
const HIGHLIGHT_JS_LOADER = "\$(document).ready(function(){\$('code').each(function(i, block) { hljs.highlightBlock(block); }); })";
|
||||
const ADMINLTE = "/js/adminlte.min.js";
|
||||
const ADMINLTE = "/js/adminlte.min.js";
|
||||
|
||||
private string $type;
|
||||
private string $content;
|
||||
|
||||
9
core/Elements/StaticView.class.php
Normal file
9
core/Elements/StaticView.class.php
Normal file
@@ -0,0 +1,9 @@
|
||||
<?php
|
||||
|
||||
namespace Elements;
|
||||
|
||||
abstract class StaticView {
|
||||
|
||||
public abstract function getCode();
|
||||
|
||||
}
|
||||
@@ -2,9 +2,7 @@
|
||||
|
||||
namespace Elements;
|
||||
|
||||
use View;
|
||||
|
||||
class Style extends View {
|
||||
class Style extends StaticView {
|
||||
|
||||
private string $style;
|
||||
|
||||
|
||||
120
core/Elements/View.class.php
Normal file
120
core/Elements/View.class.php
Normal file
@@ -0,0 +1,120 @@
|
||||
<?php
|
||||
|
||||
namespace Elements;
|
||||
|
||||
abstract class View extends StaticView {
|
||||
|
||||
private Document $document;
|
||||
private bool $loadView;
|
||||
protected bool $searchable;
|
||||
protected string $reference;
|
||||
protected string $title;
|
||||
protected array $langModules;
|
||||
|
||||
public function __construct(Document $document, $loadView = true) {
|
||||
$this->document = $document;
|
||||
$this->searchable = false;
|
||||
$this->reference = "";
|
||||
$this->title = "Untitled View";
|
||||
$this->langModules = array();
|
||||
$this->loadView = $loadView;
|
||||
}
|
||||
|
||||
public function getTitle() { return $this->title; }
|
||||
public function __toString() { return $this->getCode(); }
|
||||
public function getDocument() { return $this->document; }
|
||||
public function isSearchable() { return $this->searchable; }
|
||||
public function getReference() { return $this->reference; }
|
||||
|
||||
private function loadLanguageModules() {
|
||||
$lang = $this->document->getUser()->getLanguage();
|
||||
foreach($this->langModules as $langModule) {
|
||||
$lang->loadModule($langModule);
|
||||
}
|
||||
}
|
||||
|
||||
// Virtual Methods
|
||||
public function loadView() { }
|
||||
|
||||
public function getCode() {
|
||||
|
||||
// Load translations
|
||||
$this->loadLanguageModules();
|
||||
|
||||
// Load Meta Data + Head (title, scripts, includes, ...)
|
||||
if($this->loadView) {
|
||||
$this->loadView();
|
||||
}
|
||||
|
||||
return '';
|
||||
}
|
||||
|
||||
// UI Functions
|
||||
private function createList($items, $tag) {
|
||||
if(count($items) === 0)
|
||||
return "<$tag></$tag>";
|
||||
else
|
||||
return "<$tag><li>" . implode("</li><li>", $items) . "</li></$tag>";
|
||||
}
|
||||
|
||||
public function createOrderedList($items=array()) {
|
||||
return $this->createList($items, "ol");
|
||||
}
|
||||
|
||||
public function createUnorderedList($items=array()) {
|
||||
return $this->createList($items, "ul");
|
||||
}
|
||||
|
||||
protected function createLink($link, $title=null) {
|
||||
if(is_null($title)) $title=$link;
|
||||
return "<a href=\"$link\">$title</a>";
|
||||
}
|
||||
|
||||
protected function createExternalLink($link, $title=null) {
|
||||
if(is_null($title)) $title=$link;
|
||||
return "<a href=\"$link\" target=\"_blank\" class=\"external\">$title</a>";
|
||||
}
|
||||
|
||||
protected function createIcon($icon, $type = "fas", $classes = "") {
|
||||
$iconClass = "$type fa-$icon";
|
||||
|
||||
if($icon === "spinner")
|
||||
$iconClass .= " fa-spin";
|
||||
|
||||
if($classes)
|
||||
$iconClass .= " $classes";
|
||||
|
||||
return "<i class=\"$iconClass\"></i>";
|
||||
}
|
||||
|
||||
protected function createErrorText($text, $id="", $hidden=false) {
|
||||
return $this->createStatusText("danger", $text, $id, $hidden);
|
||||
}
|
||||
|
||||
protected function createWarningText($text, $id="", $hidden=false) {
|
||||
return $this->createStatusText("warning", $text, $id, $hidden);
|
||||
}
|
||||
|
||||
protected function createSuccessText($text, $id="", $hidden=false) {
|
||||
return $this->createStatusText("success", $text, $id, $hidden);
|
||||
}
|
||||
|
||||
protected function createSecondaryText($text, $id="", $hidden=false) {
|
||||
return $this->createStatusText("secondary", $text, $id, $hidden);
|
||||
}
|
||||
|
||||
protected function createInfoText($text, $id="", $hidden=false) {
|
||||
return $this->createStatusText("info", $text, $id, $hidden);
|
||||
}
|
||||
|
||||
protected function createStatusText($type, $text, $id="", $hidden=false) {
|
||||
if(strlen($id) > 0) $id = " id=\"$id\"";
|
||||
$hidden = ($hidden?" hidden" : "");
|
||||
return "<div class=\"alert alert-$type$hidden\" role=\"alert\"$id>$text</div>";
|
||||
}
|
||||
|
||||
protected function createBadge($type, $text) {
|
||||
$text = htmlspecialchars($text);
|
||||
return "<span class=\"badge badge-$type\">$text</span>";
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user