diff --git a/cg_template_switcher_changelog.xml b/cg_template_switcher_changelog.xml index 2e5c420..ec6517e 100644 --- a/cg_template_switcher_changelog.xml +++ b/cg_template_switcher_changelog.xml @@ -1,4 +1,18 @@ + + pkg_cg_template_switcher + package + 2.2.0 + + Update : 16/09/2024 + + + Switch between multiple Astroid templates + + + CGStyle plugin becomes a service provider + + pkg_cg_template_switcher package diff --git a/packages/mod_cg_template_switcher_j4.zip b/packages/mod_cg_template_switcher_j4.zip index 2351cbf..4f5d8aa 100644 Binary files a/packages/mod_cg_template_switcher_j4.zip and b/packages/mod_cg_template_switcher_j4.zip differ diff --git a/packages/mod_cg_template_switcher_j4/mod_cg_template_switcher.xml b/packages/mod_cg_template_switcher_j4/mod_cg_template_switcher.xml index aec1a5e..b402b8d 100644 --- a/packages/mod_cg_template_switcher_j4/mod_cg_template_switcher.xml +++ b/packages/mod_cg_template_switcher_j4/mod_cg_template_switcher.xml @@ -2,12 +2,12 @@ CG Template Switcher ConseilGouz - 2023-08-27 + 2024-09-16 Copyright (C) 2023 ConseilGouz. All rights reserved - http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 + https://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv2 pascal.leconte@conseilgouz.com www.conseilgouz.com - 2.1.2 + 2.2.0 CG_XML_DESCRIPTION ConseilGouz\Module\CGTemplateSwitcher https://raw.githubusercontent.com/conseilgouz/pkg_cg_template_switcher_j4/master/cg_template_switcher_changelog.xml diff --git a/packages/plg_system_cgstyle_j4.zip b/packages/plg_system_cgstyle_j4.zip index e1b531e..2894ae2 100644 Binary files a/packages/plg_system_cgstyle_j4.zip and b/packages/plg_system_cgstyle_j4.zip differ diff --git a/packages/plg_system_cgstyle_j4/cgstyle.xml b/packages/plg_system_cgstyle_j4/cgstyle.xml index c31836c..dbf897a 100644 --- a/packages/plg_system_cgstyle_j4/cgstyle.xml +++ b/packages/plg_system_cgstyle_j4/cgstyle.xml @@ -2,16 +2,19 @@ plg_system_cgstyle ConseilGouz - 2023-08-27 - (C)2023 ConseilGouz. All rights reserved. - GNU General Public License version 2 or later; see LICENSE.txt + 2024-09-16 + (C)2024 ConseilGouz. All rights reserved. + GNU General Public License version 3 or later; see LICENSE.txt pascal.leconte@conseilgouz.com www.conseilgouz.com - 2.1.2 + 2.2.0 PLG_SYSTEM_CGSTYLE_XML_DESCRIPTION + Conseilgouz\Plugin\System\Cgstyle - cgstyle.php + services + src cgstyle.xml + index.html language/en-GB/plg_system_cgstyle.ini diff --git a/packages/plg_system_cgstyle_j4/index.html b/packages/plg_system_cgstyle_j4/index.html new file mode 100644 index 0000000..2efb97f --- /dev/null +++ b/packages/plg_system_cgstyle_j4/index.html @@ -0,0 +1 @@ + diff --git a/packages/plg_system_cgstyle_j4/services/index.html b/packages/plg_system_cgstyle_j4/services/index.html new file mode 100644 index 0000000..2efb97f --- /dev/null +++ b/packages/plg_system_cgstyle_j4/services/index.html @@ -0,0 +1 @@ + diff --git a/packages/plg_system_cgstyle_j4/services/provider.php b/packages/plg_system_cgstyle_j4/services/provider.php new file mode 100644 index 0000000..4929033 --- /dev/null +++ b/packages/plg_system_cgstyle_j4/services/provider.php @@ -0,0 +1,49 @@ +set( + PluginInterface::class, + function (Container $container) { + $displatcher = $container->get(DispatcherInterface::class); + $plugin = new Cgstyle( + $displatcher, + (array) PluginHelper::getPlugin('system', 'cgstyle') + ); + $plugin->setDatabase($container->get(DatabaseInterface::class)); + $plugin->setApplication(Factory::getApplication()); + return $plugin; + } + ); + } +}; diff --git a/packages/plg_system_cgstyle_j4/cgstyle.php b/packages/plg_system_cgstyle_j4/src/Extension/Cgstyle.php similarity index 66% rename from packages/plg_system_cgstyle_j4/cgstyle.php rename to packages/plg_system_cgstyle_j4/src/Extension/Cgstyle.php index 91ea718..df8b195 100644 --- a/packages/plg_system_cgstyle_j4/cgstyle.php +++ b/packages/plg_system_cgstyle_j4/src/Extension/Cgstyle.php @@ -8,22 +8,31 @@ * @license GNU General Public License version 2 or later; see LICENSE.txt * */ - +namespace Conseilgouz\Plugin\System\Cgstyle\Extension; defined('_JEXEC') or die; use Joomla\CMS\Factory; use Joomla\CMS\Plugin\CMSPlugin; use Joomla\CMS\Version; +use Joomla\Database\DatabaseAwareTrait; +use Joomla\Event\SubscriberInterface; -class PlgSystemCGStyle extends CMSPlugin -{ - public function onAfterRoute() { +final class Cgstyle extends CMSPlugin implements SubscriberInterface { + + use DatabaseAwareTrait; + + public static function getSubscribedEvents(): array { + return [ + 'onAfterRoute' => 'afterRoute' + ]; + } + public function afterRoute() { $app= Factory::getApplication(); if ($app->isClient('administrator')) { // run only on frontend return; } $cookieValue = Factory::getApplication()->input->cookie->get('cg_template'); if ($cookieValue) { - $db = Factory::getDbo(); + $db = $this->getDatabase(); $query = $db->getQuery(true); $query->select('*'); $query->from('#__template_styles'); @@ -36,6 +45,9 @@ public function onAfterRoute() { $version=substr($j->getShortVersion(), 0,1); if ($version >= "4") { // Joomla 4 and higher $app->setTemplate( $style); + if (strpos($style->template,'astroid') === 0) { + \Astroid\Framework::getTemplate($style->id); + } }else { // Joomla 3.10 $app->setTemplate( $style->template, $style->params ); } diff --git a/packages/plg_system_cgstyle_j4/src/Extension/index.html b/packages/plg_system_cgstyle_j4/src/Extension/index.html new file mode 100644 index 0000000..2efb97f --- /dev/null +++ b/packages/plg_system_cgstyle_j4/src/Extension/index.html @@ -0,0 +1 @@ + diff --git a/packages/plg_system_cgstyle_j4/src/index.html b/packages/plg_system_cgstyle_j4/src/index.html new file mode 100644 index 0000000..2efb97f --- /dev/null +++ b/packages/plg_system_cgstyle_j4/src/index.html @@ -0,0 +1 @@ + diff --git a/pkg_cgtemplateswitcher.xml b/pkg_cgtemplateswitcher.xml index 26cbe5f..786c8e1 100644 --- a/pkg_cgtemplateswitcher.xml +++ b/pkg_cgtemplateswitcher.xml @@ -1,13 +1,13 @@ CG Template Switcher - 2023-08-27 + 2024-09-16 cgtemplateswitcher - https://www.gnu.org/licenses/gpl-2.0.html GNU/GPL + https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL ConseilGouz pascal.leconte@conseilgouz.com www.conseilgouz.com - 2.1.2 + 2.2.0 https://www.conseilgouz.com/ ConseilGouz Package CG Template Switcher