Skip to content

Commit

Permalink
2.1.0
Browse files Browse the repository at this point in the history
Joomla 5 compatibility
Use WebAssetManager
  • Loading branch information
conseilgouz committed Aug 27, 2023
1 parent 43f7ce1 commit 26e9de8
Show file tree
Hide file tree
Showing 18 changed files with 55 additions and 33 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.1.0</version>
<note>
<item>Update : 27/08/2023</item>
</note>
<fix>
<item>Joomla 5 compatibility</item>
</fix>
<change>
<item>Use webassetmanager</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
@@ -1,4 +1,4 @@
CG_XML_DESCRIPTION="<p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher version 2.0.7</p>"
CG_XML_DESCRIPTION="<p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher version 2.1.0</p>"
CG_STYLE_PREVIEW="Preview template ?"
CG_STYLE_PREVIEWDESC="Show or not template preview window ?"
CG_STYLE_AUTO="Auto Switch"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
CG_XML_DESCRIPTION="<p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher version 2.0.7</p>"
CG_XML_DESCRIPTION="<p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher version 2.1.0</p>"

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
CG_XML_DESCRIPTION="<p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher version 2.0.7.</p>"
CG_XML_DESCRIPTION="<p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher version 2.1.0.</p>"
CG_STYLE_PREVIEW="Pr&eacute;visualisation du template ?"
CG_STYLE_PREVIEWDESC="Activer ou non la Pr&eacute;visualisation du template ?"
CG_STYLE_AUTO="Auto Switch"
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CG_XML_DESCRIPTION="<p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher version 2.0.7.</p>"
CG_XML_DESCRIPTION="<p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher version 2.1.0.</p>"
19 changes: 13 additions & 6 deletions packages/mod_cg_template_switcher_j4/mod_cg_template_switcher.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
<?php
/**
* @package CG template switcher Module
* @version 2.0.5
* @version 2.1.0
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @copyright (c) 2022 ConseilGouz. All Rights Reserved.
* @copyright (c) 2023 ConseilGouz. All Rights Reserved.
* @author ConseilGouz
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Plugin\PluginHelper;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Uri\Uri;
use ConseilGouz\Module\CGTemplateSwitcher\Site\Helper\CGTemplateSwitcherHelper;

JLoader::registerNamespace('ConseilGouz\Module\CGTemplateSwitcher\Site', JPATH_SITE . '/modules/mod_cg_template_switcher/src', false, false, 'psr4');
Expand All @@ -20,9 +21,12 @@
return false;
}
$document = Factory::getDocument();
$modulefield = ''.JURI::base(true).'/media/mod_cg_template_switcher/';
$modulefield = 'media/mod_cg_template_switcher/';

$document->addStyleDeclaration($params->get('css',''));
/** @var Joomla\CMS\WebAsset\WebAssetManager $wa */
$wa = Factory::getApplication()->getDocument()->getWebAssetManager();

if ($params->get('css')) $wa->addInlineStyle($params->get('css'));

$templates = CGTemplateSwitcherHelper::getTemplates($params);

Expand All @@ -40,8 +44,11 @@
array('cookie_duration' => $params->get('cookie_duration', 0),'showpreview' => $params->get('showpreview', 'true'),
'autoswitch' => $params->get('autoswitch', 'false'),
'noimage' => Text::_('NOIMAGE'),'templates' => $templates_js));
$document->addScript($modulefield .'js/init.js');

if ((bool)Factory::getConfig()->get('debug')) { // Mode debug
$document->addScript(''.URI::base(true).'/media/mod_cg_template_switcher/js/init.js');
} else {
$wa->registerAndUseScript('cgtemplateswitcher'.$module->id, $modulefield.'js/init.js');
}
require_once(ModuleHelper::getLayoutPath($module->module));

