From f00933754c20801c8dd07bfd4b78e72b94c63756 Mon Sep 17 00:00:00 2001 From: Sonny Le Date: Fri, 26 Jul 2024 09:17:27 +0700 Subject: [PATCH 01/50] Improve Semantic of HTML --- framework/library/astroid/Component/Menu.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/framework/library/astroid/Component/Menu.php b/framework/library/astroid/Component/Menu.php index 970be2c2..8d031562 100644 --- a/framework/library/astroid/Component/Menu.php +++ b/framework/library/astroid/Component/Menu.php @@ -61,7 +61,7 @@ public static function getMenu($menutype = '', $nav_class = [], $logo = null, $l $return = []; // Menu Wrapper - echo '
' + echo '
'; + . ''; } // Joomla Functions From 7ca901c38cb1082e10894cf7863baf7197616590 Mon Sep 17 00:00:00 2001 From: Sonny Le Date: Mon, 29 Jul 2024 12:18:09 +0700 Subject: [PATCH 02/50] Remove unnecessary code --- framework/html/com_content/category/blog_item.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/framework/html/com_content/category/blog_item.php b/framework/html/com_content/category/blog_item.php index b7c9af70..44eb2f08 100644 --- a/framework/html/com_content/category/blog_item.php +++ b/framework/html/com_content/category/blog_item.php @@ -73,7 +73,7 @@ $clsItemContainer = $astroidArticle->getStyle('container'); $clsItemBody = $astroidArticle->getStyle('body'); ?> -
+
From 18e0b2f9ea116714244559f728a53f7134e8293b Mon Sep 17 00:00:00 2001 From: Sonny Le Date: Wed, 31 Jul 2024 12:24:55 +0700 Subject: [PATCH 03/50] Fix issue validate html when Intro Image is null --- framework/html/com_content/category/blog_item.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/framework/html/com_content/category/blog_item.php b/framework/html/com_content/category/blog_item.php index 44eb2f08..9fb01150 100644 --- a/framework/html/com_content/category/blog_item.php +++ b/framework/html/com_content/category/blog_item.php @@ -164,9 +164,11 @@
'; - echo '
'; + if (((!empty($images->image_intro)) && $post_format == 'standard') || (is_string($image) && !empty($image))) { + if (($image_position == 'left' || $image_position == 'right')) { + echo '
'; + echo ''; + } } ?> From 3731c45d9c401f5bd8f26368023631e4cd475f6a Mon Sep 17 00:00:00 2001 From: Sonny Le Date: Wed, 31 Jul 2024 14:27:08 +0700 Subject: [PATCH 04/50] Add Masonry library --- framework/library/astroid/Document.php | 101 +++++++++++++++---------- 1 file changed, 63 insertions(+), 38 deletions(-) diff --git a/framework/library/astroid/Document.php b/framework/library/astroid/Document.php index aa5f513b..4f41d9c0 100644 --- a/framework/library/astroid/Document.php +++ b/framework/library/astroid/Document.php @@ -34,6 +34,8 @@ class Document protected $minify_html = false; protected static $_fontawesome = false; protected static $_fancybox = false; + protected static $_masonry = false; + protected static $_slick = false; protected static $_layout_paths = []; protected $type = null; protected $modules = null; @@ -60,7 +62,7 @@ public function getType() return $this->type; } - public function addLayoutPath($path) + public function addLayoutPath($path): void { self::$_layout_paths[] = $path; } @@ -116,7 +118,7 @@ public function include($section, $data = [], $return = false) echo trim($content); } - public function compress() + public function compress(): void { $app = Factory::getApplication(); $body = $app->getBody(); @@ -133,7 +135,7 @@ public function compress() $app->setBody($body); } - public function isFrontendEditing() + public function isFrontendEditing(): bool { if (!Framework::isSite()) { return false; @@ -219,7 +221,7 @@ function addProtocol($url) } - public function minifyCSS($html) + public function minifyCSS($html): array|string { Framework::getDebugger()->log('Minifying CSS'); $stylesheets = []; @@ -381,7 +383,7 @@ public function minifyJS($html) return $html; } - public function minifyHTML($html) + public function minifyHTML($html): array|string|null { Framework::getDebugger()->log('Minifying HTML'); $level = Framework::getTemplate()->getParams()->get('minify_html_level', 'basic'); @@ -476,7 +478,7 @@ public function minifyHTML($html) return trim($html); } - public function _replace($rx, $replacement, $code, $callback = null) + public function _replace($rx, $replacement, $code, $callback = null): array|string|null { if ($callback === null) { return preg_replace($rx, $replacement, $code); @@ -515,7 +517,7 @@ public function _minifyAssets($m) return $m[0]; } - private function _assetsHash() + private function _assetsHash(): string { $assets = []; $assets[] = \json_encode($this->_styles); @@ -529,7 +531,7 @@ private function _assetsHash() return md5(serialize($assets)); } - public function position($position, $style = 'none') + public function position($position, $style = 'none'): string { if (empty($position)) { return ''; @@ -547,7 +549,7 @@ public function position($position, $style = 'none') return $return; } - public function hasModule($position, $module) + public function hasModule($position, $module): bool { return in_array($module, array_column(ModuleHelper::getModules($position), 'module')); } @@ -582,7 +584,7 @@ public function loadModule($content) return $content; } - private function _modulePosition($position) + private function _modulePosition($position): false|string { $this->modules[$position] = ''; $document = Factory::getDocument(); @@ -599,7 +601,7 @@ private function _modulePosition($position) return $this->modules[$position]; } - private function _moduleId($id) + private function _moduleId($id): false|string { $this->modules[$id] = ''; $document = Factory::getDocument(); @@ -664,7 +666,7 @@ private function _positionLayouts() return $return; } - protected function checkDev() + protected function checkDev(): void { $params = Framework::getTemplate()->getParams(); if ($params->exists('developemnt_mode')) { @@ -675,7 +677,7 @@ protected function checkDev() $this->_dev = ($dev ? true : false); } - public function isDev() + public function isDev(): bool { if ($this->_dev === null) { $this->checkDev(); @@ -683,7 +685,7 @@ public function isDev() return $this->_dev; } - public function addMeta($name, $content, $attribs = []) + public function addMeta($name, $content, $attribs = []): void { $this->_metas[$name] = [ 'name' => $name, @@ -692,7 +694,7 @@ public function addMeta($name, $content, $attribs = []) ]; } - public function addLink($href = '', $rel = 'stylesheet', $attribs = ['type' => 'text/css']) + public function addLink($href = '', $rel = 'stylesheet', $attribs = ['type' => 'text/css']): void { $this->_links[md5($href)] = [ 'href' => $href, @@ -701,7 +703,7 @@ public function addLink($href = '', $rel = 'stylesheet', $attribs = ['type' => ' ]; } - public function renderMeta() + public function renderMeta(): string { $html = ''; foreach ($this->_metas as $meta) { @@ -720,7 +722,7 @@ public function renderMeta() return $html; } - public function renderLinks() + public function renderLinks(): string { $html = ''; foreach ($this->_links as $link) { @@ -739,7 +741,7 @@ public function renderLinks() return $html; } - public function beutifyURL($url) + public function beutifyURL($url): array|string { $url = str_replace('?' . Helper::joomlaMediaVersion(), '', $url); $url = str_replace(Uri::root(), '', $url); @@ -754,7 +756,7 @@ public function beutifyURL($url) return $url; } - public function addScript($url, $position = 'head', $options = [], $attribs = [], $type = '') + public function addScript($url, $position = 'head', $options = [], $attribs = [], $type = ''): void { if (!is_array($url)) { $url = [$url]; @@ -771,7 +773,7 @@ public function addScript($url, $position = 'head', $options = [], $attribs = [] } } - public function getScripts($position = 'head') + public function getScripts($position = 'head'): string { $html = ''; foreach ($this->_javascripts[$position] as $javascript) { @@ -783,7 +785,7 @@ public function getScripts($position = 'head') return $html; } - public function getCustomTags($position = 'head') + public function getCustomTags($position = 'head'): string { $content = ''; foreach ($this->_customtags[$position] as $tag) { @@ -792,7 +794,7 @@ public function getCustomTags($position = 'head') return $content; } - public function addScriptOptions($key, $options, $merge = true) + public function addScriptOptions($key, $options, $merge = true): static { if (empty($this->scriptOptions[$key])) { $this->scriptOptions[$key] = []; @@ -816,7 +818,7 @@ public function getScriptOptions($key = null) return $this->scriptOptions; } - protected function _systemUrl($url, $version = true) + protected function _systemUrl($url, $version = true): string { $config = Factory::getApplication()->getConfig(); $params = Helper::getPluginParams(); @@ -848,7 +850,7 @@ protected function _systemUrl($url, $version = true) return $url.$postfix ; } - public function addScriptDeclaration($content, $position = 'head', $type = 'text/javascript') + public function addScriptDeclaration($content, $position = 'head', $type = 'text/javascript'): void { if (empty($content)) { return; @@ -859,7 +861,7 @@ public function addScriptDeclaration($content, $position = 'head', $type = 'text $this->_scripts[$position][] = $script; } - public function addStyleDeclaration($content, $device = 'desktop') + public function addStyleDeclaration($content, $device = 'desktop'): void { if (empty($content)) { return; @@ -867,7 +869,7 @@ public function addStyleDeclaration($content, $device = 'desktop') $this->_styles[$device][] = trim($content); } - public function addStyleSheet($url, $attribs = ['rel' => 'stylesheet', 'type' => 'text/css'], $shifted = 0) + public function addStyleSheet($url, $attribs = ['rel' => 'stylesheet', 'type' => 'text/css'], $shifted = 0): void { if (!is_array($url)) { $url = [$url]; @@ -886,7 +888,7 @@ public function addStyleSheet($url, $attribs = ['rel' => 'stylesheet', 'type' => } } - public function addCustomTag($content, $position = 'head') + public function addCustomTag($content, $position = 'head'): void { if (empty($content)) { return; @@ -897,7 +899,7 @@ public function addCustomTag($content, $position = 'head') } } - public function loadFontAwesome() + public function loadFontAwesome(): void { if (self::$_fontawesome) { return; @@ -905,7 +907,7 @@ public function loadFontAwesome() Helper\Font::loadFontAwesome(); } - public function loadFancyBox() + public function loadFancyBox(): void { if (self::$_fancybox) { return; @@ -916,13 +918,35 @@ public function loadFancyBox() self::$_fancybox = true; } - public function moveFile(&$array, $a, $b) + public function loadMasonry(): void + { + if (!self::$_masonry) { + $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); + $wa->registerAndUseScript('masonry', 'astroid/masonry.pkgd.min.js', ['relative' => true, 'version' => 'auto'], [], ['jquery']); + self::$_masonry = true; + } + } + + public function loadSlick($obj = '', $config = ''): void + { + $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); + if (!self::$_slick) { + $wa->registerAndUseStyle('slick.css', 'astroid/slick.min.css'); + $wa->registerAndUseScript('slick.js', 'astroid/slick.min.js', ['relative' => true, 'version' => 'auto'], [], ['jquery']); + self::$_slick = true; + } + if (!empty($obj) && !empty($config)) { + $wa->addInlineScript('jQuery(document).ready(function(){jQuery(\''.$obj.'\').slick({'.$config.'})});'); + } + } + + public function moveFile(&$array, $a, $b): void { $out = array_splice($array, $a, 1); array_splice($array, $b, 0, $out); } - public function getStylesheets() + public function getStylesheets(): string { $keys = array_keys($this->_stylesheets); foreach ($keys as $index => $key) { @@ -943,7 +967,7 @@ public function getStylesheets() return $content; } - public function renderScss($path) + public function renderScss($path): void { ini_set('memory_limit', '1024M'); Framework::getDebugger()->log('Rendering Scss'); @@ -1071,7 +1095,7 @@ public function renderScss($path) Helper::putContents($path, $css->getCss()); } - public function renderCss() + public function renderCss(): string { /* if (Framework::isSite()) { $template = Framework::getTemplate(); @@ -1090,7 +1114,7 @@ public function renderCss() return $cssScript; } - public function getBodyClass($extra_class = '') + public function getBodyClass($extra_class = ''): string { $template = Framework::getTemplate(); @@ -1160,7 +1184,7 @@ public function getBodyClass($extra_class = '') return implode(' ', $class); } - public function isBuilder() + public function isBuilder(): bool { $jinput = Factory::getApplication()->input; $option = $jinput->get('option', ''); @@ -1193,7 +1217,7 @@ public static function getDir($dir, $extension = null, &$results = array()) return $results; } - public static function scssHash() + public static function scssHash(): string { $params = Helper::getPluginParams(); $debug = $params->get('astroid_debug', 0); @@ -1220,7 +1244,7 @@ public static function scssHash() return md5($name); } - public function astroidCSS() + public function astroidCSS(): void { $getPluginParams = Helper::getPluginParams(); $wa = Factory::getApplication()->getDocument()->getWebAssetManager(); @@ -1292,7 +1316,8 @@ public function astroidCustomCSS() { } } - public function astroidInlineCSS() { + public function astroidInlineCSS(): string + { // css on page $getPluginParams = Helper::getPluginParams(); $astroid_inline_css = $getPluginParams->get('astroid_inline_css', 0); From df8782dbda92e1ce5ff4763303b4b39eaea7c712 Mon Sep 17 00:00:00 2001 From: Sonny Le Date: Wed, 31 Jul 2024 15:05:09 +0700 Subject: [PATCH 05/50] Update Image Group Widget use Masonry --- framework/elements/imagegroup/imagegroup.php | 14 +++++++------- framework/elements/imagegroup/imagegroup.xml | 1 + 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/framework/elements/imagegroup/imagegroup.php b/framework/elements/imagegroup/imagegroup.php index 4c9b6746..a3421f91 100644 --- a/framework/elements/imagegroup/imagegroup.php +++ b/framework/elements/imagegroup/imagegroup.php @@ -13,7 +13,7 @@ // No direct access. defined('_JEXEC') or die; -use Joomla\CMS\Factory; +use Astroid\Framework; use Astroid\Helper\Style; extract($displayData); @@ -27,6 +27,7 @@ } $enable_slider = $params->get('enable_slider', 0); +$use_masonry = $params->get('use_masonry', 0); $slider_autoplay = $params->get('slider_autoplay', 0); $slider_nav = $params->get('slider_nav', 1); $slider_dotnav = $params->get('slider_dotnav', 0); @@ -144,7 +145,7 @@ $text_color_mode = $params->get('text_color_mode', ''); $text_color_mode = $text_color_mode !== '' ? ' ' . $text_color_mode : ''; -echo '
'; +echo '
'; foreach ($images as $image) { $image_params = Style::getSubFormParams($image->params); if (!empty($image_params['image'])) { @@ -162,10 +163,9 @@ } } echo '
'; +$document = Framework::getDocument(); if ($enable_slider) { - $mainframe = Factory::getApplication(); - $wa = $mainframe->getDocument()->getWebAssetManager(); - $wa->registerAndUseStyle('slick.css', 'astroid/slick.min.css'); - $wa->registerAndUseScript('slick.js', 'astroid/slick.min.js', ['relative' => true, 'version' => 'auto'], [], ['jquery']); - echo ''; + $document->loadSlick('#'.$element->id.' .astroid-slick', implode(',', $slide_settings)); +} elseif ($use_masonry) { + $document->loadMasonry(); } \ No newline at end of file diff --git a/framework/elements/imagegroup/imagegroup.xml b/framework/elements/imagegroup/imagegroup.xml index 79e18fe8..ec66d96f 100644 --- a/framework/elements/imagegroup/imagegroup.xml +++ b/framework/elements/imagegroup/imagegroup.xml @@ -204,6 +204,7 @@ + From dff131e29383cb7228d76e40d6b4133fbd4cbcfa Mon Sep 17 00:00:00 2001 From: Sonny Le Date: Wed, 31 Jul 2024 15:25:00 +0700 Subject: [PATCH 06/50] Update blog use Masonry --- framework/html/com_content/category/blog.php | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/framework/html/com_content/category/blog.php b/framework/html/com_content/category/blog.php index aea75265..58e7eb69 100644 --- a/framework/html/com_content/category/blog.php +++ b/framework/html/com_content/category/blog.php @@ -13,6 +13,7 @@ use Joomla\CMS\Language\Text; use Joomla\CMS\Layout\FileLayout; use Joomla\CMS\Layout\LayoutHelper; +use Astroid\Framework; $app = Factory::getApplication(); @@ -31,6 +32,13 @@ $htag = $this->params->get('show_page_heading') ? 'h2' : 'h1'; +$use_masonry = $this->params->get('use_masonry', 0); + +if ($use_masonry) { + $document = Framework::getDocument(); + $document->loadMasonry(); +} + ?>
params->get('show_page_heading')) : ?> @@ -109,7 +117,7 @@ params->get('num_columns'); ?>