Skip to content

Commit

Permalink
2.2.0
Browse files Browse the repository at this point in the history
Switch between multiple Astroid templates
CGStyle plugin becomes a service provider
  • Loading branch information
conseilgouz committed Sep 16, 2024
1 parent b6e0e36 commit 0a3a457
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 16 deletions.
14 changes: 14 additions & 0 deletions cg_template_switcher_changelog.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,18 @@
<changelogs>
<changelog>
<element>pkg_cg_template_switcher</element>
<type>package</type>
<version>2.2.0</version>
<note>
<item>Update : 16/09/2024</item>
</note>
<fix>
<item>Switch between multiple Astroid templates</item>
</fix>
<change>
<item>CGStyle plugin becomes a service provider</item>
</change>
</changelog>
<changelog>
<element>pkg_cg_template_switcher</element>
<type>package</type>
Expand Down
Binary file modified packages/mod_cg_template_switcher_j4.zip
Binary file not shown.
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<extension version="4.0" type="module" method="upgrade" client="site">
<name>CG Template Switcher</name>
<author>ConseilGouz</author>
<creationDate>2023-08-27</creationDate>
<creationDate>2024-09-16</creationDate>
<copyright>Copyright (C) 2023 ConseilGouz. All rights reserved</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2</license>
<license>https://www.gnu.org/licenses/gpl-3.0.html GNU/GPLv2</license>
<authorEmail>pascal.leconte@conseilgouz.com</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>2.1.2</version>
<version>2.2.0</version>
<description>CG_XML_DESCRIPTION</description>
<namespace path="src">ConseilGouz\Module\CGTemplateSwitcher</namespace>
<changelogurl>https://raw.githubusercontent.com/conseilgouz/pkg_cg_template_switcher_j4/master/cg_template_switcher_changelog.xml</changelogurl>
Expand Down
Binary file modified packages/plg_system_cgstyle_j4.zip
Binary file not shown.
13 changes: 8 additions & 5 deletions packages/plg_system_cgstyle_j4/cgstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,16 +2,19 @@
<extension version="4.0" type="plugin" group="system" method="upgrade">
<name>plg_system_cgstyle</name>
<author>ConseilGouz</author>
<creationDate>2023-08-27</creationDate>
<copyright>(C)2023 ConseilGouz. All rights reserved.</copyright>
<license>GNU General Public License version 2 or later; see LICENSE.txt</license>
<creationDate>2024-09-16</creationDate>
<copyright>(C)2024 ConseilGouz. All rights reserved.</copyright>
<license>GNU General Public License version 3 or later; see LICENSE.txt</license>
<authorEmail>pascal.leconte@conseilgouz.com</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>2.1.2</version>
<version>2.2.0</version>
<description>PLG_SYSTEM_CGSTYLE_XML_DESCRIPTION</description>
<namespace path="src">Conseilgouz\Plugin\System\Cgstyle</namespace>
<files>
<filename plugin="cgstyle">cgstyle.php</filename>
<folder plugin="cgstyle">services</folder>
<folder>src</folder>
<filename>cgstyle.xml</filename>
<filename>index.html</filename>
</files>
<languages>
<language tag="en-GB">language/en-GB/plg_system_cgstyle.ini</language>
Expand Down
1 change: 1 addition & 0 deletions packages/plg_system_cgstyle_j4/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
1 change: 1 addition & 0 deletions packages/plg_system_cgstyle_j4/services/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
49 changes: 49 additions & 0 deletions packages/plg_system_cgstyle_j4/services/provider.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
<?php
/**
* @version 1.0.0
* @package CGWebp system plugin
* @author ConseilGouz
* @copyright Copyright (C) 2024 ConseilGouz. All rights reserved.
* license https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
* From DJ-WEBP version 1.0.0
**/

defined('_JEXEC') or die;

use Joomla\CMS\Extension\PluginInterface;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\Database\DatabaseInterface;
use Joomla\DI\Container;
use Joomla\DI\ServiceProviderInterface;
use Joomla\Event\DispatcherInterface;
use Joomla\Http\HttpFactory;
use Conseilgouz\Plugin\System\Cgstyle\Extension\Cgstyle;

return new class () implements ServiceProviderInterface {
/**
* Registers the service provider with a DI container.
*
* @param Container $container The DI container.
*
* @return void
*
* @since 4.2.0
*/
public function register(Container $container)
{
$container->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;
}
);
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand All @@ -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 );
}
Expand Down
1 change: 1 addition & 0 deletions packages/plg_system_cgstyle_j4/src/Extension/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
1 change: 1 addition & 0 deletions packages/plg_system_cgstyle_j4/src/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
<!DOCTYPE html><title></title>
6 changes: 3 additions & 3 deletions pkg_cgtemplateswitcher.xml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
<?xml version="1.0" encoding="UTF-8" ?>
<extension type="package" version="3.10" method="upgrade">
<name>CG Template Switcher</name>
<creationDate>2023-08-27</creationDate>
<creationDate>2024-09-16</creationDate>
<packagename>cgtemplateswitcher</packagename>
<license>https://www.gnu.org/licenses/gpl-2.0.html GNU/GPL</license>
<license>https://www.gnu.org/licenses/gpl-3.0.html GNU/GPL</license>
<author>ConseilGouz</author>
<authorEmail>pascal.leconte@conseilgouz.com</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>2.1.2</version>
<version>2.2.0</version>
<url>https://www.conseilgouz.com/</url>
<packager>ConseilGouz</packager>
<description>Package CG Template Switcher</description>
Expand Down

0 comments on commit 0a3a457

Please sign in to comment.