Skip to content

Commit f7c880a

Browse files
committed
Same fixes
1 parent c201920 commit f7c880a

File tree

3 files changed

+20
-212
lines changed

3 files changed

+20
-212
lines changed

build.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
basedir=".">
44

55
<property name="VERSION"
6-
value="7.4" />
6+
value="7.5" />
77

88
<tstamp>
99
<format property="DATE"

packages/mod_junewsultra/mod_junewsultra.xml

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
2-
<extension type="module" version="3.8" client="site" method="upgrade">
2+
<extension type="module"
3+
version="3.8"
4+
client="site"
5+
method="upgrade">
36
<name>MOD_JUNEWSULTRA</name>
47
<creationDate>@date@</creationDate>
58
<author>Denys Nosov</author>
@@ -24,7 +27,9 @@
2427
</media>
2528

2629
<updateservers>
27-
<server type="extension" priority="1" name="JUNewsUltra">https://joomla-ua.org/update/mod/junewsultra.xml</server>
30+
<server type="extension"
31+
priority="1"
32+
name="JUNewsUltra">https://joomla-ua.org/update/mod/junewsultra.xml</server>
2833
</updateservers>
2934

3035
<config addfieldpath="/modules/mod_junewsultra/fields">
@@ -1509,8 +1514,7 @@
15091514

15101515
<field
15111516
name="gallery"
1512-
path="/plugins/content/jumultithumb_gallery/jumultithumb_gallery.php"
1513-
type="Integration"
1517+
type="radio"
15141518
class="btn-group"
15151519
default="1"
15161520
label="MOD_JUNEWS_IMAGE_JUMULTITHUMB_GALLERY"

script.php

Lines changed: 11 additions & 207 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
defined('_JEXEC') or die;
1313

1414
use Joomla\CMS\Factory;
15-
use Joomla\CMS\Language\Text;
15+
use Joomla\CMS\Filesystem\File;
16+
use Joomla\CMS\Filesystem\Folder;
1617

