-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.php
91 lines (76 loc) · 2.08 KB
/
script.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?php
/**
* JUPWA plugin
*
* @version 1.x
* @package JUPWA
* @author Denys D. Nosov ([email protected])
* @copyright (C) 2023-2024 by Denys D. Nosov (https://joomla-ua.org)
* @license GNU General Public License version 2 or later; see LICENSE.md
*
**/
defined('_JEXEC') or die('Restricted access');
use Joomla\CMS\Factory;
use Joomla\Filesystem\Folder;
class Pkg_JUPWAInstallerScript
{
/**
* @return bool
*
* @throws \Exception
* @since 7.0
*/
public function preflight()
{
$app = Factory::getApplication();
if(version_compare(JVERSION, '4.0', 'lt'))
{
$app->enqueueMessage('Update for Joomla! 4.0 +', 'error');
return false;
}
Folder::create(JPATH_SITE . '/favicons');
Folder::create(JPATH_SITE . '/images/jupwa');
Folder::create(JPATH_SITE . '/images/jupwa/icon');
Folder::create(JPATH_SITE . '/images/jupwa/logos');
Folder::create(JPATH_SITE . '/images/jupwa/icons');
Folder::create(JPATH_SITE . '/images/jupwa/images');
Folder::create(JPATH_SITE . '/images/jupwa/screenshots');
Folder::create(JPATH_SITE . '/images/jupwa/watermark');
return true;
}
public function postflight($type, $parent)
{
$db = Factory::getDbo();
$query = $db->getQuery(true);
$query->select('*');
$query->from('#__extensions');
$query->where($db->quoteName('folder') . ' = ' . $db->quote('jupwa'));
$db->setQuery($query);
$results = $db->loadObjectList();
$html = '<div class="main-card p-4">
<table class="table">
<thead class="table-light">
<tr>
<th scope="col">Extensions</th>
<th scope="col">Status</th>
</tr>
</thead>
<tbody>';
foreach($results as $result)
{
$html .= '<tr><td><strong>' . $result->name . '</strong></td><td>';
if($result->enabled == 1)
{
$html .= '<span class="tbody-icon active"><i class="icon-publish" aria-hidden="true"></i></span>';
}
else
{
$html .= '<span class="tbody-icon"><i class="icon-unpublish" aria-hidden="true"></i></span>';
}
$html .= '</td></tr>';
}
$html .= '</tbody></table></div>';
echo $html;
return true;
}
}