Skip to content

Commit

Permalink
2.1.5
Browse files Browse the repository at this point in the history
changelog/updates package on github
  • Loading branch information
conseilgouz committed Aug 13, 2023
1 parent dae6732 commit abdde1a
Show file tree
Hide file tree
Showing 4 changed files with 192 additions and 10 deletions.
9 changes: 4 additions & 5 deletions admin/cgparallax.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<authorUrl>www.conseilgouz.com</authorUrl>
<copyright>Copyright (C) 2023 ConseilGouz.com. All Rights Reserved</copyright>
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
<version>2.1.4</version>
<version>2.1.5</version>
<namespace path="src">ConseilGouz\Component\CGParallax</namespace>
<description>CG_PX_XML_DESCRIPTION</description>
<install>
Expand All @@ -27,6 +27,7 @@
<schemapath type="mysql">sql/updates</schemapath>
</schemas>
</update>
<scriptfile>script.php</scriptfile>
<files folder="site">
<folder>src</folder>
<folder>tmpl</folder>
Expand Down Expand Up @@ -67,11 +68,9 @@
<language tag="fr-FR">language/fr-FR/com_cgparallax.sys.ini</language>
</languages>
</administration>
<changelogurl>https://www.conseilgouz.com/updates/com_cgparallax_changelog.xml</changelogurl>

<changelogurl>https://raw.githubusercontent.com/conseilgouz/com_cgparallax_j4/master/com_cgparallax_changelog.xml</changelogurl>
<updateservers>
<server type="extension" name="COM CG Parallax" priority="1">https://www.conseilgouz.com/updates/com_cgparallax_update.xml</server>
<server type="extension" name="COM CG Parallax" priority="2">http://432473037d.url-de-test.ws/updateserver/updates/com_cgparallax_update.xml</server>
<server type="extension" name="COM CG Parallax" priority="1">https://raw.githubusercontent.com/conseilgouz/updates_github/master/com_cgparallax_update.xml</server>
</updateservers>

</extension>
9 changes: 4 additions & 5 deletions cgparallax.xml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
<authorUrl>www.conseilgouz.com</authorUrl>
<copyright>Copyright (C) 2023 ConseilGouz.com. All Rights Reserved</copyright>
<license>GNU/GPL Version 2 or later - http://www.gnu.org/licenses/gpl-2.0.html</license>
<version>2.1.4</version>
<version>2.1.5</version>
<namespace path="src">ConseilGouz\Component\CGParallax</namespace>
<description>CG_PX_XML_DESCRIPTION</description>
<install>
Expand All @@ -27,6 +27,7 @@
<schemapath type="mysql">sql/updates</schemapath>
</schemas>
</update>
<scriptfile>script.php</scriptfile>
<files folder="site">
<folder>src</folder>
<folder>tmpl</folder>
Expand Down Expand Up @@ -67,11 +68,9 @@
<language tag="fr-FR">language/fr-FR/com_cgparallax.sys.ini</language>
</languages>
</administration>
<changelogurl>https://www.conseilgouz.com/updates/com_cgparallax_changelog.xml</changelogurl>

<changelogurl>https://raw.githubusercontent.com/conseilgouz/com_cgparallax_j4/master/com_cgparallax_changelog.xml</changelogurl>
<updateservers>
<server type="extension" name="COM CG Parallax" priority="1">https://www.conseilgouz.com/updates/com_cgparallax_update.xml</server>
<server type="extension" name="COM CG Parallax" priority="2">http://432473037d.url-de-test.ws/updateserver/updates/com_cgparallax_update.xml</server>
<server type="extension" name="COM CG Parallax" priority="1">https://raw.githubusercontent.com/conseilgouz/updates_github/master/com_cgparallax_update.xml</server>
</updateservers>

</extension>
11 changes: 11 additions & 0 deletions com_cgparallax_changelog.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,15 @@
<changelogs>
<changelog>
<element>com_cgparallax</element>
<type>component</type>
<version>2.1.5</version>
<note>
<item>Update : 12/08/2023</item>
</note>
<change>
<item>changelog/updates package on github</item>
</change>
</changelog>
<changelog>
<element>com_cgparallax</element>
<type>component</type>
Expand Down
173 changes: 173 additions & 0 deletions script.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,173 @@
<?php
/**
* CG Parallax Component - Joomla 4.x/5.x Component
* Version : 2.1.5
* Package : CG Parallax
* copyright : Copyright (C) 2023 ConseilGouz. All rights reserved.
* license : http://www.gnu.org/licenses/gpl-2.0.html GNU/GPL
* From : https://vegas.jaysalvat.com/
*/
// No direct access to this file
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;

