-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.script.php
177 lines (154 loc) · 5.84 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
<?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 aceess');
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;
// 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 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: 20px 0 40px;
overflow: hidden;
}
.sppb-installation-wrap .sppb-installation-left {
float: left;
width: 250px;
margin-right: 15px;
}
.sppb-installation-wrap .sppb-installation-footer{
margin-top: 30px;
}
.sppb-installation-wrap .sppb-installation-footer a{
margin-right: 10px;
}
</style>
<div class="sppb-installation-wrap row-fluid">
<div class="span4 sppb-installation-left span2">
<img src="../media/com_sppagebuilder/images/logo-pagebuilder.jpg" alt="SP Page Builder" />
</div> <!-- /.sppb-installation-left -->
<div class="sppb-installation-right span8">
<div class="sppb-installation-texts">
<h2>SP Page Builder Lite</h2>
<p>Trusted by 250,000+ 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>
<div class="sppb-installation-footer">
<div class="pagebuilder-links">
<a class="btn btn-success" href="index.php?option=com_sppagebuilder">Get Started</a>
<a class="btn btn-info" href="index.php?option=com_sppagebuilder&task=page.add" target="_blank">Create a New Page</a>
<a class="btn btn-warning" href="https://www.joomshaper.com/documentation/joomla-extensions/sp-page-builder-2-x" target="_blank">Documentation</a>
</div>
</div>
</div> <!-- /.sppb-installation-right -->
</div> <!-- /.sppb-installation-wrap -->
<?php
}
}