-
Notifications
You must be signed in to change notification settings - Fork 16
/
installer.script.php
322 lines (283 loc) · 11 KB
/
installer.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
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
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
<?php
/**
* @package SP Page Builder
* @author JoomShaper http://www.joomshaper.com
* @copyright Copyright (c) 2010 - 2016 JoomShaper
* @license http://www.gnu.org/licenses/gpl-2.0.html GNU/GPLv2 or later
*/
//no direct accees
defined ('_JEXEC') or die ('restricted access');
class com_sppagebuilderInstallerScript {
/**
* method to uninstall the component
*
* @return void
*/
public function uninstall($parent) {
$db = JFactory::getDBO();
$status = new stdClass;
$status->modules = array();
$manifest = $parent->getParent()->manifest;
// Uninstall Plugins
$plugins = $manifest->xpath('plugins/plugin');
foreach ($plugins as $plugin) {
$name = (string)$plugin->attributes()->name;
$group = (string)$plugin->attributes()->group;
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('extension_id')));
$query->from($db->quoteName('#__extensions'));
$query->where($db->quoteName('type') . ' = '. $db->quote('plugin'));
$query->where($db->quoteName('element') . ' = '. $db->quote($name));
$query->where($db->quoteName('folder') . ' = '. $db->quote($group));
$db->setQuery($query);
$extensions = $db->loadColumn();
if (count($extensions)) {
foreach ($extensions as $id) {
$installer = new JInstaller;
$result = $installer->uninstall('plugin', $id);
}
$status->plugins[] = array('name' => $name, 'result' => $result);
}
}
// Uninstal Modules
$modules = $manifest->xpath('modules/module');
foreach ($modules as $module)
{
$name = (string)$module->attributes()->module;
$client = (string)$module->attributes()->client;
$db = JFactory::getDBO();
$query = "SELECT `extension_id` FROM `#__extensions` WHERE `type`='module' AND element = ".$db->Quote($name)."";
$db->setQuery($query);
$extensions = $db->loadColumn();
if (count($extensions))
{
foreach ($extensions as $id)
{
$installer = new JInstaller;
$result = $installer->uninstall('module', $id);
}
$status->modules[] = array('name' => $name, 'client' => $client, 'result' => $result);
}
}
}
/**
* method to run before an install/update/uninstall method
*
* @return void
*/
public function preflight($type, $parent) {
// Remove Free Updater
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$conditions = array($db->quoteName('location') . ' = ' . $db->quote('http://www.joomshaper.com/updates/com-sp-page-builder-free.xml'));
$query->delete($db->quoteName('#__update_sites'));
$query->where($conditions);
$db->setQuery($query);
$db->execute();
}
/**
* method to run after an install/update/uninstall method
*
* @return void
*/
public function postflight($type, $parent) {
$db = JFactory::getDBO();
$status = new stdClass;
$status->modules = array();
$src = $parent->getParent()->getPath('source');
$manifest = $parent->getParent()->manifest;
// Install Plugins
$plugins = $manifest->xpath('plugins/plugin');
foreach ($plugins as $plugin) {
$name = (string)$plugin->attributes()->name;
$group = (string)$plugin->attributes()->group;
$path = $src . '/plugins/' . $group . '/' . $name;
$installer = new JInstaller;
$result = $installer->install($path);
if ($result) {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$fields = array( $db->quoteName('enabled') . ' = 1' );
$conditions = array(
$db->quoteName('type') . ' = ' . $db->quote('plugin'),
$db->quoteName('element') . ' = ' . $db->quote($name),
$db->quoteName('folder') . ' = ' . $db->quote($group)
);
$query->update($db->quoteName('#__extensions'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
}
}
// Install Modules
$modules = $manifest->xpath('modules/module');
foreach ($modules as $module) {
$name = (string)$module->attributes()->module;
$client = (string)$module->attributes()->client;
$path = $src . '/modules/' . $client . '/' . $name;
$position = (isset($module->attributes()->position) && $module->attributes()->position) ? (string)$module->attributes()->position : '';
$ordering = (isset($module->attributes()->ordering) && $module->attributes()->ordering) ? (string)$module->attributes()->ordering : 0;
$installer = new JInstaller;
$result = $installer->install($path);
if($client == 'administrator') {
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$fields = array();
$fields[] = $db->quoteName('published') . ' = 1';
if($position) {
$fields[] = $db->quoteName('position') . ' = ' . $db->quote($position);
}
if($ordering) {
$fields[] = $db->quoteName('ordering') . ' = ' . $db->quote($ordering);
}
$conditions = array(
$db->quoteName('module') . ' = ' . $db->quote($name)
);
$query->update($db->quoteName('#__modules'))->set($fields)->where($conditions);
$db->setQuery($query);
$db->execute();
// Retrive ID
$db = JFactory::getDbo();
$query = $db->getQuery(true);
$query->select($db->quoteName(array('id')));
$query->from($db->quoteName('#__modules'));
$query->where($db->quoteName('module') . ' = ' . $db->quote($name));
$db->setQuery($query);
$id = (int) $db->loadResult();
// New
if($id) {
$db = JFactory::getDbo();
$db->setQuery("INSERT IGNORE INTO #__modules_menu (`moduleid`,`menuid`) VALUES (".$id.", 0)");
$db->query();
}
}
}
if ($type == 'uninstall') {
return true;
} ?>
<style type="text/css">
.sppb-installation-wrap{
padding: 40px;
overflow: hidden;
background-color: #0080FE;
color: #fff;
font-size: 16px;
line-height: 26px;
box-sizing: border-box;
margin-bottom: 30px;
}
.sppb-installation-wrap .sppb-installation-left {
float: left;
width: 128px;
height: 128px;
line-height: 128px;
text-align: center;
margin-right: 15px;
background-color: #fff;
border-radius: 3px;
box-shadow: 0 0 5px rgba(0,0,0,0.15);
}
.sppb-installation-wrap .sppb-installation-left img{
display: inline-block;
}
.sppb-installation-wrap .sppb-installation-texts p{
margin-bottom: 26px;
}
.sppb-installation-wrap .sppb-installation-texts h2{
font-size: 24px;
vertical-align: middle;
}
.sppb-installation-wrap .sppb-installation-texts h2 span{
font-size: 16px;
color: rgab(255,255,255,0.88);
border-left: 1px solid rgba(255,255,255, 0.45);
padding-left: 20px;
margin-left: 20px;
vertical-align: middle;
}
.sppb-installation-wrap .sppb-installation-footer{
margin-top: 60px;
}
.sppb-installation-wrap .sppb-installation-footer a{
margin-right: 10px;
}
.sppb-installation-wrap .sppb-installation-jed{
background-color: #03E16D;
padding: 20px;
border-radius: 3px;
}
.sppb-installation-wrap .sppb-installation-jed span{
display: block;
font-size: 36px;
float: left;
width: 36px;
height: 50px;
line-height: 50px;
margin-right: 15px;
}
.sppb-installation-wrap .sppb-installation-jed h3{
margin-top: 0;
}
.sppb-installation-wrap .sppb-installation-jed p{
margin-bottom: 0;
}
.sppb-installation-wrap .sppb-installation-jed p a{
color: #fff;
text-decoration: underline;
font-style: italic;
}
.sppb-installation-wrap .btn-sppb-custom{
background-color: #fff;
border: none;
font-size: 14px;
padding: 10px 15px;
color: #0080FE;
font-weight: 500;
border-radius: 3px;
}
.sppb-installation-wrap .pagebuilder-social-links{
margin-top: 30px;
}
.sppb-installation-wrap .pagebuilder-social-links a{
color: #fff;
font-size: 14px;
text-decoration: none;
margin-right: 20px;
}
</style>
<link href="<?php echo JURI::base() . 'components/com_sppagebuilder/assets/css/font-awesome.min.css'; ?>" rel="stylesheet">
<div class="sppb-installation-wrap row-fluid">
<div class="span4 sppb-installation-left span2">
<img src="<?php echo JURI::root(); ?>administrator/components/com_sppagebuilder/assets/img/icon.svg" alt="SP Page Builder" />
</div> <!-- /.sppb-installation-left -->
<div class="sppb-installation-right span8">
<div class="sppb-installation-texts">
<h2>SP Page Builder Lite <span>Version: 3.0</span></h2>
<p>Trusted by <strong>200,000+</strong> people worldwide, SP Page Builder is an extremely powerful drag & drop design system.<br/>
Whether you're a beginner or a professional, you must love taking control over your website design.</p>
<p>With SP Page Builder, you can build a unique, stunning and functional site without coding a single line.<br/>
Using the tool, anyone can build a professional quality site in minutes.</p>
<div class="sppb-installation-jed">
<span class="fa fa-thumbs-o-up"></span>
<h3>Rate us on JED</h3>
<p>If you foud this product useful for you then please rate this product on <a href="https://extensions.joomla.org/extension/sp-page-builder/" target="_blank">Joomla Extension Directory</a>.</p>
</div>
</div>
<div class="sppb-installation-footer">
<div class="pagebuilder-links">
<a class="btn btn-sppb-custom" href="index.php?option=com_sppagebuilder&task=page.add" target="_blank"><span class="fa fa-plus-circle"></span> Create a New Page</a>
<a class="btn btn-sppb-custom" href="https://www.joomshaper.com/forums/categories/page-builder" target="_blank"><span class="fa fa-support"></span> Support Forum</a>
<a class="btn btn-sppb-custom" href="#" target="_blank"><span class="fa fa-play-circle-o"></span> Videos</a>
<a class="btn btn-sppb-custom" href="https://www.joomshaper.com/documentation/sp-page-builder/sp-page-builder-3" target="_blank"><span class="fa fa-book"></span> Documentation</a>
</div>
<div class="pagebuilder-social-links">
<a href="https://www.facebook.com/joomshaper" target="_blank"><span class="fa fa-facebook-square"></span> Like us on FaceBook</a>
<a href="https://twitter.com/joomshaper" target="_blank"><span class="fa fa-twitter-square"></span> Follow us on Twitter</a>
<a href="https://www.youtube.com/user/joomshaper" target="_blank"><span class="fa fa-youtube"></span> Subscribe us on YouTube</a>
</div>
</div>
</div> <!-- /.sppb-installation-right -->
</div> <!-- /.sppb-installation-wrap -->
<?php
}
}