Skip to content

Commit

Permalink
2.0.5
Browse files Browse the repository at this point in the history
Autoselect current template
Display thumbnails from media directory
No click on thumbnail
  • Loading branch information
conseilgouz committed Sep 9, 2022
1 parent 2c57b6e commit aab2648
Show file tree
Hide file tree
Showing 13 changed files with 73 additions and 47 deletions.
13 changes: 13 additions & 0 deletions cg_template_switcher_changelog.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<changelogs>
<changelog>
<element>pkg_cg_template_switcher</element>
<type>package</type>
<version>2.0.5</version>
<note>
<item>Update : 09/09/2022</item>
</note>
<fix>
<item>Autoselect current template</item>
<item>Display thumbnails from media directory</item>
<item>No click on thumbnail</item>
</fix>
</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.1</p>"
CG_XML_DESCRIPTION="<p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher version 2.0.5</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.1</p>"
CG_XML_DESCRIPTION="<p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher version 2.0.5</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.1.</p>"
CG_XML_DESCRIPTION="<p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher version 2.0.5.</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.1.</p>"
CG_XML_DESCRIPTION="<p style='text-align:left;padding-left:5px;font-size:inherit'>CG Template Switcher version 2.0.5.</p>"
8 changes: 3 additions & 5 deletions packages/mod_cg_template_switcher_j4/media/js/init.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
/**
* @package CG template switcher Module
* @version 2.0.1
* @version 2.0.5
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @copyright (c) 2021 ConseilGouz. All Rights Reserved.
* @copyright (c) 2025 ConseilGouz. All Rights Reserved.
* @author ConseilGouz
*
**/
Expand Down Expand Up @@ -63,9 +63,7 @@ function go_switch(options) {

function CG_TS_ImageShow(s) {
if (CG_TS_Images[s]) {
document.getElementById("CG_TS_Switcher").innerHTML = decodeURIComponent("%3C")+'a href="'+ CG_TS_Images[s].preview +'" class="fancybox"'+decodeURIComponent("%3E")+
decodeURIComponent("%3C")+'img src="'+CG_TS_Images[s].preview+'" id="CG_TS_Img"'+decodeURIComponent("%3E")+
decodeURIComponent("%3C")+'/a'+decodeURIComponent("%3E");
document.getElementById("CG_TS_Switcher").innerHTML = decodeURIComponent("%3C")+'img src="'+CG_TS_Images[s].preview+'" id="CG_TS_Img"'+decodeURIComponent("%3E");
} else {
document.getElementById("CG_TS_Switcher").innerHTML = options.noimage;
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* @package CG template switcher Module
* @version 2.0.1
* @version 2.0.5
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @copyright (c) 2021 ConseilGouz. All Rights Reserved.
* @copyright (c) 2022 ConseilGouz. All Rights Reserved.
* @author ConseilGouz
*/
defined('_JEXEC') or die;
Expand Down
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>October 2021</creationDate>
<copyright>Copyright (C) 2021 ConseilGouz. All rights reserved</copyright>
<creationDate>September 2022</creationDate>
<copyright>Copyright (C) 2022 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.2</version>
<version>2.0.5</version>
<description>CG_XML_DESCRIPTION</description>
<namespace path="src">ConseilGouz\Module\CGTemplateSwitcher</namespace>
<scriptfile>script.php</scriptfile>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,17 @@
<changelogs>
<changelog>
<element>mod_cg_template_switcher</element>
<type>Module</type>
<version>2.0.5</version>
<note>
<item>Update : 09/09/2022</item>
</note>
<fix>
<item>Autoselect current template</item>
<item>Display thumbnails from media directory</item>
<item>No click on thumbnail</item>
</fix>
</changelog>
<changelog>
<element>mod_cg_template_switcher</element>
<type>Module</type>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
<?php
/**
* @package CG template switcher Module
* @version 2.0.1
* @version 2.0.5
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @copyright (c) 2021 ConseilGouz. All Rights Reserved.
* @copyright (c) 2022 ConseilGouz. All Rights Reserved.
* @author ConseilGouz
*/
namespace ConseilGouz\Module\CGTemplateSwitcher\Site\Helper;
Expand All @@ -17,40 +17,48 @@ class CGTemplateSwitcherHelper
{
static function getTemplates($params)
{

if ($params->get('templatesall','true') == 'true') { // all the templates
$styles = self::getListStyles();
} else { // selected templates
$list = $params->get('templates',array());
$styles = self::getListStyles($list);
}

$results = new \stdClass();
$results->imagewidth ='150'; // default image width
$results->options = array();
foreach ($styles as $template) {
$template_dir = strtolower(JPATH_ROOT.'/templates/'.$template->template);
$template_dir = strtolower(JPATH_ROOT.'/templates/'.$template->template); // for file_exists
$template_dir_html = \JURI::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';
$results->options[$template->id] = HTMLHelper::_('select.option', $template->id, $template->title);
$results->home[$template->id] = $template->home;
if ($params->get('showpreview', 'true') == 'true') {
$img = "";
$img_preview = "";
if (file_exists($template_dir.'/template_thumbnail.png')) {
$img = $template_dir_html.'/template_thumbnail.png';
} elseif (file_exists($template_media_dir.'/template_thumbnail.png')){
$img = $template_media_dir_html.'/template_thumbnail.png';
}
if (file_exists($template_dir.'/template_preview.png')) {
$img_preview = $template_dir_html.'/template_preview.png';
}
if (file_exists($template_media_dir.'/template_preview.png')){
$img_preview = $template_media_dir_html.'/template_preview.png';
}
if ($img) {
$results->images[$template->id] = new \stdClass();
$results->images[$template->id]->name = $template->title;
$results->images[$template->id]->src = \JURI::root().'/templates/'.$template->template.'/template_thumbnail.png';
$results->images[$template->id]->src = $img;
$results->images[$template->id]->width = '150';
$results->images[$template->id]->height = '100';
$results->images[$template->id]->preview = \JURI::root().'/templates/'.$template->template.'/template_thumbnail.png';;
if (file_exists($template_dir.'/template_preview.png')) {
$results->images[$template->id]->preview = \JURI::root().'/templates/'.$template->template.'/template_preview.png';
}
$results->images[$template->id]->preview = $img_preview;
}

}

}
return $results;
}

static function getListStyles($list = array() )
{
$clientId = 0;
Expand Down Expand Up @@ -90,7 +98,6 @@ public static function getAjax() {
return false;
}
private static function getParams($params) {

$templates = self::getTemplates($params);
$templates_js = array();
if ($params->get('showpreview', 'true') == 'true') {
Expand All @@ -106,5 +113,4 @@ private static function getParams($params) {
return $ret;
}
}

?>
30 changes: 13 additions & 17 deletions packages/mod_cg_template_switcher_j4/tmpl/default.php
Original file line number Diff line number Diff line change
@@ -1,32 +1,28 @@
<?php
/**
* @package CG template switcher Module
* @version 2.0.1
* @version 2.0.5
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* @copyright (c) 2021 ConseilGouz. All Rights Reserved.
* @copyright (c) 2022 ConseilGouz. All Rights Reserved.
* @author ConseilGouz
*
*/
defined('_JEXEC') or die('Restricted access'); ?>
<?php
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\CMS\HTML\HTMLHelper;
use Joomla\CMS\Language\Text;

if (empty($templates->options)) { ?>
<form style="border:none" action="#">
<div style="margin:6px 0;padding:0;border:none;background:none;overflow:hidden">
<?php echo JText::_('NOTEMPLATE'); ?>
<?php echo Text::_('NOTEMPLATE'); ?>
</div>
</form>
<?php return; }
$app = JFactory::getApplication();
$curr_template = $app->getTemplate(); // Current template
$curr_template_idx = JFactory::getApplication()->input->cookie->get('cg_template'); // template ix from cookie
// look for home template
$home_template_id = 0;
foreach ($templates->home as $key => $value) {
if ($value == 1) {
$home_template_id = $key;
}
}
if (($curr_template_idx == 0) && ($home_template_id > 0)) $curr_template_idx = $home_template_id;
$app = Factory::getApplication();
$curr_template = $app->getTemplate(true); // Current template
$curr_template_idx = Factory::getApplication()->input->cookie->get('cg_template'); // template ix from cookie
if (!$curr_template_idx) $curr_template_idx = $curr_template->id;
?>

<form id="cg_ts_form" method="post" style="border:none" >
Expand All @@ -36,7 +32,7 @@
</div>
<div id="CG_TS_CHOICE" style="margin:6px 0;padding:0;border:none;background:none;overflow:hidden">
<div id="CG_TS_THUMBNAIL" style="padding:0;border:none;background:none;text-align:center">
<?php echo JHtmlSelect::genericlist($templates->options, 'template', "class=\"inputbox\" style=\"margin:0\"", 'value', 'text', $curr_template_idx,'CG_TS_Select'); ?>
<?php echo HTMLHelper::_('select.genericlist',$templates->options, 'template', "class=\"inputbox\" style=\"margin:0\"", 'value', 'text', $curr_template_idx,'CG_TS_Select'); ?>
</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">
Expand Down
2 changes: 1 addition & 1 deletion pkg_cgtemplateswitcher.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<author>ConseilGouz</author>
<authorEmail>pascal.leconte@conseilgouz.com</authorEmail>
<authorUrl>www.conseilgouz.com</authorUrl>
<version>2.0.4</version>
<version>2.0.5</version>
<url>https://www.conseilgouz.com/</url>
<packager>ConseilGouz</packager>
<description>Package CG Template Switcher</description>
Expand Down

0 comments on commit aab2648

Please sign in to comment.