Skip to content

Commit

Permalink
Same fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
denysdesign committed Feb 8, 2023
1 parent c201920 commit f7c880a
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 212 deletions.
2 changes: 1 addition & 1 deletion build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
basedir=".">

<property name="VERSION"
value="7.4" />
value="7.5" />

<tstamp>
<format property="DATE"
Expand Down
12 changes: 8 additions & 4 deletions packages/mod_junewsultra/mod_junewsultra.xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
<?xml version="1.0" encoding="utf-8"?>
<extension type="module" version="3.8" client="site" method="upgrade">
<extension type="module"
version="3.8"
client="site"
method="upgrade">
<name>MOD_JUNEWSULTRA</name>
<creationDate>@date@</creationDate>
<author>Denys Nosov</author>
Expand All @@ -24,7 +27,9 @@
</media>

<updateservers>
<server type="extension" priority="1" name="JUNewsUltra">https://joomla-ua.org/update/mod/junewsultra.xml</server>
<server type="extension"
priority="1"
name="JUNewsUltra">https://joomla-ua.org/update/mod/junewsultra.xml</server>
</updateservers>

<config addfieldpath="/modules/mod_junewsultra/fields">
Expand Down Expand Up @@ -1509,8 +1514,7 @@

<field
name="gallery"
path="/plugins/content/jumultithumb_gallery/jumultithumb_gallery.php"
type="Integration"
type="radio"
class="btn-group"
default="1"
label="MOD_JUNEWS_IMAGE_JUMULTITHUMB_GALLERY"
Expand Down
218 changes: 11 additions & 207 deletions script.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,8 @@
defined('_JEXEC') or die;

use Joomla\CMS\Factory;
use Joomla\CMS\Language\Text;
use Joomla\CMS\Filesystem\File;
use Joomla\CMS\Filesystem\Folder;

/**
* Installation class to perform additional changes during install/uninstall/update
Expand Down Expand Up @@ -50,18 +51,20 @@ class Pkg_JUNewsUltraInstallerScript
*/
public function preflight($type, $parent)
{
$app = Factory::getApplication();

if(version_compare(JVERSION, '3.8.0', 'lt'))
{
Factory::getApplication()->enqueueMessage('Update for Joomla! 3.8+', 'error');
$app->enqueueMessage('Update for Joomla! 3.8+', 'error');

return false;
}

$this->MakeDirectory(JPATH_SITE . '/img');
Folder::create(JPATH_SITE . '/img', 0777);

if(!is_dir(JPATH_SITE . '/img/'))
{
Factory::getApplication()->enqueueMessage('Error creating folder \'img\'. Please manually create the folder \'img\' in the root of the site where you installed Joomla!');
$app->enqueueMessage('Error creating folder \'img\'. Please manually create the folder \'img\' in the root of the site where you installed Joomla!');
}

$cache = Factory::getCache('mod_junewsultra');
Expand All @@ -70,51 +73,16 @@ public function preflight($type, $parent)
return true;
}

/**
* @param $parent
*
*
* @return bool
* @since 6.0
*/
public function uninstall($parent)
{
return true;
}

/**
* @param $parent
*
*
* @return bool
* @since 6.0
*/
public function update($parent)
{
return true;
}

