Skip to content

Commit

Permalink
Merge pull request #226 from templaza/developer
Browse files Browse the repository at this point in the history
Version 2.6.3
  • Loading branch information
sonvnn authored Dec 6, 2022
2 parents 5421c7e + f351448 commit a73e058
Show file tree
Hide file tree
Showing 13 changed files with 72 additions and 53 deletions.
4 changes: 2 additions & 2 deletions astroid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
<name>Astroid Framework</name>
<libraryname>astroid</libraryname>
<author>JoomDev/TemPlaza</author>
<creationDate>October 2022</creationDate>
<version>2.6.2</version>
<creationDate>December 2022</creationDate>
<version>2.6.3</version>
<url>https://astroidframe.work/</url>
<copyright>Copyright (C) 2022 TemPlaza, Inc. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see LICENSE.txt</license>
Expand Down
4 changes: 2 additions & 2 deletions astroid_framework.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<updates>
<update>
<name>Astroid Framework</name>
<version>2.6.2</version>
<version>2.6.3</version>
<infourl title="Astroid Framework">https://astroidframe.work/</infourl>
<element>astroid</element>
<type>library</type>
<client>0</client>
<downloads>
<downloadurl type="full" format="zip">https://github.com/templaza/astroid-framework/releases/download/v2.6.2/astroid-framework-2.6.2.zip</downloadurl>
<downloadurl type="full" format="zip">https://github.com/templaza/astroid-framework/releases/download/v2.6.3/astroid-framework-2.6.3.zip</downloadurl>
</downloads>
<tags>
<tag>stable</tag>
Expand Down
12 changes: 6 additions & 6 deletions framework/frontend/header/stacked.php
Original file line number Diff line number Diff line change
Expand Up @@ -257,14 +257,14 @@
// header block starts
if ($block_1_type == 'position') {
echo '<div class="d-none d-lg-flex w-100 justify-content-end py-2 align-items-center">';
echo '<div class="d-flex w-100 justify-content-end header-block-item">';
echo '<div class="d-flex w-100 justify-content-end header-block-item align-items-center">';
echo $document->position($block_1_position, 'xhtml');
echo '</div>';
echo '</div>';
}
if ($block_1_type == 'custom') {
echo '<div class="d-none d-lg-flex w-100 justify-content-end py-2 align-items-center">';
echo '<div class="d-flex w-100 justify-content-end header-block-item">';
echo '<div class="d-flex w-100 justify-content-end header-block-item align-items-center">';
echo $block_1_custom;
echo '</div>';
echo '</div>';
Expand All @@ -291,15 +291,15 @@
// header nav ends
// header block starts
if ($block_2_type == 'position') {
echo '<div class="d-flex justify-content-end py-3 align-items-center">';
echo '<div class="header-block-item">';
echo '<div class="d-flex justify-content-end py-3">';
echo '<div class="d-flex align-items-center header-block-item">';
echo $document->position($block_2_position, 'xhtml');
echo '</div>';
echo '</div>';
}
if ($block_2_type == 'custom') {
echo '<div class="d-flex justify-content-end py-3 align-items-center">';
echo '<div class="header-block-item">';
echo '<div class="d-flex justify-content-end py-3">';
echo '<div class="d-flex align-items-center header-block-item">';
echo $block_2_custom;
echo '</div>';
echo '</div>';
Expand Down
24 changes: 15 additions & 9 deletions framework/frontend/header/sticky.php
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
$enable_offcanvas = $params->get('enable_offcanvas', FALSE);
$offcanvas_animation = $params->get('offcanvas_animation', 'st-effect-1');
$offcanvas_direction = $params->get('offcanvas_direction', 'offcanvasDirLeft');
$offcanvas_position = $params->get('offcanvas_position', 'offcanvasRight');
$offcanvas_togglevisibility = $params->get('offcanvas_togglevisibility', 'd-block');
$class = ['astroid-header', 'astroid-header-sticky'];
$stickyheader = $params->get('stickyheader', 'static');
Expand All @@ -30,7 +31,7 @@
$stickyheadertablet = $params->get('stickyheadertablet', 'static');
$class[] = 'header-' . $stickyheadertablet . '-tablet';
$navClass = ['nav', 'astroid-nav', 'd-none', 'd-lg-flex'];
$navWrapperClass = ['astroid-nav-wraper', 'align-self-center', 'px-2', 'd-none', 'd-lg-block'];
$navWrapperClass = ['astroid-nav-wraper', 'align-self-center', 'px-3', 'd-none', 'd-lg-block'];
$mode = $params->get('header_horizontal_menu_mode', 'left');
$stickey_mode = $params->get('stickey_horizontal_menu_mode', 'left');
$block_1_type = $params->get('stickey_block_1_type', 'left');
Expand Down Expand Up @@ -59,6 +60,11 @@
</div>
<?php } ?>
<div class="header-left-section d-flex justify-content-start<?php echo $stickey_mode == 'left' ? ' flex-lg-grow-1' : ''; ?>">
<?php if ($enable_offcanvas && $offcanvas_position === 'offcanvasLeft') { ?>
<?php echo '<div class="d-none d-lg-flex me-4 offcanvas-button '.$offcanvas_position.'">'; ?>
<?php $document->include('offcanvas.trigger', ['offcanvas' => '#astroid-offcanvas', 'visibility' => $offcanvas_togglevisibility, 'effect' => $offcanvas_animation, 'direction' => $offcanvas_direction]); ?>
<?php echo '</div>'; ?>
<?php } ?>
<?php $document->include('logo'); ?>
<?php
if ($stickey_mode == 'left') {
Expand Down Expand Up @@ -89,27 +95,27 @@
// header nav ends
}
?>
<?php if ($enable_offcanvas) { ?>
<?php echo '<div class="d-flex ms-3 offcanvas-button offcanvasRight">'; ?>
<?php $document->include('offcanvas.trigger', ['offcanvas' => '#astroid-offcanvas', 'visibility' => $offcanvas_togglevisibility, 'effect' => $offcanvas_animation, 'direction' => $offcanvas_direction]); ?>
<?php echo '</div>'; ?>
<?php } ?>
<?php if ($block_1_type != 'blank') : ?>
<div class="header-right-block d-none d-lg-block align-self-center px-2">
<div class="header-right-block d-none d-lg-block align-self-center">
<?php
if ($block_1_type == 'position') {
echo '<div class="header-block-item">';
echo '<div class="header-block-item d-flex">';
echo $document->position($block_1_position, 'xhtml');
echo '</div>';
}
if ($block_1_type == 'custom') {
echo '<div class="header-block-item">';
echo '<div class="header-block-item d-flex">';
echo $block_1_custom;
echo '</div>';
}
?>
</div>
<?php endif; ?>
<?php if ($enable_offcanvas) { ?>
<?php echo '<div class="'.($offcanvas_position === 'offcanvasRight' ? 'd-flex' : 'd-lg-none d-flex').' ms-4 offcanvas-button offcanvasRight">'; ?>
<?php $document->include('offcanvas.trigger', ['offcanvas' => '#astroid-offcanvas', 'visibility' => $offcanvas_togglevisibility, 'effect' => $offcanvas_animation, 'direction' => $offcanvas_direction]); ?>
<?php echo '</div>'; ?>
<?php } ?>
</div>
<?php endif; ?>
</div>
Expand Down
2 changes: 1 addition & 1 deletion framework/layouts/manager/templates.php
Original file line number Diff line number Diff line change
Expand Up @@ -36,5 +36,5 @@
$column_sizes = ['inherit', '1', '2', '3', '4', '5', '6', '7', '8', '9', '10', '11', '12'];
?>
<script type="text/ng-template" id="column-responsive-field-template">
<table class="table table-bordered"><tr><th width="30%"></th><th class="" width="30%"><?php echo JText::_('ASTROID_COLUMN_SIZE_LABEL'); ?></th><th class="" width="30%"><?php echo JText::_('TPL_ASTROID_VISIBILITY_LABEL'); ?></th></tr><?php foreach ($screen_sizes as $key => $screen_size) { ?><tr><td class=""><p class="mb-0 h4 font-weight-normal"><strong><?php echo $screen_size['label']; ?></strong></p><p class="text-muted mb-0"><code><?php echo $screen_size['info']; ?></code></p></td><td class="align-middle"><select <?php echo ($key == "lg" ? 'readonly disabled' : ''); ?> data-name="size_<?php echo $key; ?>" class="responsive-field form-control"><?php foreach ($column_sizes as $column_size) { ?><option<?php echo $column_size == 'inherit' ? ' selected' : ''; ?> value="<?php echo $column_size; ?>"><?php echo (($column_size == 'inherit' || $column_size == 'col') ? '' : 'col-' . $key . '-') . $column_size; ?></option><?php } ?></select></td><td class="align-middle"><div class="jd-ui"><div class="d-inline-block"><input checked type="checkbox" data-name="hide_<?php echo $key; ?>" id="visible-<?php echo $key; ?>" class="responsive-field jd-switch" /><label class="jd-switch-btn m-0" for="visible-<?php echo $key; ?>"></label></div></div></td></tr><?php } ?></table>
<table class="table table-bordered"><tr><th width="30%"></th><th class="" width="30%"><?php echo JText::_('ASTROID_COLUMN_SIZE_LABEL'); ?></th><th class="" width="30%"><?php echo JText::_('TPL_ASTROID_VISIBILITY_LABEL'); ?></th></tr><?php foreach ($screen_sizes as $key => $screen_size) { ?><tr><td class=""><p class="mb-0 h4 font-weight-normal"><strong><?php echo $screen_size['label']; ?></strong></p><p class="text-muted mb-0"><code><?php echo $screen_size['info']; ?></code></p></td><td class="align-middle"><select data-name="size_<?php echo $key; ?>" class="responsive-field form-control"><?php foreach ($column_sizes as $column_size) { ?><option<?php echo $column_size == 'inherit' ? ' selected' : ''; ?> value="<?php echo $column_size; ?>"><?php echo (($column_size == 'inherit' || $column_size == 'col') ? '' : 'col-' . $key . '-') . $column_size; ?></option><?php } ?></select></td><td class="align-middle"><div class="jd-ui"><div class="d-inline-block"><input checked type="checkbox" data-name="hide_<?php echo $key; ?>" id="visible-<?php echo $key; ?>" class="responsive-field jd-switch" /><label class="jd-switch-btn m-0" for="visible-<?php echo $key; ?>"></label></div></div></td></tr><?php } ?></table>
</script>
1 change: 1 addition & 0 deletions framework/library/astroid/Admin.php
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ protected function manager()
$form->loadOptions(JPATH_LIBRARIES . '/astroid/framework/options');
Helper::triggerEvent('onBeforeAstroidTemplateFormLoad', [&$template, &$form]);
$form->loadOptions(ASTROID_TEMPLATE_PATH . '/astroid/options');
$form->loadOptions(ASTROID_MEDIA_TEMPLATE_PATH . '/astroid/options');
Helper::triggerEvent('onAfterAstroidTemplateFormLoad', [&$template, &$form]);
Framework::getDebugger()->log('Loading Forms');

Expand Down
8 changes: 6 additions & 2 deletions framework/library/astroid/Component/Includer.php
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,12 @@ public static function run($content = null)
$includers = array_reverse($includers);

foreach ($includers as $includer) {
$func = $includer['func'];
$body = ($includer['replace'] && self::$func()) ? str_replace($includer['replace'], self::$func(), $body) : $body;
$func = $includer['func'];
$func_content = self::$func();
if (!is_string($func_content)) {
$func_content = '';
}
$body = ($includer['replace']) ? str_replace($includer['replace'], $func_content, $body) : $body;
}

if ($content === null) {
Expand Down
12 changes: 8 additions & 4 deletions framework/library/astroid/Component/Menu.php
Original file line number Diff line number Diff line change
Expand Up @@ -124,10 +124,14 @@ public static function getMenu($menutype = '', $nav_class = [], $logo = null, $l
// The next item is shallower.
elseif ($item->shallower) {
echo '</li>';
if ($item->level == 1 && $item->parent) {
echo str_repeat('</ul></div>' . '</li>', $item->level_diff);
} else {
echo str_repeat('</ul>' . '</li>', $item->level_diff);
$l = $item->level;
for ($i = 0; $i < $item->level_diff; $i++) {
if ($l > 2) {
echo '</ul>' . '</li>';
} else {
echo '</ul></div>' . '</li>';
}
$l--;
}
}
// The next item is on the same level.
Expand Down
26 changes: 17 additions & 9 deletions framework/library/astroid/Document.php
Original file line number Diff line number Diff line change
Expand Up @@ -215,14 +215,17 @@ public function minifyCSS($html)
{
Framework::getDebugger()->log('Minifying CSS');
$stylesheets = [];
$stylesheetLinks = [];
$stylesheetsUrls = [];
$html = preg_replace_callback('/(<link\s[^>]*href=")([^"]*)("[^>][^>]*rel=")([^"]*)("[^>]*\/>)/siU', function ($matches) use (&$stylesheets, &$stylesheetsUrls) {

$html = preg_replace_callback('/(<link\s[^>]*href=")([^"]*)("[^>][^>]*rel=")([^"]*)("[^>]*\/>)/siU', function ($matches) use (&$stylesheetLinks, &$stylesheetsUrls) {
if (isset($matches[4]) && $matches[4] === 'stylesheet') {
if (strpos($matches[2], 'fonts.googleapis.com') > 0) {
return $matches[0];
}
$url = $this->_cssPath($matches[2]);
$ext = pathinfo($url, PATHINFO_EXTENSION);
if ($ext !== 'css' && !Helper::startsWith($url, '@import')) return $matches[0];
$stylesheets[] = $url;
$stylesheetLinks[] = $url;
$stylesheetsUrls[] = $this->beutifyURL($matches[2]);
return '';
}
Expand All @@ -248,10 +251,15 @@ public function minifyCSS($html)
Framework::getReporter('Logs')->add('Minify &amp; Combine Files <code>' . implode('</code>, <code>', $stylesheetsUrls) . '</code>.');
Helper::putContents($cssFile, '');
$minifier = new Minify\CSS($cssFile);
foreach ($stylesheets as $stylesheet) {
if (file_exists(JPATH_SITE . '/' . $stylesheet)) {
$minifier->add(JPATH_SITE . '/' . $stylesheet);
} else {
if (count($stylesheetLinks)) {
foreach ($stylesheetLinks as $stylesheet) {
if (file_exists(JPATH_SITE . '/' . $stylesheet)) {
$minifier->add(JPATH_SITE . '/' . $stylesheet);
}
}
}
if (count($stylesheets)) {
foreach ($stylesheets as $stylesheet) {
$minifier->add($stylesheet);
}
}
Expand All @@ -277,7 +285,7 @@ public function minifyJS($html)
// print_r($matches);
$script = [];
if (isset($matches[5]) && $matches[5] == '</script>' && !empty($matches[2])) {
if (strpos($matches[0], 'type="module"') > 0) {
if (strpos($matches[0], 'type="module"') > 0 || strpos($matches[0], 'media/system/js/joomla-hidden-mail-es5.min.js') > 0 || strpos($matches[0], 'webcomponents-bundle.min.js') > 0) {
return $matches[0];
}
$script = ['content' => $this->beutifyURL($matches[2]), 'type' => 'url'];
Expand Down Expand Up @@ -437,7 +445,7 @@ public function minifyHTML($html)
$rx = "#(?:(?=[^>]*+>)|<[a-z0-9]++ )"
. "(?>[=]?[^=><]*+(?:=(?:$ns1|$ns2)|>(?>[^<]*+(?:$j|$x|$nsc|$nst|<(?![a-z0-9]++ ))?)*?(?:<[a-z0-9]++ |$))?)*?"
. "(?:=\K([\"'])([^\"'`=<>\s]++)\g{1}[ ]?|\K$)#i";
$html = $this->_replace($rx, '$2 ', $html);
// $html = $this->_replace($rx, '$2 ', $html);

//Remove last whitespace in open tag
$rx = "#(?>[^<]*+(?:$j|$x|$nsc|$nst|<(?![a-z0-9]++))?)*?(?:<[a-z0-9]++(?>\s*+[^\s>]++)*?\K" . "(?:\s*+(?=>)|(?<=[\"'])\s++(?=/>))|$\K)#i";
Expand Down
2 changes: 1 addition & 1 deletion framework/library/astroid/Helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ public static function triggerEvent($name, $data = [])

public static function clearCacheByTemplate($template)
{
return self::clearCache($template, ['style', 'custom', 'astroid', 'preset', 'compiled']);
return self::clearCache($template, ['style', 'astroid', 'preset', 'compiled']);
}

public static function clearCache($template = '', $prefix = 'style')
Expand Down
2 changes: 1 addition & 1 deletion framework/library/astroid/Helper/Constants.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

class Constants
{
public static $astroid_version = '2.6.2';
public static $astroid_version = '2.6.3';
public static $fontawesome_version = '6.2.0';
public static $animatecss_version = '3.7.0';
public static $forum_link = 'https://github.com/templaza/astroid-framework/issues';
Expand Down
24 changes: 10 additions & 14 deletions framework/library/astroid/Template.php
Original file line number Diff line number Diff line change
Expand Up @@ -241,26 +241,22 @@ protected function _getPresets()
if (isset($data['thumbnail']) && !empty($data['thumbnail'])) {
$preset['thumbnail'] = \JURI::root() . 'templates/' . $this->template . '/' . $data['thumbnail'];
}
if (isset($data['colors'])) {
$colors = [];
$properties = [];
foreach ($data['colors'] as $prop => $color) {
if (is_array($color)) {
foreach ($color as $subprop => $color2) {
if (!empty($color2)) {
$properties[$prop][$subprop] = $color2;
$colors[] = $color2;
if (isset($data['preset'])) {
$properties = [];
$preset_data= \json_decode($data['preset'], true);
foreach ($preset_data as $prop => $value) {
if (is_array($value)) {
foreach ($value as $subprop => $value2) {
if (!empty($value2)) {
$properties[$prop][$subprop] = $value2;
}
}
} else {
if (!empty($color)) {
$properties[$prop] = $color;
$colors[] = $color;
if (!empty($value)) {
$properties[$prop] = $value;
}
}
}
$colors = array_keys(array_count_values($colors));
$preset['colors'] = array_unique($colors);
$preset['preset'] = $properties;
}
$presets[$preset['name']] = $preset;
Expand Down
4 changes: 2 additions & 2 deletions plugins/astroid/astroid.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@
<extension version="3.1" type="plugin" method="upgrade" group="system">
<name>Astroid Plugin</name>
<author>JoomDev/TemPlaza</author>
<creationDate>September 2022</creationDate>
<version>2.6.2</version>
<creationDate>December 2022</creationDate>
<version>2.6.3</version>
<url>https://www.astroidframe.work</url>
<copyright>Copyright (C) 2022 TemPlaza, Inc. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see LICENSE.txt</license>
Expand Down

0 comments on commit a73e058

Please sign in to comment.