-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathinstall.package.php
263 lines (233 loc) · 9.17 KB
/
install.package.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
<?php
/**
* This is the special installer addon created by Andrew Eddie and the team of jXtended.
* We thank for this cool idea of extending the installation process easily
* @copyright 2005-2008 New Life in IT Pty Ltd. All rights reserved.
*/
/**
* @version $Id$
* @package virtualdomains
* @subpackage Base
* @author EasyJoomla {@link http://www.easy-joomla.org Easy-Joomla.org}
* @author Michael Liebler {@link http://www.janguo.de}
* @author Created on 14-Aug-09
*/
//--No direct access
defined('_JEXEC') or die('=;)');
$status = new JObject();
$status->modules = array();
$status->plugins = array();
//no frontend menu item for VD
$db = & JFactory::getDBO();
$query = "UPDATE #__components set link='' WHERE `option` = 'com_virtualdomains'";
$db->setQuery($query);
$db->query();
//check if table virtualdomain already exists
$is_update = in_array($db->getPrefix().'virtualdomain', $db->getTableList());
//prepare the new json parameters
if ($is_update ) {
$found_params = array();
$query = "SELECT COUNT( * ) FROM #__virtualdomain WHERE SUBSTRING( `params` , 1, 1 ) = '{'";
$db->setQuery($query);
$newParams=$db->loadResult();
if (!$newParams) {
$query = "SELECT * FROM #__virtualdomain";
$db->setQuery($query);
$rows=$db->loadObjectList();
for ($i=0;$i<count($rows);$i++) {
$obj = new JParameter($rows[$i]->params);
$params = json_encode($obj->toArray());
$found_params = array_merge($found_params, $obj->toArray());
$query = "UPDATE #__virtualdomain SET `params`=".$db->Quote($params)." WHERE id = ".(int) $rows[$i]->id;
$db->setQuery($query);
$db->query();
}
}
}
/***********************************************************************************************
* ---------------------------------------------------------------------------------------------
* PLUGIN INSTALLATION SECTION
* ---------------------------------------------------------------------------------------------
***********************************************************************************************/
$plugins = &$this->manifest->getElementByPath('plugins');
if (is_a($plugins, 'JSimpleXMLElement') && count($plugins->children()))
foreach ($plugins->children() as $plugin) {
$pname = $plugin->attributes('plugin');
$pgroup = $plugin->attributes('group');
$porder = $plugin->attributes('order');
//--Set the installation path
if ( ! empty($pname) && ! empty($pgroup)) {
$this->parent->setPath('extension_root', JPATH_ROOT.'/plugins/'.$pgroup);
} else {
$this->parent->abort(JText::_('Plugin').' '.JText::_('Install').': '.JText::_('No plugin file specified'));
return false;
}
/**
* ---------------------------------------------------------------------------------------------
* Filesystem Processing Section
* ---------------------------------------------------------------------------------------------
*/
//--If the plugin directory does not exist, lets create it
$created = false;
if ( ! file_exists($this->parent->getPath('extension_root'))) {
if ( ! $created = JFolder::create($this->parent->getPath('extension_root'))) {
$this->parent->abort(JText::_('Plugin').' '.JText::_('Install').': '.JText::_('Failed to create directory').': "'.$this->parent->getPath('extension_root').'"');
return false;
}
}
/*
* If we created the plugin directory and will want to remove it if we
* have to roll back the installation, lets add it to the installation
* step stack
*/
if ($created) {
$this->parent->pushStep(array ('type' => 'folder', 'path' => $this->parent->getPath('extension_root')));
}
//--Copy all necessary files
$element = &$plugin->getElementByPath('files');
if ($this->parent->parseFiles($element, -1) === false) {
//--Install failed, roll back changes
$this->parent->abort();
return false;
}
//--Copy all necessary files
$element = &$plugin->getElementByPath('languages');
if ($this->parent->parseLanguages($element, 1) === false) {
//--Install failed, roll back changes
$this->parent->abort();
return false;
}
//--Copy media files
$element = &$plugin->getElementByPath('media');
if ($this->parent->parseMedia($element, 1) === false) {
//--Install failed, roll back changes
$this->parent->abort();
return false;
}
/**
* ---------------------------------------------------------------------------------------------
* Database Processing Section
* ---------------------------------------------------------------------------------------------
*/
$db = &JFactory::getDBO();
//--Check to see if a plugin by the same name is already installed
$query = 'SELECT `id`' .
' FROM `#__plugins`' .
' WHERE folder = '.$db->Quote($pgroup) .
' AND element = '.$db->Quote($pname);
$db->setQuery($query);
if ( ! $db->Query()) {
//--Install failed, roll back changes
$this->parent->abort(JText::_('Plugin').' '.JText::_('Install').': '.$db->stderr(true));
return false;
}
$id = $db->loadResult();
//--Was there a plugin already installed with the same name?
if ($id) {
if ( ! $this->parent->getOverwrite()) {
//--Install failed, roll back changes
$this->parent->abort(JText::_('Plugin').' '.JText::_('Install').': '.JText::_('Plugin').' "'.$pname.'" '.JText::_('already exists!'));
return false;
}
} else {
$row =& JTable::getInstance('plugin');
$row->name = JText::_(ucfirst($pgroup)).' - '.JText::_(ucfirst($pname));
$row->ordering = $porder;
$row->folder = $pgroup;
$row->iscore = 0;
$row->access = 0;
$row->client_id = 0;
$row->element = $pname;
$row->published = 1;
$row->params = '';
if ( ! $row->store()) {
//--Install failed, roll back changes
$this->parent->abort(JText::_('Plugin').' '.JText::_('Install').': '.$db->stderr(true));
return false;
}
}
$status->plugins[] = array('name'=>$pname,'group'=>$pgroup);
}//foreach
/***********************************************************************************************
* ---------------------------------------------------------------------------------------------
* SETUP DEFAULTS
* ---------------------------------------------------------------------------------------------
***********************************************************************************************/
/***********************************************************************************************
* ---------------------------------------------------------------------------------------------
* Execute specific system steps to ensure a consistent installtion
* ---------------------------------------------------------------------------------------------
***********************************************************************************************/
/***********************************************************************************************
* ---------------------------------------------------------------------------------------------
* OUTPUT TO SCREEN
* ---------------------------------------------------------------------------------------------
***********************************************************************************************/
$rows = 0;
?>
<h2>Virtual Domains Installation</h2>
<?php
if (isset($found_params) && count($found_params)) {
?>
<span style="color:red;font-size:1.4em">Attention! Found custom parameters in virtualdomains table.<br />
Please go to <a href="index.php?option=com_virtualdomains&view=params">Virtualdomains->Params</a> and add the following parameters manually:</span>
<ul>
<?php
foreach ($found_params as $key => $value) {
echo '<li>'.$key.'</li>';
}
?>
</ul>
<span style="color:red">
You can ignore this notice, if you don't use the parameters above.
</span>
<?php
}
?>
<table class="adminlist">
<thead>
<tr>
<th class="title" colspan="2"><?php echo JText::_('Extension'); ?></th>
<th width="30%"><?php echo JText::_('Status'); ?></th>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="3"></td>
</tr>
</tfoot>
<tbody>
<tr class="row0">
<td class="key" colspan="2"><?php echo 'virtualdomains '.JText::_('Component'); ?></td>
<td><img src="images/publish_g.png" alt="OK" /> <strong><?php echo JText::_('Installed'); ?></strong></td>
</tr>
<?php if (count($status->modules)) : ?>
<tr>
<th><?php echo JText::_('Module'); ?></th>
<th><?php echo JText::_('Client'); ?></th>
<th></th>
</tr>
<?php foreach ($status->modules as $module) : ?>
<tr class="row<?php echo (++ $rows % 2); ?>">
<td class="key"><?php echo $module['name']; ?></td>
<td class="key"><?php echo ucfirst($module['client']); ?></td>
<td><img src="images/publish_g.png" alt="OK" /> <strong><?php echo JText::_('Installed'); ?></strong></td>
</tr>
<?php endforeach;
endif;
if (count($status->plugins)) : ?>
<tr>
<th><?php echo JText::_('Plugin'); ?></th>
<th><?php echo JText::_('Group'); ?></th>
<th></th>
</tr>
<?php foreach ($status->plugins as $plugin) : ?>
<tr class="row<?php echo (++ $rows % 2); ?>">
<td class="key"><?php echo ucfirst($plugin['name']); ?></td>
<td class="key"><?php echo ucfirst($plugin['group']); ?></td>
<td><img src="images/publish_g.png" alt="OK" /> <strong><?php echo JText::_('Installed'); ?></strong></td>
</tr>
<?php endforeach;
endif; ?>
</tbody>
</table>