This repository has been archived by the owner on Apr 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathmod_osmod.script.php
96 lines (81 loc) · 3.26 KB
/
mod_osmod.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
92
93
94
95
96
<?php
/**
* @copyright Copyright (C) Martin Kröll. All Rights Reserved.
* @license http://www.gnu.org/licenses/gpl-3.0.html GNU/GPL
*/
// No direct access to this file
defined('_JEXEC') or die('Restricted access');
function rrmdir($dir) {
if (is_dir($dir)) {
$objects = scandir($dir);
foreach ($objects as $object) {
if ($object != "." && $object != "..") {
if (filetype($dir."/".$object) == "dir") rrmdir($dir."/".$object); else unlink($dir."/".$object);
}
}
reset($objects);
rmdir($dir);
}
}
class mod_osmodInstallerScript
{
// Move to the module site after installation
function install($parent) {
// $parent is the class calling this method
$parent->getParent()->setRedirectURL('index.php?option=com_modules');
}
// Show after uninstall message
function uninstall($parent) {
echo '<p>' . JText::_('MOD_OSMOD_UNINSTALL') . '</p>';
}
// Show after update message
function update($parent) {
// $parent is the class calling this method
echo '<p>' . JText::sprintf('MOD_OSMOD_UPDATE', $parent->get('manifest')->version) . '</p>';
echo '<p><b>Please note, the support for MapQuest has been dropped.</b></p>';
}
// Before install/update/uninstall
function preflight($type, $parent) {
// $type is the type of change (install, update or discover_install)
echo '<p>' . JText::_('MOD_OSMOD_PREFLIGHT') . '<ul>';
// Remove FR language pack
$db = JFactory::getDBO();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('extension_id', 'name')))
->from($db->quoteName('#__extensions'))
->where($db->quoteName('element') . ' = '. $db->quote('OSModulFrenchPack'));
$db->setQuery($query);
$frPack = $db->loadRow();
if(!empty($frPack)) {
echo '<li>' . $frPack[1] . '</li>';
$query = $db->getQuery(true);
$query->delete($db->quoteName('#__extensions'))
->where($db->quoteName('extension_id') . ' = '. $frPack[0]);
$db->setQuery($query);
$db->execute();
rrmdir(JPATH_ROOT . '/modules/mod_osmod/language/fr-FR');
}
// Remove files from older releases
$folders = array('/modules/mod_osmod/leaflet',
'/modules/mod_osmod/images');
$files = array('/language/de-DE/de-DE.mod_osmod.ini',
'/language/de-DE/de-DE.mod_osmod.sys.ini',
'/language/en-GB/en-GB.mod_osmod.ini',
'/language/en-GB/en-GB.mod_osmod.sys.ini');
foreach ($folders as &$f) {
if (file_exists(JPATH_ROOT . $f)) {
echo '<li>' . JPATH_ROOT . $f . '</li>';
rrmdir(JPATH_ROOT . $f);
}
}
foreach ($files as &$f) {
if (file_exists(JPATH_ROOT . $f)) {
echo '<li>' . JPATH_ROOT . $f . '</li>';
unlink(JPATH_ROOT . $f);
}
}
echo '</ul>' . JText::_('MOD_OSMOD_DONE') . '</p>';
}
// After install/update/uninstall
function postflight($type, $parent) {}
}