forked from BabDev/Tweet-Display-Back
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathscript.php
137 lines (120 loc) · 3.13 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
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
<?php
/**
* Tweet Display Back Module for Joomla!
*
* @package TweetDisplayBack
*
* @copyright Copyright (C) 2010-2013 Michael Babker. All rights reserved.
* @license GNU/GPL - http://www.gnu.org/copyleft/gpl.html
*/
/**
* Class to handle additional work during installation routine
*
* @package TweetDisplayBack
* @since 3.0
*/
class Mod_TweetDisplayBackInstallerScript
{
/**
* Function to act prior to installation process begins
*
* @param string $type The action being performed
* @param JInstallerModule $parent The function calling this method
*
* @return boolean True on success, false on failure
*
* @since 3.0
*/
public function preflight($type, $parent)
{
// Requires PHP 5.3
if (version_compare(PHP_VERSION, '5.3', 'lt'))
{
JError::raiseNotice(null, JText::_('MOD_TWEETDISPLAYBACK_ERROR_INSTALL_PHPVERSION'));
return false;
}
// Requires Joomla! 2.5.6
if (version_compare(JVERSION, '2.5.6', 'lt'))
{
JError::raiseNotice(null, JText::_('MOD_TWEETDISPLAYBACK_ERROR_INSTALL_VERSION'));
return false;
}
return true;
}
/**
* Function to perform changes during update
*
* @param JInstallerModule $parent The class calling this method
*
* @return void
*
* @since 3.0
*/
public function update($parent)
{
// Remove files deleted between versions
$this->_removeFiles();
}
/**
* Function to remove files deleted between updates
*
* @return void
*
* @since 3.0
*/
private function _removeFiles()
{
jimport('joomla.filesystem.file');
jimport('joomla.filesystem.folder');
// Remove the connector compatibility files
$base = JPATH_SITE . '/modules/mod_tweetdisplayback/';
$files = array('compat.php', 'curl.php', 'curl_25.php');
// Remove the files
foreach ($files as $file)
{
if (is_file($base . $file))
{
JFile::delete($base . $file);
}
}
// Get the language tag for the site to delete non-English language files
$langTag = JFactory::getLanguage()->getTag();
$base = JPATH_SITE . '/language/' . $langTag . '/';
$engBase = JPATH_SITE . '/language/en-GB/';
// The language files for pre-3.0
$files = array($langTag . '.mod_tweetdisplayback.ini', $langTag . '.mod_tweetdisplayback.sys.ini');
$engFiles = array('en-GB.mod_tweetdisplayback.ini', 'en-GB.mod_tweetdisplayback.sys.ini');
// Remove the files
foreach ($files as $file)
{
if (is_file($base . $file))
{
JFile::delete($base . $file);
}
}
// Check for and remove en-GB files
foreach ($engFiles as $engFile)
{
if (is_file($engBase . $engFile))
{
JFile::delete($engBase . $engFile);
}
}
// Remove the module's media folder if it exists
if (is_dir(JPATH_SITE . '/modules/mod_tweetdisplayback/media/'))
{
JFolder::delete(JPATH_SITE . '/modules/mod_tweetdisplayback/media/');
}
// The widget template files to remove
$base = JPATH_SITE . '/modules/mod_tweetdisplayback/tmpl/';
$files = array('w_list.php', 'w_profile.php', 'w_search.php');
// Remove the files
foreach ($files as $file)
{
if (is_file($base . $file))
{
JFile::delete($base . $file);
}
}
}
}