6
6
* @license GNU General Public License version 2 or later
7
7
*/
8
8
9
- use Joomla \CMS \Factory ;
10
- use Joomla \CMS \Filesystem \Folder ;
11
9
use Joomla \CMS \Installer \Adapter \ComponentAdapter ;
12
10
use Joomla \CMS \Installer \InstallerScript ;
13
- use Joomla \CMS \Language \Text ;
14
11
15
12
/**
16
13
* Installation class to perform additional changes during install/uninstall/update
19
16
*/
20
17
class Com_PatchtesterInstallerScript extends InstallerScript
21
18
{
22
- /**
23
- * Array of templates with supported overrides
24
- *
25
- * @var array
26
- * @since 2.0
27
- */
28
- protected $ templateOverrides = array ('atum ' );
29
-
30
19
/**
31
20
* Extension script constructor.
32
21
*
@@ -51,73 +40,6 @@ public function __construct()
51
40
);
52
41
}
53
42
54
- /**
55
- * Function to perform changes during install
56
- *
57
- * @param ComponentAdapter $parent The class calling this method
58
- *
59
- * @return void
60
- *
61
- * @since 2.0
62
- */
63
- public function install ($ parent )
64
- {
65
- $ this ->copyLayouts ();
66
- }
67
-
68
- /**
69
- * Function to perform changes during update
70
- *
71
- * @param ComponentAdapter $parent The class calling this method
72
- *
73
- * @return void
74
- *
75
- * @since 2.0
76
- */
77
- public function update ($ parent )
78
- {
79
- $ this ->copyLayouts ();
80
- }
81
-
82
- /**
83
- * Function to perform changes during uninstall
84
- *
85
- * @param ComponentAdapter $parent The class calling this method
86
- *
87
- * @return void
88
- *
89
- * @since 2.0
90
- */
91
- public function uninstall ($ parent )
92
- {
93
- // Initialize the error array
94
- $ errorTemplates = array ();
95
-
96
- // Loop the supported templates
97
- foreach ($ this ->templateOverrides as $ template )
98
- {
99
- // Set the file paths
100
- $ tmplRoot = JPATH_ADMINISTRATOR . '/templates/ ' . $ template ;
101
- $ overrideFolder = JPATH_ADMINISTRATOR . '/templates/ ' . $ template . '/html/com_patchtester ' ;
102
-
103
- // Make sure the template is actually installed
104
- if (is_dir ($ tmplRoot ))
105
- {
106
- // If there's a failure in copying the overrides, log it to the error array
107
- if (Folder::delete ($ overrideFolder ))
108
- {
109
- $ errorTemplates [] = ucfirst ($ template );
110
- }
111
- }
112
- }
113
-
114
- // If we couldn't remove any overrides, notify the user
115
- if (count ($ errorTemplates ) > 0 )
116
- {
117
- Factory::getApplication ()->enqueueMessage (Text::sprintf ('COM_PATCHTESTER_COULD_NOT_REMOVE_OVERRIDES ' , implode (', ' , $ errorTemplates )));
118
- }
119
- }
120
-
121
43
/**
122
44
* Function to perform changes during postflight
123
45
*
@@ -132,49 +54,4 @@ public function postflight($type, $parent)
132
54
{
133
55
$ this ->removeFiles ();
134
56
}
135
-
136
- /**
137
- * Function to copy layout overrides for core templates at install or update
138
- *
139
- * @return void
140
- *
141
- * @since 2.0
142
- */
143
- private function copyLayouts ()
144
- {
145
- // Initialize the error array
146
- $ errorTemplates = array ();
147
-
148
- // Loop the supported templates
149
- foreach ($ this ->templateOverrides as $ template )
150
- {
151
- // Set the file paths
152
- $ source = __DIR__ . '/ ' . $ template ;
153
- $ tmplRoot = JPATH_ADMINISTRATOR . '/templates/ ' . $ template ;
154
- $ destination = JPATH_ADMINISTRATOR . '/templates/ ' . $ template . '/html/com_patchtester ' ;
155
-
156
- // Make sure the template is actually installed
157
- if (is_dir ($ tmplRoot ))
158
- {
159
- // If there's a failure in copying the overrides, log it to the error array
160
- try
161
- {
162
- if (Folder::copy ($ source , $ destination , '' , true ))
163
- {
164
- $ errorTemplates [] = ucfirst ($ template );
165
- }
166
- }
167
- catch (RuntimeException $ exception )
168
- {
169
- $ errorTemplates [] = ucfirst ($ template );
170
- }
171
- }
172
- }
173
-
174
- // If we couldn't remove any overrides, notify the user
175
- if (count ($ errorTemplates ) > 0 )
176
- {
177
- Factory::getApplication ()->enqueueMessage (Text::sprintf ('COM_PATCHTESTER_COULD_NOT_INSTALL_OVERRIDES ' , implode (', ' , $ errorTemplates )));
178
- }
179
- }
180
57
}
0 commit comments