class com_cgparallaxInstallerScript
{
private $min_joomla_version = '4.0';
private $min_php_version = '8.0';
private $name = 'CG Parallax';
private $exttype = 'component';
private $extname = 'cgisotope';
private $previous_version = '';
private $dir = null;
private $lang = null;
private $installerName = 'cgparallaxinstaller';
public function __construct()
{
$this->dir = __DIR__;
$this->lang = Factory::getLanguage();
$this->lang->load($this->extname);
}
function preflight($type, $parent)
{

if ( ! $this->passMinimumJoomlaVersion())
{
$this->uninstallInstaller();

return false;
}

if ( ! $this->passMinimumPHPVersion())
{
$this->uninstallInstaller();

return false;
}
// To prevent installer from running twice if installing multiple extensions
if ( ! file_exists($this->dir . '/' . $this->installerName . '.xml'))
{
return true;
}
$xml = simplexml_load_file(JPATH_ADMIN . '/components/com_'.$this->extname.'/'.$this->extname.'.xml');
$this->previous_version = $xml->version;

}

function install($parent)
{
}

function uninstall($parent)
{
}

function update($parent)
{
}

function postflight($type, $parent)
{
if (($type=='install') || ($type == 'update')) { // remove obsolete dir/files
$this->postinstall_cleanup();
}
switch ($type) {
case 'install': $message = Text::_('ISO_POSTFLIGHT_INSTALLED'); break;
case 'uninstall': $message = Text::_('ISO_POSTFLIGHT_UNINSTALLED'); break;
case 'update': $message = Text::_('ISO_POSTFLIGHT_UPDATED'); break;
case 'discover_install': $message = Text::_('ISO_POSTFLIGHT_DISC_INSTALLED'); break;
}
$message = '<h3>'.Text::sprintf('ISO_POSTFLIGHT',$parent->getManifest()->name,$parent->getManifest()->version,$message).'</h3>';

Factory::getApplication()->enqueueMessage($message.Text::_('CG_ISO_XML_DESCRIPTION'), 'notice');

// Uninstall this installer
$this->uninstallInstaller();

return true;


// JFactory::getApplication()->enqueueMessage($message);
}
private function postinstall_cleanup() {

/* $obsoleteFiles = [
JPATH_ADMINISTRATOR."/components/com_cgisotope/updates.txt"
];
foreach ($obsoleteFiles as $file) {
if (@is_file($file)) {
File::delete($file);
}
}
*/
// remove obsolete update sites
$db = Factory::getDbo();
$query = $db->getQuery(true)
->delete('#__update_sites')
->where($db->quoteName('location') . ' like "%432473037d.url-de-test.ws/%"');
$db->setQuery($query);
$db->execute();
// Simple Isotope is now on Github
$query = $db->getQuery(true)
->delete('#__update_sites')
->where($db->quoteName('location') . ' like "%conseilgouz.com/updates/com_parallax%"');
$db->setQuery($query);
$db->execute();

}
// Check if Joomla version passes minimum requirement
private function passMinimumJoomlaVersion()
{
if (version_compare(JVERSION, $this->min_joomla_version, '<'))
{
Factory::getApplication()->enqueueMessage(
'Incompatible Joomla version : found <strong>' . JVERSION . '</strong>, Minimum : <strong>' . $this->min_joomla_version . '</strong>',
'error'
);

return false;
}

return true;
}

// Check if PHP version passes minimum requirement
private function passMinimumPHPVersion()
{

if (version_compare(PHP_VERSION, $this->min_php_version, '<'))
{
Factory::getApplication()->enqueueMessage(
'Incompatible PHP version : found <strong>' . PHP_VERSION . '</strong>, Minimum <strong>' . $this->min_php_version . '</strong>',
'error'
);
return false;
}

return true;
}

private function uninstallInstaller()
{
if ( ! is_dir(JPATH_PLUGINS . '/system/' . $this->installerName)) {
return;
}
$this->delete([
JPATH_PLUGINS . '/system/' . $this->installerName . '/language',
JPATH_PLUGINS . '/system/' . $this->installerName,
]);
$db = Factory::getDbo();
$query = $db->getQuery(true)
->delete('#__extensions')
->where($db->quoteName('element') . ' = ' . $db->quote($this->installerName))
->where($db->quoteName('folder') . ' = ' . $db->quote('system'))
->where($db->quoteName('type') . ' = ' . $db->quote('plugin'));
$db->setQuery($query);
$db->execute();
Factory::getCache()->clean('_system');
}

}

0 comments on commit abdde1a

Please sign in to comment.