forked from BabDev/Podcast-Manager
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathscript.php
More file actions
265 lines (242 loc) · 7.21 KB
/
script.php
File metadata and controls
265 lines (242 loc) · 7.21 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
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
<?php
/**
* Podcast Manager for Joomla!
*
* @package PodcastManager
*
* @copyright Copyright (C) 2011-2015 Michael Babker. All rights reserved.
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
*
* Podcast Manager is based upon the ideas found in Podcast Suite created by Joe LeBlanc
* Original copyright (c) 2005 - 2008 Joseph L. LeBlanc and released under the GPLv2 license
*/
/**
* Installation class to perform additional changes during install/uninstall/update
*
* @package PodcastManager
* @since 2.0
*/
class Pkg_PodcastManagerInstallerScript
{
/**
* An array of supported database types
*
* @var array
* @since 2.0
*/
protected $dbSupport = array('mysql', 'mysqli', 'postgresql', 'sqlsrv', 'sqlazure');
/**
* Function to act prior to installation process begins
*
* @param string $type The action being performed
* @param JInstallerPackage $parent The class calling this method
*
* @return boolean True on success
*
* @since 2.0
*/
public function preflight($type, $parent)
{
// Requires PHP 5.3
if (version_compare(PHP_VERSION, '5.3', 'lt'))
{
JError::raiseNotice(null, JText::_('PKG_PODCASTMANAGER_ERROR_INSTALL_PHPVERSION'));
return false;
}
// Requires Joomla! 2.5.6
if (version_compare(JVERSION, '2.5.6', 'lt'))
{
JError::raiseNotice(null, JText::_('PKG_PODCASTMANAGER_ERROR_INSTALL_JVERSION'));
return false;
}
// Check to see if the database type is supported
if (!in_array(JFactory::getDbo()->name, $this->dbSupport))
{
JError::raiseNotice(null, JText::_('PKG_PODCASTMANAGER_ERROR_DB_SUPPORT'));
return false;
}
return true;
}
/**
* Function to perform changes during uninstall
*
* @param JInstallerPackage $parent The class calling this method
*
* @return void
*
* @since 2.1
*/
public function uninstall($parent)
{
// If in CMS 3, uninstall the Isis layouts
if (version_compare(JVERSION, '3.0', 'ge'))
{
/*
* Since the adapter doesn't remove folders with content, we have to remove the content here
* And, lucky us, the file scriptfile isn't copied!
*/
// Import dependencies
jimport('joomla.filesystem.folder');
jimport('joomla.filesystem.file');
// First, the array of folders we need to get the children for
$folders = array('html/com_podcastmanager', 'html/com_podcastmedia', 'js/podcastmanager');
// Set up our base path
$base = JPATH_ADMINISTRATOR . '/templates/isis/';
// Process our parent folders
foreach ($folders as $folder)
{
// Set up our full path to the folder
$path = $base . $folder;
// Get the list of child folders
$children = JFolder::folders($path);
if (count($children))
{
// Process the child folders and remove their files
foreach ($children as $child)
{
// Set the path for the child
$cPath = $path . '/' . $child;
// Get the list of files
$files = JFolder::files($cPath);
// Now, remove the files
foreach ($files as $file)
{
JFile::delete($cPath . '/' . $file);
}
}
}
}
// We need to get the extension ID for our Strapped layouts first
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('extension_id'));
$query->from($db->quoteName('#__extensions'));
$query->where($db->quoteName('name') . ' = ' . $db->quote('files_podcastmanager_strapped'));
$db->setQuery($query);
$id = $db->loadResult();
// Instantiate a new installer instance and uninstall the layouts if present
if ($id)
{
$installer = new JInstaller;
$installer->uninstall('file', $id);
}
}
}
/**
* Function to perform changes during update
*
* @param JInstallerPackage $parent The class calling this method
*
* @return void
*
* @since 2.1
*/
public function update($parent)
{
// If in CMS 3, install the Strapped layouts
if (version_compare(JVERSION, '3.0', 'ge'))
{
$installer = new JInstaller;
$installer->update(__DIR__ . '/strapped');
}
}
/**
* Function to act after the installation process runs
*
* @param string $type The action being performed
* @param JInstallerPackage $parent The class calling this method
* @param array $results The results of each installer action
*
* @return void
*
* @since 2.0
*/
public function postflight($type, $parent, $results)
{
// If in CMS 3, install the Strapped layouts
if (version_compare(JVERSION, '3.0', 'ge') && $type == 'install')
{
$installer = new JInstaller;
$strapped = $installer->install(__DIR__ . '/strapped');
}
// Determine whether each extension is enabled or not
$enabled = array();
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName('enabled'));
$query->from($db->quoteName('#__extensions'));
foreach ($results as $result)
{
$extension = (string) $result['name'];
$query->clear('where');
$query->where($db->quoteName('name') . ' = ' . $db->quote($extension));
$db->setQuery($query);
$enabled[$extension] = $db->loadResult();
}
?>
<table class="adminlist table table-striped">
<thead>
<tr>
<th class="title"><?php echo JText::_('PKG_PODCASTMANAGER_EXTENSION'); ?></th>
<th class="title" width="20%"><?php echo JText::_('PKG_PODCASTMANAGER_TYPE'); ?></th>
<th class="title" width="20%"><?php echo JText::_('JSTATUS'); ?></th>
<th class="title" width="15%"><?php echo JText::_('JENABLED'); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4"></td>
</tr>
</tfoot>
<tbody>
<?php foreach ($results as $result) :
$extension = (string) $result['name'];
$e_type = substr($extension, 0, 3); ?>
<tr class="row<?php echo ($result % 2); ?>">
<td class="key"><?php echo JText::_(strtoupper($extension)); ?></td>
<td><strong>
<?php if ($e_type == 'com') :
echo JText::_('COM_INSTALLER_TYPE_COMPONENT');
elseif ($e_type == 'mod') :
echo JText::_('COM_INSTALLER_TYPE_MODULE');
elseif ($e_type == 'plg') :
echo JText::_('COM_INSTALLER_TYPE_PLUGIN');
elseif ($e_type == 'get') :
echo JText::_('COM_INSTALLER_TYPE_LIBRARY');
endif; ?></strong>
</td>
<td><strong>
<?php if ($result['result'] == true) :
echo JText::_('PKG_PODCASTMANAGER_INSTALLED');
else :
echo JText::_('PKG_PODCASTMANAGER_NOT_INSTALLED');
endif; ?></strong>
</td>
<td><strong>
<?php if ($enabled[$extension] == 1) :
echo JText::_('JYES');
else :
echo JText::_('JNO');
endif; ?></strong>
</td>
</tr>
<?php endforeach;
if (version_compare(JVERSION, '3.0', 'ge')) : ?>
<tr class="row0">
<td class="key"><?php echo JText::_('PKG_PODCASTMANAGER_STRAPPED'); ?></td>
<td><strong><?php echo JText::_('COM_INSTALLER_TYPE_FILE'); ?></strong></td>
<td><strong>
<?php if ($strapped == true) :
echo JText::_('PKG_PODCASTMANAGER_INSTALLED');
else :
echo JText::_('PKG_PODCASTMANAGER_NOT_INSTALLED');
endif; ?></strong>
</td>
<td><strong><?php echo JText::_('PKG_PODCASTMANAGER_NA'); ?></strong></td>
</tr>
<?php endif; ?>
</tbody>
</table>
<?php
}
}