/**
* @param $type
* @param $parent
* @param $results
*
* @return bool
*
* @throws \Exception
* @since 6.0
*/
public function postflight($type, $parent, $results)
public function postflight($type, $parent)
{
$enabled = [];

$db = Factory::getDbo();
$query = $db->getQuery(true);
$app = Factory::getApplication();

$lang = Factory::getLanguage();
$lang->load('mod_junewsultra', JPATH_SITE);

if(version_compare(JVERSION, '4.0.0', '>='))
{
$xml = file_get_contents(JPATH_SITE . '/modules/mod_junewsultra/mod_junewsultra.xml');
Expand All @@ -129,109 +97,6 @@ public function postflight($type, $parent, $results)
file_put_contents(JPATH_SITE . '/modules/mod_junewsultra/mod_junewsultra.xml', $xml);
}

foreach($results as $result)
{
$extension = (string) $result[ 'name' ];

$query->clear();

$query->select($db->quoteName([ 'enabled' ]));
$query->from($db->quoteName('#__extensions'));
$query->where($db->quoteName('name') . ' = ' . $db->quote($extension));
$db->setQuery($query);

$enabled[ $extension ] = $db->loadResult();
}

$html = '<style type="text/css">
.juinstall {
color: #333!important;
font-weight: normal;
margin: 0!important;
padding: 0;
overflow: hidden;
background: #fff!important;
}
.juinstall-content {
margin: 5% auto!important;
padding: 35px 0 18px 0;
width: 50%;
}
.juinstall .newalert {
clear: both;
margin: 5px 10%!important;
}
.juinstall p {
margin-left: 0;
text-align: left;
}
.juinstall table td .label {
margin: 0 auto;
}
.juinstall hr {
margin-top:6px;
margin-bottom:6px;
border:0;
border-top:1px solid #eee
}
</style>';

$html .= '<div class="juinstall">
<div class="juinstall-content">
<h2 style="padding: 0 0 8px 0; margin: 0;">' . Text::_('MOD_JUNEWS_TITLE') . '</h2>
<h2 style="padding: 0 0 8px 0; margin: 0;"><small>' . Text::_('MOD_JUNEWS_DESCRIPTION') . '</small></h2>
<table class="table table-striped">
<thead>
<tr>
<th>' . Text::_('MOD_JUNEWS_EXTENSION') . '</th>
<th>' . Text::_('JSTATUS') . '</th>
<th>' . Text::_('JENABLED') . '</th>
</tr>
</thead>
<tbody>';

foreach($results as $result)
{
$extension = (string) $result[ 'name' ];

$html .= '<tr><td>';

if($extension === 'MOD_JUNEWSULTRA')
{
$html .= Text::_($extension);
}
else
{
$html .= $extension;
}

$html .= '</td><td><strong>';

if($result[ 'result' ] === true)
{
$html .= '<span class="label label-success">' . Text::_('MOD_JUNEWS_INSTALLED') . '</span>';
}
else
{
$html .= '<span class="label label-important">' . Text::_('MOD_JUNEWS_NOT_INSTALLED') . '</span>';
}

$html .= '</strong></td><td>';

if($enabled[ $extension ] == 1)
{
$html .= '<span class="label label-success">' . Text::_('JYES') . '</span>';
}
else
{
$html .= '<span class="label label-important">' . Text::_('JNO') . '</span>';
}

$html .= '</td></tr>';
}

$html .= '</tbody></table>';

$path = JPATH_SITE . '/modules/mod_junewsultra/';
$files = [
$path . 'assets/donate2.gif',
Expand All @@ -258,7 +123,6 @@ public function postflight($type, $parent, $results)
$path . 'assets/css/default.css',
$path . 'assets/css/elegant.css',
$path . 'assets/css/docs.css',

$path . 'fields/jumultithumbradio.php',
$path . 'fields/colorpicker.php',
$path . 'fields/imagesetting.php',
Expand All @@ -268,11 +132,9 @@ public function postflight($type, $parent, $results)
$path . 'fields/toggler30.php',
$path . 'fields/donate.php',
$path . 'fields/article.php',

$path . 'tmpl/default/images/bg.jpg',
$path . 'tmpl/default/images/rating_star.png_',
$path . 'tmpl/default/images/rating_star_blank.png_',

$path . 'img/.htaccess',
$path . 'img/config.php',
$path . 'img/img.php',
Expand All @@ -287,91 +149,33 @@ public function postflight($type, $parent, $results)
$path . 'assets/js/minicolors'
];

$i = 0;
foreach($files as $file)
{
if(file_exists($file))
{
$i++;
File::delete($file);
}
}

$j = 0;
foreach($folders as $folder)
{
if(is_dir($folder))
{
$j++;
$this->unlinkRecursive($folder);
}
}

if(($i + $j) > 0)
{
$html .= '<h2>' . Text::_('MOD_JUNEWS_REMOVE_OLD_FILES') . '</h2><table class="table table-striped"><tbody>';

foreach($files as $file)
{
if(file_exists($file))
{
$filepath = str_replace($path, '', $file);
unlink($file);

$html .= '<tr><td><span class="label">File:</span> <code>' . $filepath . '</code></td><td><span class="label label-inverse">Delete</span></td></tr>';
}
}

foreach($folders as $folder)
{
if(is_dir($folder))
{
$folderpath = str_replace($path, '', $folder);
$this->unlinkRecursive($folder, 1);

$html .= '<tr><td><span class="label">Folder:</span> <code>' . $folderpath . '</code></td><td><span class="label label-inverse">Delete</span></td></tr>';
}
}

$html .= '</tbody></table>';
}

$html .= '</div></div>';

//$app->enqueueMessage($html);
echo $html;

return true;
}

/**
* @param $dir
*
* @return bool
*
* @since version
*/
private function MakeDirectory($dir)
{
if(mkdir($dir, 0777, true) || is_dir($dir))
{
return true;
}

if(!$this->MakeDirectory(dirname($dir)))
{
return false;
}

return mkdir($dir, 0777, true);
}

/**
* @param $dir
* @param $deleteRootToo
*
*
* @since version
*/
private function unlinkRecursive($dir, $deleteRootToo)
private function unlinkRecursive($dir, $deleteRootToo = 1)
{
if(!$dh = opendir($dir))
{
Expand Down

0 comments on commit f7c880a

Please sign in to comment.