2020-02-09 23:02:19 +01:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Elements;
|
|
|
|
|
2020-04-04 01:15:59 +02:00
|
|
|
class Link extends StaticView {
|
2020-02-09 23:02:19 +01:00
|
|
|
|
|
|
|
const STYLESHEET = "stylesheet";
|
|
|
|
const MIME_TEXT_CSS = "text/css";
|
|
|
|
|
2020-04-04 01:15:59 +02:00
|
|
|
const FONTAWESOME = "/css/fontawesome.min.css";
|
|
|
|
const BOOTSTRAP = "/css/bootstrap.min.css";
|
|
|
|
const CORE = "/css/style.css";
|
2020-07-02 00:47:45 +02:00
|
|
|
const ACCOUNT = "/css/account.css";
|
2020-02-09 23:02:19 +01:00
|
|
|
|
2020-04-03 15:56:04 +02:00
|
|
|
private string $type;
|
|
|
|
private string $rel;
|
|
|
|
private string $href;
|
2021-12-08 16:53:43 +01:00
|
|
|
private ?string $nonce;
|
2020-02-09 23:02:19 +01:00
|
|
|
|
|
|
|
function __construct($rel, $href, $type = "") {
|
2020-04-03 15:56:04 +02:00
|
|
|
$this->href = $href;
|
2020-02-09 23:02:19 +01:00
|
|
|
$this->type = $type;
|
|
|
|
$this->rel = $rel;
|
2021-12-08 16:53:43 +01:00
|
|
|
$this->nonce = null;
|
2020-02-09 23:02:19 +01:00
|
|
|
}
|
|
|
|
|
2021-04-02 22:47:11 +02:00
|
|
|
function getCode(): string {
|
2021-12-08 16:53:43 +01:00
|
|
|
$attributes = ["rel" => $this->rel, "href" => $this->href];
|
|
|
|
|
|
|
|
if (!empty($this->type)) {
|
|
|
|
$attributes["type"] = $this->type;
|
|
|
|
}
|
|
|
|
if (!empty($this->nonce)) {
|
|
|
|
$attributes["nonce"] = $this->nonce;
|
|
|
|
}
|
|
|
|
|
|
|
|
$attributes = html_attributes($attributes);
|
|
|
|
return "<link $attributes/>";
|
|
|
|
}
|
|
|
|
|
|
|
|
public function setNonce(string $nonce) {
|
|
|
|
$this->nonce = $nonce;
|
2020-02-09 23:02:19 +01:00
|
|
|
}
|
|
|
|
}
|