1718
/**
1819
* Installation class to perform additional changes during install/uninstall/update
@@ -50,18 +51,20 @@ class Pkg_JUNewsUltraInstallerScript
5051
*/
5152
public function preflight($type, $parent)
5253
{
54+
$app = Factory::getApplication();
55+
5356
if(version_compare(JVERSION, '3.8.0', 'lt'))
5457
{
55-
Factory::getApplication()->enqueueMessage('Update for Joomla! 3.8+', 'error');
58+
$app->enqueueMessage('Update for Joomla! 3.8+', 'error');
5659

5760
return false;
5861
}
5962

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

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

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

73-
/**
74-
* @param $parent
75-
*
76-
*
77-
* @return bool
78-
* @since 6.0
79-
*/
80-
public function uninstall($parent)
81-
{
82-
return true;
83-
}
84-
85-
/**
86-
* @param $parent
87-
*
88-
*
89-
* @return bool
90-
* @since 6.0
91-
*/
92-
public function update($parent)
93-
{
94-
return true;
95-
}
96-
9776
/**
9877
* @param $type
9978
* @param $parent
100-
* @param $results
10179
*
10280
* @return bool
10381
*
104-
* @throws \Exception
10582
* @since 6.0
10683
*/
107-
public function postflight($type, $parent, $results)
84+
public function postflight($type, $parent)
10885
{
109-
$enabled = [];
110-
111-
$db = Factory::getDbo();
112-
$query = $db->getQuery(true);
113-
$app = Factory::getApplication();
114-
115-
$lang = Factory::getLanguage();
116-
$lang->load('mod_junewsultra', JPATH_SITE);
117-
11886
if(version_compare(JVERSION, '4.0.0', '>='))
11987
{
12088
$xml = file_get_contents(JPATH_SITE . '/modules/mod_junewsultra/mod_junewsultra.xml');
@@ -129,109 +97,6 @@ public function postflight($type, $parent, $results)
12997
file_put_contents(JPATH_SITE . '/modules/mod_junewsultra/mod_junewsultra.xml', $xml);
13098
}
13199

132-
foreach($results as $result)
133-
{
134-
$extension = (string) $result[ 'name' ];
135-
136-
$query->clear();
137-
138-
$query->select($db->quoteName([ 'enabled' ]));
139-
$query->from($db->quoteName('#__extensions'));
140-
$query->where($db->quoteName('name') . ' = ' . $db->quote($extension));
141-
$db->setQuery($query);
142-
143-
$enabled[ $extension ] = $db->loadResult();
144-
}
145-
146-
$html = '<style type="text/css">
147-
.juinstall {
148-
color: #333!important;
149-
font-weight: normal;
150-
margin: 0!important;
151-
padding: 0;
152-
overflow: hidden;
153-
background: #fff!important;
154-
}
155-
.juinstall-content {
156-
margin: 5% auto!important;
157-
padding: 35px 0 18px 0;
158-
width: 50%;
159-
}
160-
.juinstall .newalert {
161-
clear: both;
162-
margin: 5px 10%!important;
163-
}
164-
.juinstall p {
165-
margin-left: 0;
166-
text-align: left;
167-
}
168-
.juinstall table td .label {
169-
margin: 0 auto;
170-
}
171-
.juinstall hr {
172-
margin-top:6px;
173-
margin-bottom:6px;
174-
border:0;
175-
border-top:1px solid #eee
176-
}
177-
</style>';
178-
179-
$html .= '<div class="juinstall">
180-
<div class="juinstall-content">
181-
<h2 style="padding: 0 0 8px 0; margin: 0;">' . Text::_('MOD_JUNEWS_TITLE') . '</h2>
182-
<h2 style="padding: 0 0 8px 0; margin: 0;"><small>' . Text::_('MOD_JUNEWS_DESCRIPTION') . '</small></h2>
183-
<table class="table table-striped">
184-
<thead>
185-
<tr>
186-
<th>' . Text::_('MOD_JUNEWS_EXTENSION') . '</th>
187-
<th>' . Text::_('JSTATUS') . '</th>
188-
<th>' . Text::_('JENABLED') . '</th>
189-
</tr>
190-
</thead>
191-
<tbody>';
192-
193-
foreach($results as $result)
194-
{
195-
$extension = (string) $result[ 'name' ];
196-
197-
$html .= '<tr><td>';
198-
199-
if($extension === 'MOD_JUNEWSULTRA')
200-
{
201-
$html .= Text::_($extension);
202-
}
203-
else
204-
{
205-
$html .= $extension;
206-
}
207-
208-
$html .= '</td><td><strong>';
209-
210-
if($result[ 'result' ] === true)
211-
{
212-
$html .= '<span class="label label-success">' . Text::_('MOD_JUNEWS_INSTALLED') . '</span>';
213-
}
214-
else
215-
{
216-
$html .= '<span class="label label-important">' . Text::_('MOD_JUNEWS_NOT_INSTALLED') . '</span>';
217-
}
218-
219-
$html .= '</strong></td><td>';
220-
221-
if($enabled[ $extension ] == 1)
222-
{
223-
$html .= '<span class="label label-success">' . Text::_('JYES') . '</span>';
224-
}
225-
else
226-
{
227-
$html .= '<span class="label label-important">' . Text::_('JNO') . '</span>';
228-
}
229-
230-
$html .= '</td></tr>';
231-
}
232-
233-
$html .= '</tbody></table>';
234-
235100
$path = JPATH_SITE . '/modules/mod_junewsultra/';
236101
$files = [
237102
$path . 'assets/donate2.gif',
@@ -258,7 +123,6 @@ public function postflight($type, $parent, $results)
258123
$path . 'assets/css/default.css',
259124
$path . 'assets/css/elegant.css',
260125
$path . 'assets/css/docs.css',
261-
262126
$path . 'fields/jumultithumbradio.php',
263127
$path . 'fields/colorpicker.php',
264128
$path . 'fields/imagesetting.php',
@@ -268,11 +132,9 @@ public function postflight($type, $parent, $results)
268132
$path . 'fields/toggler30.php',
269133
$path . 'fields/donate.php',
270134
$path . 'fields/article.php',
271-
272135
$path . 'tmpl/default/images/bg.jpg',
273136
$path . 'tmpl/default/images/rating_star.png_',
274137
$path . 'tmpl/default/images/rating_star_blank.png_',
275-
276138
$path . 'img/.htaccess',
277139
$path . 'img/config.php',
278140
$path . 'img/img.php',
@@ -287,91 +149,33 @@ public function postflight($type, $parent, $results)
287149
$path . 'assets/js/minicolors'
288150
];
289151

290-
$i = 0;
291152
foreach($files as $file)
292153
{
293154
if(file_exists($file))
294155
{
295-
$i++;
156+
File::delete($file);
296157
}
297158
}
298159

299-
$j = 0;
300160
foreach($folders as $folder)
301161
{
302162
if(is_dir($folder))
303163
{
304-
$j++;
164+
$this->unlinkRecursive($folder);
305165
}
306166
}
307167

308-
if(($i + $j) > 0)
309-
{
310-
$html .= '<h2>' . Text::_('MOD_JUNEWS_REMOVE_OLD_FILES') . '</h2><table class="table table-striped"><tbody>';
311-
312-
foreach($files as $file)
313-
{
314-
if(file_exists($file))
315-
{
316-
$filepath = str_replace($path, '', $file);
317-
unlink($file);
318-
319-
$html .= '<tr><td><span class="label">File:</span> <code>' . $filepath . '</code></td><td><span class="label label-inverse">Delete</span></td></tr>';
320-
}
321-
}
322-
323-
foreach($folders as $folder)
324-
{
325-
if(is_dir($folder))
326-
{
327-
$folderpath = str_replace($path, '', $folder);
328-
$this->unlinkRecursive($folder, 1);
329-
330-
$html .= '<tr><td><span class="label">Folder:</span> <code>' . $folderpath . '</code></td><td><span class="label label-inverse">Delete</span></td></tr>';
331-
}
332-
}
333-
334-
$html .= '</tbody></table>';
335-
}
336-
337-
$html .= '</div></div>';
338-
339-
//$app->enqueueMessage($html);
340-
echo $html;
341-
342168
return true;
343169
}
344170

345-
/**
346-
* @param $dir
347-
*
348-
* @return bool
349-
*
350-
* @since version
351-
*/
352-
private function MakeDirectory($dir)
353-
{
354-
if(mkdir($dir, 0777, true) || is_dir($dir))
355-
{
356-
return true;
357-
}
358-
359-
if(!$this->MakeDirectory(dirname($dir)))
360-
{
361-
return false;
362-
}
363-
364-
return mkdir($dir, 0777, true);
365-
}
366-
367171
/**
368172
* @param $dir
369173
* @param $deleteRootToo
370174
*
371175
*
372176
* @since version
373177
*/
374-
private function unlinkRecursive($dir, $deleteRootToo)
178+
private function unlinkRecursive($dir, $deleteRootToo = 1)
375179
{
376180
if(!$dh = opendir($dir))
377181
{

0 commit comments

Comments
 (0)