1
0
mirror of https://github.com/typemill/typemill.git synced 2025-08-01 11:50:28 +02:00

latest 20171218

This commit is contained in:
Sebastian
2017-12-18 10:20:36 +01:00
parent 4cb743c2ae
commit 5fa14fb838
18 changed files with 175 additions and 115 deletions

View File

@@ -17,15 +17,14 @@ class Assets
public function addCSS(string $CSS)
{
$CSSpath = __DIR__ . '/../plugins' . $CSS;
if(file_exists($CSSfile))
$CSSfile = $this->getFileUrl($CSS);
if($CSSfile)
{
$CSSfile = $this->baseUrl . '/plugins' . $CSS;
$this->CSS[] = '<link rel="stylesheet" href="' . $CSSfile . '" />';
}
}
public function addInlineCSS($CSS)
{
$this->inlineCSS[] = '<style>' . $CSS . '</style>';
@@ -33,11 +32,10 @@ class Assets
public function addJS(string $JS)
{
$JSpath = __DIR__ . '/../plugins' . $JS;
$JSfile = $this->getFileUrl($JS);
if(file_exists($JSpath))
if($JSfile)
{
$JSfile = $this->baseUrl . '/plugins' . $JS;
$this->JS[] = '<script src="' . $JSfile . '"></script>';
}
}
@@ -56,4 +54,26 @@ class Assets
{
return implode('<br/>', $this->JS) . implode('<br/>', $this->inlineJS);
}
/**
* Checks, if a string is a valid internal or external ressource like js-file or css-file
* @params $path string
* @return string or false
*/
public function getFileUrl(string $path)
{
$internalFile = __DIR__ . '/../plugins' . $path;
if(file_exists($internalFile))
{
return $this->baseUrl . '/plugins' . $path;
}
if(fopen($path, "r"))
{
return $path;
}
return false;
}
}