-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathscript.php
More file actions
220 lines (181 loc) · 9.14 KB
/
Copy pathscript.php
File metadata and controls
220 lines (181 loc) · 9.14 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
<?php
/**
* @package Joomla.Site
* @subpackage Modules - mod_jbcookies
*
* @author JoomBall! Project
* @link http://www.joomball.com
* @copyright Copyright © 2011-2026 JoomBall! Project. All Rights Reserved.
* @license GNU/GPL, http://www.gnu.org/licenses/gpl-3.0.html
*/
defined('_JEXEC') or die;
use Joomla\CMS\Factory;
use Joomla\Filesystem\File;
use Joomla\Filesystem\Folder;
use Joomla\CMS\Version;
use Joomla\CMS\Language\Text;
class Mod_JBCookiesInstallerScript {
protected string $extension = 'mod_jbcookies';
protected ?string $release = null;
protected ?string $last_version = null;
protected ?string $minimum_joomla_release = null;
public function install( $parent ) {
$lang = Factory::getLanguage();
$basePathLanguage = JPATH_ROOT . '/media/jbmedia';
$lang->load('install', $basePathLanguage, null, false, true)
|| $lang->load('install', $basePathLanguage, $lang->getDefault(), false, true);
$status = new stdClass();
$result = null;
self::displayInstall($parent, $result);
?><h1><?php echo Text::_('JB_INSTALL_INSTALLATION'); ?></h1><?php
return true;
}
/**
* Method to update Joomla!
*
* @param Installer $installer The class calling this method
*
* @return void
*/
public function update($installer) {
// Idioma es necessari aquí
$lang = Factory::getLanguage();
$basePathLanguage = JPATH_ROOT . '/media/jbmedia';
$lang->load('install', $basePathLanguage, null, false, true)
|| $lang->load('install', $basePathLanguage, $lang->getDefault(), false, true);
$status = new stdClass();
// echo '<pre>'; echo print_r($installer); echo '</pre>'; exit;
$result = null;
// Installing component manifest file version
$this->release = $installer->getManifest()->version;
if ($this->release <= '3.1.6') {
$pathSite = JPATH_SITE.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'mod_jbcookies';
// Eliminem Arxius innecesaris
$files = array($pathSite.'/tmpl/custom.php', $pathSite.'/tmpl/decline.php', $pathSite.'/tmpl/default_decline.php');
File::delete($files);
}
if ($this->release <= '4.0.0') {
$pathSite = JPATH_SITE.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'mod_jbcookies';
// Eliminem Arxius innecesaris
$files = array($pathSite.'/index.html', $pathSite.'/helper.php', $pathSite.'/script.install.php',
$pathSite.'/tmpl/index.html',
$pathSite.'/language/index.html',
$pathSite.'/language/ca-ES/index.html', $pathSite.'/language/ca-ES/ca-ES.mod_jbcookies.ini', $pathSite.'/language/ca-ES/ca-ES.mod_jbcookies.sys.ini',
$pathSite.'/language/de-DE/index.html', $pathSite.'/language/de-DE/de-DE.mod_jbcookies.ini', $pathSite.'/language/de-DE/de-DE.mod_jbcookies.sys.ini',
$pathSite.'/language/el-GR/index.html', $pathSite.'/language/el-GR/el-GR.mod_jbcookies.ini', $pathSite.'/language/el-GR/el-GR.mod_jbcookies.sys.ini',
$pathSite.'/language/en-GB/index.html', $pathSite.'/language/en-GB/en-GB.mod_jbcookies.ini', $pathSite.'/language/en-GB/en-GB.mod_jbcookies.sys.ini',
$pathSite.'/language/es-ES/index.html', $pathSite.'/language/es-ES/es-ES.mod_jbcookies.ini', $pathSite.'/language/es-ES/es-ES.mod_jbcookies.sys.ini',
$pathSite.'/language/fr-FR/index.html', $pathSite.'/language/fr-FR/fr-FR.mod_jbcookies.ini', $pathSite.'/language/fr-FR/fr-FR.mod_jbcookies.sys.ini',
$pathSite.'/language/it-IT/index.html', $pathSite.'/language/it-IT/it-IT.mod_jbcookies.ini', $pathSite.'/language/it-IT/it-IT.mod_jbcookies.sys.ini',
$pathSite.'/language/nl-NL/index.html', $pathSite.'/language/nl-NL/nl-NL.mod_jbcookies.ini', $pathSite.'/language/nl-NL/nl-NL.mod_jbcookies.sys.ini',
$pathSite.'/language/pl-PL/index.html', $pathSite.'/language/pl-PL/pl-PL.mod_jbcookies.ini', $pathSite.'/language/pl-PL/pl-PL.mod_jbcookies.sys.ini',
$pathSite.'/language/pt-PT/index.html', $pathSite.'/language/pt-PT/pt-PT.mod_jbcookies.ini', $pathSite.'/language/pt-PT/pt-PT.mod_jbcookies.sys.ini',
$pathSite.'/language/sv-SE/index.html', $pathSite.'/language/sv-SE/sv-SE.mod_jbcookies.ini', $pathSite.'/language/sv-SE/sv-SE.mod_jbcookies.sys.ini');
File::delete($files);
self::deleteFolder($pathSite.'/assets');
self::deleteFolder($pathSite.'/fields');
}
if ($this->release <= '6.0.1') {
$pathSite = JPATH_SITE.DIRECTORY_SEPARATOR.'modules'.DIRECTORY_SEPARATOR.'mod_jbcookies';
// Eliminem Arxius innecesaris
$files = array( $pathSite.'/index.html', $pathSite.'/helper.php', $pathSite.'/script.install.php', $pathSite.'/tmpl/default_custom.php', $pathSite.'/tmpl/default_decline.php',
$pathSite.'/tmpl/index.html', $pathSite.'/mod_jbcookies.php',
$pathSite.'/language/index.html',
$pathSite.'/language/ca-ES/index.html', $pathSite.'/language/ca-ES/ca-ES.mod_jbcookies.ini', $pathSite.'/language/ca-ES/ca-ES.mod_jbcookies.sys.ini',
$pathSite.'/language/de-DE/index.html', $pathSite.'/language/de-DE/de-DE.mod_jbcookies.ini', $pathSite.'/language/de-DE/de-DE.mod_jbcookies.sys.ini',
$pathSite.'/language/el-GR/index.html', $pathSite.'/language/el-GR/el-GR.mod_jbcookies.ini', $pathSite.'/language/el-GR/el-GR.mod_jbcookies.sys.ini',
$pathSite.'/language/en-GB/index.html', $pathSite.'/language/en-GB/en-GB.mod_jbcookies.ini', $pathSite.'/language/en-GB/en-GB.mod_jbcookies.sys.ini',
$pathSite.'/language/es-ES/index.html', $pathSite.'/language/es-ES/es-ES.mod_jbcookies.ini', $pathSite.'/language/es-ES/es-ES.mod_jbcookies.sys.ini',
$pathSite.'/language/fr-FR/index.html', $pathSite.'/language/fr-FR/fr-FR.mod_jbcookies.ini', $pathSite.'/language/fr-FR/fr-FR.mod_jbcookies.sys.ini',
$pathSite.'/language/it-IT/index.html', $pathSite.'/language/it-IT/it-IT.mod_jbcookies.ini', $pathSite.'/language/it-IT/it-IT.mod_jbcookies.sys.ini',
$pathSite.'/language/nl-NL/index.html', $pathSite.'/language/nl-NL/nl-NL.mod_jbcookies.ini', $pathSite.'/language/nl-NL/nl-NL.mod_jbcookies.sys.ini',
$pathSite.'/language/pl-PL/index.html', $pathSite.'/language/pl-PL/pl-PL.mod_jbcookies.ini', $pathSite.'/language/pl-PL/pl-PL.mod_jbcookies.sys.ini',
$pathSite.'/language/pt-PT/index.html', $pathSite.'/language/pt-PT/pt-PT.mod_jbcookies.ini', $pathSite.'/language/pt-PT/pt-PT.mod_jbcookies.sys.ini',
$pathSite.'/language/sv-SE/index.html', $pathSite.'/language/sv-SE/sv-SE.mod_jbcookies.ini', $pathSite.'/language/sv-SE/sv-SE.mod_jbcookies.sys.ini');
File::delete($files);
self::deleteFolder($pathSite.'/assets');
self::deleteFolder($pathSite.'/fields');
}
// Afegim plantilla
self::displayInstall($installer, $result);
?><h1><?php echo Text::_('JB_INSTALL_UPDATE'); ?></h1><?php
$jversion = new Version();
$this->last_version = $this->getParam('version');
// Manifest file minimum Joomla version
$this->minimum_joomla_release = $installer->getManifest()->attributes()->version;
// Show the essential information at the install/update back-end
echo '<p>Installing component manifest file version = ' . $this->release . '</p>';
echo '<p>Current manifest cache component version = ' . $this->last_version . '</p>';
echo '<p>Installing component manifest file minimum Joomla version = ' . $this->minimum_joomla_release . '</p>';
echo '<p>Current Joomla version = ' . $jversion->getShortVersion() . '</p>';
return true;
}
public function getParam( $name ) {
$db = Factory::getDbo();
$db->setQuery('SELECT manifest_cache FROM #__extensions WHERE name = ' . $db->quote($this->extension));
$manifest = json_decode($db->loadResult(), true);
return $manifest[ $name ];
}
/**
* creates a folder with empty html file
*
*
*/
public function createIndexFolder($path){
if(Folder::exists($path)) {
return 'exist';
}
if(Folder::create($path)) {
if(!File::exists($path .DIRECTORY_SEPARATOR. 'index.html')){
File::copy(JPATH_ROOT.DIRECTORY_SEPARATOR.'components'.DIRECTORY_SEPARATOR.'index.html', $path .DIRECTORY_SEPARATOR. 'index.html');
}
return 'create';
}
return false;
}
/**
* delete a folder *
*
*/
public function deleteFolder($folderPath){
if (is_dir($folderPath)) Folder::delete($folderPath);
}
public function displayInstall($parent, $status) {
// Installing component manifest file version
$this->release = $parent->getManifest()->version; ?>
<style>
/* TAULA */
.table th {
padding-top: 40px;
}
.table td {
font-weight: normal;;
}
</style>
<h2><?php echo Text::_('JB_INSTALL_INSTALLATION_STATUS'); ?></h2>
<table class="table table-striped">
<thead>
<tr>
<th><?php echo Text::_('JB_INSTALL_EXTENSION'); ?></th>
<th><?php echo Text::_('JVERSION'); ?></th>
<th colspan="3"><?php echo Text::_('JB_INSTALL_DESCRIPTION'); ?></th>
<th><?php echo Text::_('JSTATUS'); ?></th>
</tr>
</thead>
<tbody>
<tr>
<td>
<?php echo $this->extension; ?>
</td>
<td>
<?php echo $this->release; ?>
</td>
<td style="width: 100%;" colspan="3"><?php echo Text::_(strtoupper($this->extension).'_XML_DESCRIPTION'); ?></td>
<td><span style="color:green"><strong><em><?php echo Text::_('JB_INSTALL_INSTALLED'); ?></em></strong></span></td>
</tr>
</tbody>
</table>
<?php
}
}
?>