-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjoomla_3.4.X_install_by_script.patch
More file actions
247 lines (244 loc) · 8.34 KB
/
joomla_3.4.X_install_by_script.patch
File metadata and controls
247 lines (244 loc) · 8.34 KB
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
diff -x '*~' -Naur a/installation/application/web.php b/installation/application/web.php
--- a/installation/application/web.php 2015-09-09 12:30:08.000000000 +0200
+++ b/installation/application/web.php 2015-10-03 17:28:29.070552668 +0200
@@ -11,6 +11,8 @@
use Joomla\Registry\Registry;
+class InstallException extends Exception { }
+
/**
* Joomla! Installation Application class.
*
@@ -157,8 +159,7 @@
// Execute the task.
try
{
- $controller = $this->fetchController($this->input->getCmd('task'));
- $contents = $controller->execute();
+ $contents = $this->installCli();
}
catch (RuntimeException $e)
{
@@ -185,6 +186,117 @@
}
/**
+ * Method to run a fake controller for a cli install.
+ *
+ * @return string The rendered view.
+ *
+ * @since Not official :-)
+ */
+ protected function installCli()
+ {
+ try {
+ $contents = '<h3>Installation</h3>'. PHP_EOL . '<ul>' . PHP_EOL;
+
+ $model = new InstallationModelSetup;
+ $sufficient = $model->getPhpOptionsSufficient();
+ $options = $model->getOptions();
+
+ $contents .= '<li>Load custom options file...';
+ $custom_options_file = JPATH_INSTALLATION . '/custom_options.json';
+ if (file_exists($custom_options_file))
+ {
+ $contents .= 'Done</li>' . PHP_EOL;
+ }
+ else
+ {
+ $contents .= 'An error occured</li>' . PHP_EOL;
+ throw new InstallException('ERROR: Preseed file ' . $custom_options_file . ' not found');
+ }
+
+ $custom_options_json = file_get_contents($custom_options_file);
+ $custom_options = json_decode($custom_options_json, true);
+ $options = array_merge($options, $custom_options);
+
+ $options = $model->storeOptions($options);
+
+ // Get the database model.
+ $db = new InstallationModelDatabase;
+
+ // Attempt to create the database.
+ $contents .= '<li>Create database... ';
+ $return = $db->createDatabase($options);
+ if ($return)
+ {
+ $contents .= 'Done</li>' . PHP_EOL;
+ }
+ else
+ {
+ $contents .= 'An error occured</li>' . PHP_EOL;
+ throw new InstallException('ERROR: Unable to create database');
+ }
+
+ // Reload options (they can be modified by InstallationModel* classes)
+ $options = $model->getOptions();
+
+ // Attempt to handle old the database.
+ $contents .= '<li>Handle old database... ';
+ $return = $db->handleOldDatabase($options);
+ if ($return)
+ {
+ $contents .= 'Done</li>' . PHP_EOL;
+ }
+ else
+ {
+ $contents .= 'An error occured</li>' . PHP_EOL;
+ throw new InstallException('ERROR: Unable to handle old database');
+ }
+
+ // Reload options (they can be modified by InstallationModel* classes)
+ $options = $model->getOptions();
+
+ // Attempt to create the database tables.
+ $contents .= '<li>Create database tables... ';
+ $return = $db->createTables($options);
+ if ($return)
+ {
+ $contents .= 'Done</li>' . PHP_EOL;
+ }
+ else
+ {
+ $contents .= 'An error occured</li>' . PHP_EOL;
+ throw new InstallException('ERROR: Unable to create database tables');
+ }
+
+ // Reload options (they can be modified by InstallationModel* classes)
+ $options = $model->getOptions();
+
+ // Get the database model.
+ $configuration = new InstallationModelConfiguration;
+
+ // Attempt to setup the configuration.
+ $contents .= '<li>Setup configuration file... ';
+ $return = $configuration->setup($options);
+ if ($return)
+ {
+ $contents .= 'Done</li>' . PHP_EOL;
+ }
+ else
+ {
+ $contents .= 'An error occured</li>' . PHP_EOL;
+ throw new InstallException('ERROR: Unable to setup configuration file');
+ }
+
+ $contents .= '</ul>'. PHP_EOL . '<h3>Installation complete</h3>'. PHP_EOL;
+ }
+ catch (InstallException $e)
+ {
+ $contents .= '</ul>'. PHP_EOL . '<h3>Installation aborted</h3>'. PHP_EOL;
+ $this->enqueueMessage($e->getMessage(), 'error');
+ }
+ return $contents;
+ }
+
+ /**
* Method to run the Web application routines.
*
* @return void
diff -x '*~' -Naur a/installation/template/index.php b/installation/template/index.php
--- a/installation/template/index.php 2015-09-09 12:30:08.000000000 +0200
+++ b/installation/template/index.php 2015-09-26 14:58:42.786182235 +0200
@@ -13,35 +13,11 @@
// Add Stylesheets
JHtml::_('bootstrap.loadCss', true, $this->direction);
JHtml::_('stylesheet', 'installation/template/css/template.css');
-
-// Load the JavaScript behaviors
-JHtml::_('bootstrap.framework');
-JHtml::_('formbehavior.chosen', 'select');
-JHtml::_('behavior.framework', true);
-JHtml::_('behavior.keepalive');
-JHtml::_('behavior.formvalidator');
-JHtml::_('script', 'installation/template/js/installation.js');
-
-// Load the JavaScript translated messages
-JText::script('INSTL_PROCESS_BUSY');
-JText::script('INSTL_FTP_SETTINGS_CORRECT');
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" dir="<?php echo $this->direction; ?>">
<head>
<jdoc:include type="head" />
- <!--[if lt IE 9]>
- <script src="../media/jui/js/html5.js"></script>
- <![endif]-->
- <script type="text/javascript">
- jQuery(function()
- { // Delay instantiation after document.formvalidation and other dependencies loaded
- window.setTimeout(function(){
- window.Install = new Installation('container-installation', '<?php echo JUri::current(); ?>');
- }, 500);
-
- });
- </script>
</head>
<body>
<!-- Header -->
@@ -67,67 +43,10 @@
<!-- Container -->
<div class="container">
<jdoc:include type="message" />
- <div id="javascript-warning">
- <noscript>
- <div class="alert alert-error">
- <?php echo JText::_('INSTL_WARNJAVASCRIPT'); ?>
- </div>
- </noscript>
- </div>
<div id="container-installation">
<jdoc:include type="component" />
</div>
<hr />
</div>
- <script>
- function initElements()
- {
- (function($){
- $('.hasTooltip').tooltip()
-
- // Chosen select boxes
- $("select").chosen({
- disable_search_threshold : 10,
- allow_single_deselect : true
- });
-
- // Turn radios into btn-group
- $('.radio.btn-group label').addClass('btn');
- $(".btn-group label:not(.active)").click(function()
- {
- var label = $(this);
- var input = $('#' + label.attr('for'));
-
- if (!input.prop('checked'))
- {
- label.closest('.btn-group').find("label").removeClass('active btn-success btn-danger btn-primary');
- if(input.val()== '')
- {
- label.addClass('active btn-primary');
- } else if(input.val()==0 || input.val()=='remove')
- {
- label.addClass('active btn-danger');
- } else {
- label.addClass('active btn-success');
- }
- input.prop('checked', true);
- }
- });
- $(".btn-group input[checked=checked]").each(function()
- {
- if ($(this).val()== '')
- {
- $("label[for=" + $(this).attr('id') + "]").addClass('active btn-primary');
- } else if($(this).val()==0 || $(this).val()=='remove')
- {
- $("label[for=" + $(this).attr('id') + "]").addClass('active btn-danger');
- } else {
- $("label[for=" + $(this).attr('id') + "]").addClass('active btn-success');
- }
- });
- })(jQuery);
- }
- initElements();
- </script>
</body>
</html>