?>
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/02/18</creationDate>
<creationDate>2023/08/27</creationDate>
<copyright>Copyright (C) 2023 ConseilGouz. All rights reserved</copyright>
<license>http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2</license>
<authorEmail>pascal.leconte@conseilgouz.com</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>2.0.7</version>
<version>2.1.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
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<?php
/**
* @package CG template switcher Module
* @version 2.0.7
* @version 2.1.0
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @copyright (c) 2023 ConseilGouz. All Rights Reserved.
* @author ConseilGouz
Expand All @@ -12,6 +12,7 @@
use Joomla\Registry\Registry;
use Joomla\CMS\Helper\ModuleHelper;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Uri\Uri;

class CGTemplateSwitcherHelper
{
Expand All @@ -28,9 +29,9 @@ static function getTemplates($params)
$results->options = array();
foreach ($styles as $template) {
$template_dir = strtolower(JPATH_ROOT.'/templates/'.$template->template); // for file_exists
$template_dir_html = \JURI::root().'/templates/'. $template->template; // for display
$template_dir_html = Uri::root().'/templates/'. $template->template; // for display
$template_media_dir = strtolower(JPATH_ROOT.'/media/templates/site/'.$template->template.'/images');
$template_media_dir_html = \JURI::root().'/media/templates/site/'.$template->template.'/images';
$template_media_dir_html = Uri::root().'/media/templates/site/'.$template->template.'/images';
$results->options[$template->id] = HTMLHelper::_('select.option', $template->id, $template->title);
$results->home[$template->id] = $template->home;
if ($params->get('showpreview', 'true') == 'true') {
Expand Down
8 changes: 4 additions & 4 deletions packages/mod_cg_template_switcher_j4/tmpl/default.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* @package CG template switcher Module
* @version 2.0.5
* @version 2.1.0
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @copyright (c) 2022 ConseilGouz. All Rights Reserved.
* @copyright (c) 2023 ConseilGouz. All Rights Reserved.
* @author ConseilGouz
*
*/
Expand Down Expand Up @@ -36,8 +36,8 @@
</div>
<?php if ($params->get("autoswitch","false") == 'false') { // 01.0.14 : autoswitch?>
<div id="CG_TS_LIST" style="padding:6px 0 0 0;border:none;background:none;text-align:center">
<input id="CG_TS_OKBtn" class="button" type="button" style="margin:0" value="<?php echo JText::_('CGSELECT'); ?>"/>
<input id ="CG_TS_CancelBtn" class="button" type="button" style="margin-left:1em" value="<?php echo JText::_('CGCANCEL'); ?>" title="<?php echo JText::_('CGCANCELDESC'); ?>" />
<input id="CG_TS_OKBtn" class="button" type="button" style="margin:0" value="<?php echo Text::_('CGSELECT'); ?>"/>
<input id ="CG_TS_CancelBtn" class="button" type="button" style="margin-left:1em" value="<?php echo Text::_('CGCANCEL'); ?>" title="<?php echo Text::_('CGCANCELDESC'); ?>" />
</div>
<?php } ?>
</div>
Expand Down
Binary file modified packages/plg_system_cgstyle_j4.zip
Binary file not shown.
6 changes: 3 additions & 3 deletions packages/plg_system_cgstyle_j4/cgstyle.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php
/**
* @package CG template switcher Module
* @version 2.0.6
* @version 2.1.0
* @subpackage system.cg_style
*
* @copyright Copyright (C) 2022 Conseilgouz. All rights reserved.
* @copyright Copyright (C) 2023 Conseilgouz. All rights reserved.
* @license GNU General Public License version 2 or later; see LICENSE.txt
*
*/
Expand Down Expand Up @@ -34,7 +34,7 @@ public function onAfterRoute() {
if ($style != null) {
$j = new Version();
$version=substr($j->getShortVersion(), 0,1);
if ($version == "4") { // Joomla 4.0
if ($version >= "4") { // Joomla 4 and higher
$app->setTemplate( $style);
}else { // Joomla 3.10
$app->setTemplate( $style->template, $style->params );
Expand Down
6 changes: 3 additions & 3 deletions packages/plg_system_cgstyle_j4/cgstyle.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@
<extension version="4.0" type="plugin" group="system" method="upgrade">
<name>plg_system_cgstyle</name>
<author>ConseilGouz</author>
<creationDate>October 2022</creationDate>
<copyright>(C)2022 ConseilGouz. All rights reserved.</copyright>
<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>
<authorEmail>pascal.leconte@conseilgouz.com</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>2.0.6</version>
<version>2.1.0</version>
<description>PLG_SYSTEM_CGSTYLE_XML_DESCRIPTION</description>
<files>
<filename plugin="cgstyle">cgstyle.php</filename>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PLG_SYSTEM_CGSTYLE_XML_DESCRIPTION="Systeme - Template Style Switcher version 2.0.6."
PLG_SYSTEM_CGSTYLE_XML_DESCRIPTION="Systeme - Template Style Switcher version 2.1.0."
PLG_SYSTEM_CGSTYLE="Systeme - Template Style Switcher"
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
PLG_SYSTEM_CGSTYLE_XML_DESCRIPTION="Systeme - Template Style Switcher version 2.0.6."
PLG_SYSTEM_CGSTYLE_XML_DESCRIPTION="Systeme - Template Style Switcher version 2.1.0."
PLG_SYSTEM_CGSTYLE="System - Template Style Switcher"

Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PLG_SYSTEM_CGSTYLE_XML_DESCRIPTION="Systeme - Template Style Switcher version 2.0.6."
PLG_SYSTEM_CGSTYLE_XML_DESCRIPTION="Systeme - Template Style Switcher version 2.1.0."
PLG_SYSTEM_CGSTYLE="Systeme - Template Style Switcher"
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
PLG_SYSTEM_CGSTYLE_XML_DESCRIPTION="Systeme - Template Style Switcher version 2.0.6."
PLG_SYSTEM_CGSTYLE_XML_DESCRIPTION="Systeme - Template Style Switcher version 2.1.0."
PLG_SYSTEM_CGSTYLE="Systeme - Template Style Switcher"
8 changes: 4 additions & 4 deletions script.php
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
<?php
/**
* CG Template Switcher package - Joomla 4 Module
* Version : 2.0.7
* Version : 2.1.0
* Package : CG Template Switcher
* copyright : Copyright (C) 2023 ConseilGouz. All rights reserved.
* license : http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
*/
// No direct access to this file
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Filesystem\Folder;
use Joomla\Filesystem\Folder;
use Joomla\CMS\Version;
use Joomla\CMS\Filesystem\File;
use Joomla\Filesystem\File;

class pkg_CGTemplateSwitcherInstallerScript
{
Expand Down Expand Up @@ -202,7 +202,7 @@ private function passMinimumPHPVersion()
}
private function uninstallInstaller()
{
if ( ! JFolder::exists(JPATH_PLUGINS . '/system/' . $this->installerName)) {
if ( ! is_dir(JPATH_PLUGINS . '/system/' . $this->installerName)) {
return;
}
$this->delete([
Expand Down

0 comments on commit 26e9de8

Please sign in to comment.