Skip to content

Commit

Permalink
Merge pull request #22 from mjamilasfihani/development
Browse files Browse the repository at this point in the history
Release v1.2.0
  • Loading branch information
mjamilasfihani authored Jul 10, 2021
2 parents 6e48b35 + 685c7d0 commit 4a9a309
Showing 1 changed file with 34 additions and 29 deletions.
63 changes: 34 additions & 29 deletions app/Libraries/AssetsLoader.php
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
<?php

// Latest Version : 1.1.0

/**
* MIT License
*
Expand Down Expand Up @@ -31,8 +29,8 @@
/**
* Prototype
*
* $css = ['https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.css'];
* $js = ['https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.js'];
* $css = ['https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css'];
* $js = ['https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js'];
* $jquery = 'https://code.jquery.com/jquery-3.6.0.min.js';
*
* $template = new \App\Libraries\AssetsLoader($css, $js, $jquery);
Expand Down Expand Up @@ -78,6 +76,13 @@
class AssetsLoader
{

/**
* Assets Loader Version
*
* @var const VERSION
*/
const VERSION = '1.2.0';

/**
* Default CSS
*
Expand All @@ -86,7 +91,7 @@ class AssetsLoader
*
* @var array | empty
*/
protected $css = ['https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.css'];
protected $css = ['https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css'];

/**
* Default JS
Expand All @@ -96,7 +101,7 @@ class AssetsLoader
*
* @var array | empty
*/
protected $js = ['https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.js'];
protected $js = ['https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/js/bootstrap.bundle.min.js'];

/**
* Default jQuery
Expand Down Expand Up @@ -240,12 +245,12 @@ class AssetsLoader
protected $meta =
[
'description' => '',
'keywords' => [],
'author' => '',
'viewport' => 'width=device-width, initial-scale=1, shrink-to-fit=no',
'keywords' => [],
'author' => '',
'viewport' => 'width=device-width, initial-scale=1, shrink-to-fit=no',

'http-equiv' => [],
'property' => []
'http-equiv' => [],
'property' => []
];

/**
Expand Down Expand Up @@ -305,37 +310,37 @@ protected function __header()
{
$str = doctype($this->doctype) . '<html lang="' . $this->language . '"><head><meta charset="' . $this->charset . '">';

if (empty($this->_metaFilterName($this->meta)) === false)
if (empty($meta = $this->_metaFilterName($this->meta)) === false)
{
foreach ($this->_metaFilterName($this->meta) as $name => $value)
foreach ($meta as $name => $value)
{
$str .= $this->_metaTagGenerator($name, $value);
}
}

if (empty($this->meta['http-equiv']) === false)
if (empty($meta = $this->meta['http-equiv']) === false)
{
foreach ($this->meta['http-equiv'] as $name => $value)
foreach ($meta as $name => $value)
{
$str .= $this->_metaTagGenerator($name, $value, 'http-equiv');
}
}

if (empty($this->meta['property']) === false)
if (empty($meta = $this->meta['property']) === false)
{
foreach ($this->meta['property'] as $name => $value)
foreach ($meta as $name => $value)
{
$str .= $this->_metaTagGenerator($name, $value, 'property');
}
}

$str .= link_tag($this->favicon, 'icon', mime_content_type(basename($this->favicon)));

if (empty($this->css) === false)
if (empty($css = $this->css) === false)
{
for ($i = 0; $i < count($this->css); $i++)
for ($i = 0; $i < count($css); $i++)
{
$str .= link_tag($this->css[$i]);
$str .= link_tag($css[$i]);
}
}

Expand All @@ -344,11 +349,11 @@ protected function __header()
$str .= script_tag($this->jquery);
}

if (empty($this->js) === false)
if (empty($js = $this->js) === false)
{
for ($i = 0; $i < count($this->js); $i++)
for ($i = 0; $i < count($js); $i++)
{
$str .= script_tag($this->js[$i]);
$str .= script_tag($js[$i]);
}
}

Expand Down Expand Up @@ -444,8 +449,8 @@ protected function _metaFilterName(array $meta = [])
*/
public function body(array $config = [])
{
$this->attributes = $config['attributes'] ?? $this->attributes;
$this->preload = $config['preload'] ?? $this->preload;
$this->attributes = $config['attributes'] ?? $this->attributes;
$this->preload = $config['preload'] ?? $this->preload;
$this->cookieBannerURI = $config['cookieBannerURI'] ?? $this->cookieBannerURI;
}

Expand All @@ -456,11 +461,11 @@ public function body(array $config = [])
*/
public function html(array $config = [])
{
$this->doctype = $config['doctype'] ?? $this->doctype;
$this->charset = $config['charset'] ?? $this->charset;
$this->doctype = $config['doctype'] ?? $this->doctype;
$this->charset = $config['charset'] ?? $this->charset;
$this->language = $config['language'] ?? $this->language;
$this->title = $config['title'] ?? $this->title;
$this->favicon = $config['favicon'] ?? $this->favicon;
$this->title = $config['title'] ?? $this->title;
$this->favicon = $config['favicon'] ?? $this->favicon;
}

/**
Expand Down

0 comments on commit 4a9a309

Please sign in to comment.