Commit fbb98f44c4393d1a0f0abc564f97fcc873f22a7d

Authored by jarrett
1 parent 7cb89fa6

Story Id: 964068 Fixed Conflicts

Committed by: Jarrett Jordaan

Reviewed by: Paul Barrett
setup/wizard/installUtil.php
... ... @@ -327,7 +327,8 @@ class InstallUtil {
327 327 return false;
328 328 }
329 329  
330   - return array('response'=>$response, 'java'=>'java');
  330 + return 'java';
  331 +// return array('response'=>$response, 'java'=>'java');
331 332 }
332 333  
333 334 function tryJava2() {
... ... @@ -336,7 +337,8 @@ class InstallUtil {
336 337 return false;
337 338 }
338 339  
339   - return array('response'=>$response, 'java'=>'java');
  340 + return 'java';
  341 +// return array('response'=>$response, 'java'=>'java');
340 342 }
341 343  
342 344 function tryJava3() {
... ... @@ -348,20 +350,54 @@ class InstallUtil {
348 350 foreach ($broke as $r) {
349 351 $match = preg_match('/bin/', $r);
350 352 if($match) {
351   - return array('response'=>$response, 'java'=>preg_replace('/java:/', '', $r));
  353 + return preg_replace('/java:/', '', $r);
  354 +// return array('response'=>$response, 'java'=>preg_replace('/java:/', '', $r));
352 355 }
353 356 }
354 357 }
355 358  
356   - function getJava() {
357   - $response = $this->tryJava1();
358   - if(!is_array($response)) {
359   - $response = $this->tryJava2();
360   - if(!is_array($response)) {
361   - $response = $this->tryJava3();
  359 + /**
  360 + * Check if user entered location of JRE
  361 + *
  362 + * @author KnowledgeTree Team
  363 + * @param none
  364 + * @access private
  365 + * @return mixed
  366 + */
  367 + public function javaSpecified() {
  368 + if(isset($_POST['java'])) {
  369 + if($_POST['java'] != '') {
  370 + return $_POST['java'];
  371 + } else {
  372 + return false;
362 373 }
  374 + } else {
  375 + return false;
363 376 }
364   -
  377 + }
  378 +
  379 + /**
  380 + * Determine the location of JAVA_HOME
  381 + *
  382 + * @author KnowledgeTree Team
  383 + * @param none
  384 + * @access private
  385 + * @return mixed
  386 + */
  387 + function getJava() {
  388 +// $javaSpecified = $this->javaSpecified();
  389 +// if($javaSpecified) {
  390 +// return $javaSpecified;
  391 +// } else {
  392 + $response = $this->tryJava1();
  393 + if(!is_array($response)) {
  394 + $response = $this->tryJava2();
  395 + if(!is_array($response)) {
  396 + $response = $this->tryJava3();
  397 + }
  398 + }
  399 +// }
  400 +
365 401 return $response;
366 402 }
367 403  
... ...
setup/wizard/installer.php
... ... @@ -138,7 +138,7 @@ class Installer {
138 138 } catch (Exception $e) {
139 139 $iutil = new InstallUtil();
140 140 $iutil->error("Error reading configuration file: $name");
141   - die;
  141 + exit();
142 142 }
143 143 }
144 144  
... ... @@ -397,7 +397,7 @@ class Installer {
397 397 } else {
398 398 $iutil = new InstallUtil();
399 399 $iutil->error("Class File Missing in Step Directory: $className");
400   - die;
  400 + exit();
401 401 }
402 402 }
403 403  
... ...
setup/wizard/path.php
... ... @@ -73,6 +73,8 @@
73 73 define('RES_DIR', WIZARD_DIR."resources".DS);
74 74 define('STEP_DIR', WIZARD_DIR."steps".DS);
75 75 define('TEMP_DIR', WIZARD_DIR."templates".DS);
  76 + define('SHELL_DIR', WIZARD_DIR."shells".DS);
  77 + define('OUTPUT_DIR', WIZARD_DIR."output".DS);
76 78 // Define paths to system webroot
77 79 define('SYSTEM_DIR', $sys);
78 80 define('SYS_BIN_DIR', SYSTEM_DIR."bin".DS);
... ...
setup/wizard/steps/services.php
... ... @@ -66,11 +66,38 @@ class services extends Step
66 66  
67 67 protected $util;
68 68  
69   - private $response;
  69 + //private $response;
70 70  
71 71 private $javaVersion = '1.5';
72 72  
73 73 /**
  74 + * Java Installed
  75 + *
  76 + * @author KnowledgeTree Team
  77 + * @access private
  78 + * @var mixed
  79 + */
  80 + private $java_check = 'cross';
  81 +
  82 + /**
  83 + * Java Bridge Installed
  84 + *
  85 + * @author KnowledgeTree Team
  86 + * @access private
  87 + * @var mixed
  88 + */
  89 + private $java_ext_check = 'cross';
  90 +
  91 + /**
  92 + * Service Installed
  93 + *
  94 + * @author KnowledgeTree Team
  95 + * @access private
  96 + * @var array
  97 + */
  98 + private $service_check = 'tick';
  99 +
  100 + /**
74 101 * Flag to store class information in session
75 102 *
76 103 * @author KnowledgeTree Team
... ... @@ -104,9 +131,9 @@ class services extends Step
104 131  
105 132  
106 133  
107   - function getJavaResponse() {
108   - return $this->response;
109   - }
  134 +// function getJavaResponse() {
  135 +// return $this->response;
  136 +// }
110 137  
111 138 /**
112 139 * Main control of services setup
... ... @@ -144,10 +171,7 @@ class services extends Step
144 171 * @return boolean
145 172 */
146 173 private function doRun() {
147   - $javaSettings = $this->util->getJava();
148   - $this->response = $javaSettings['response'];
149   - $this->java = $javaSettings['java'];
150   - $this->temp_variables['service_check'] = 'tick';
  174 + $this->java = $this->util->getJava();
151 175 if($this->javaChecks()) {
152 176 $this->installService();
153 177 } else { // Services not installed
... ... @@ -155,63 +179,81 @@ class services extends Step
155 179 $this->temp_variables['services'][] = array('class'=>'cross', 'msg'=>$serviceName." Could not be added as a Service");
156 180 }
157 181 }
  182 + $this->temp_variables['java_check'] = $this->java_check;
  183 + $this->temp_variables['java_ext_check'] = $this->java_ext_check;
  184 + $this->temp_variables['service_check'] = $this->service_check;
158 185 $errors = $this->getErrors();
159 186 if(!empty($errors))
160 187 return false;
161 188 return true;
162 189 }
163   -
164   - public function zendBridge() {
165   - $mods = get_loaded_extensions();
166   - if(in_array('Zend Java Bridge', $mods))
167   - return true;
168   - else
169   - return false;
170   - }
171   -
172   - public function checkZendBridge() {
173   - if($this->util->javaBridge()) { // Check if java bridge is functional
174   - $javaSystem = new Java('java.lang.System');
175   - $version = $javaSystem->getProperty('java.version');
176   - $ver = substr($version, 0, 3);
177   - if($ver < $this->javaVersion) {
178   - $this->temp_variables['version']['class'] = 'cross';
179   - $this->temp_variables['version']['found'] = "Requires Java 1.5+ to be installed";
180   - $this->error[] = "Requires Java 1.5+ to be installed";
181   - } else {
182   - $this->temp_variables['version']['class'] = 'tick';
183   - $this->temp_variables['version']['found'] = "Java Version 1.5+ Installed";
184   - }
185   - } else {
186   - $this->warnings[] = "Zend Java Bridge Error";
187   - $this->temp_variables['version']['class'] = 'cross_orange';
188   - $this->temp_variables['version']['found'] = "Java Runtime Version Cannot be detected";
189   - $this->temp_variables['extensions']['class'] = 'cross_orange';
190   - $this->temp_variables['extensions']['found'] = "Zend Java Bridge Error";
191   - return false;
192   - }
  190 +
  191 + private function detSettings() {
  192 +// $cmd = $this->java." -version > output/outJV 2>&1 echo $!";
  193 +// echo $cmd;
  194 +// die('bb');
  195 +// $response = $this->util->pexec(SHELL_DIR."javaVersion.sh");
  196 +// if(file_exists(OUTPUT_DIR.'outJV')) {
  197 +// $tmp = file_get_contents(OUTPUT_DIR.'outJV');
  198 +// echo $tmp;
  199 +// preg_match('/"(.*)"/',$tmp, $matches);
  200 +// var_dump($matches);
  201 +// $fp->
  202 +// echo 'a';
  203 +// }
  204 +// var_dump($response);
  205 +// die('aa');
  206 +// var_dump($this->util->pexec($this->java.""));
  207 +// var_dump($this->util->pexec($this->java." -version"));
193 208 }
194 209  
195 210 public function javaChecks() {
196   - $zendBridge = $this->zendBridge(); // Find Zend Bridge
197   - $this->temp_variables['java_check'] = 'tick';
198   - $this->temp_variables['java_ext_check'] = 'tick';
199 211 $this->temp_variables['extensions']['class'] = 'cross';
200 212 $this->temp_variables['extensions']['found'] = "Zend Java Bridge Required";
201 213 $this->temp_variables['version']['class'] = 'cross';
202 214 $this->temp_variables['version']['found'] = "Java Runtime Version Incorrect";
203 215 $this->temp_variables['java']['class'] = 'cross';
204 216 $this->temp_variables['java']['found'] = "Java runtime environment required";
  217 + if($this->util->javaSpecified()) {
  218 + $this->detSettings();
  219 + } else {
  220 + $this->useBridge();
  221 + }
  222 +
  223 + }
  224 +
  225 + function useBridge() {
  226 + $zendBridge = $this->zendBridge(); // Find Zend Bridge
205 227 if($zendBridge) {
206 228 $this->temp_variables['extensions']['class'] = 'tick';
207 229 $this->temp_variables['extensions']['found'] = "Java Bridge Installed";
208   - $this->checkZendBridge(); // Make sure the Zend Bridge is functional
  230 + if($this->checkZendBridge()) { // Make sure the Zend Bridge is functional
  231 + $javaSystem = new Java('java.lang.System');
  232 + $version = $javaSystem->getProperty('java.version');
  233 + $ver = substr($version, 0, 3);
  234 + if($ver < $this->javaVersion) {
  235 + $this->temp_variables['version']['class'] = 'cross';
  236 + $this->temp_variables['version']['found'] = "Requires Java 1.5+ to be installed";
  237 + $this->error[] = "Requires Java 1.5+ to be installed";
  238 + } else {
  239 + $this->temp_variables['version']['class'] = 'tick';
  240 + $this->temp_variables['version']['found'] = "Java Version 1.5+ Installed";
  241 + }
  242 + } else {
  243 + $this->warnings[] = "Zend Java Bridge Error";
  244 + $this->temp_variables['version']['class'] = 'cross_orange';
  245 + $this->temp_variables['version']['found'] = "Java Runtime Version Cannot be detected";
  246 + $this->temp_variables['extensions']['class'] = 'cross_orange';
  247 + $this->temp_variables['extensions']['found'] = "Zend Java Bridge Error";
  248 + $this->java_ext_check = 'cross_orange';
  249 + }
209 250 } else {
210 251 $this->warnings[] = "Zend Java Bridge Required";
211 252 }
212 253 if($this->java != '') { // Find Java JRE
213 254 $this->temp_variables['java']['class'] = 'tick';
214 255 $this->temp_variables['java']['found'] = "Java Runtime Installed";
  256 + $this->java_check = 'tick';
215 257 } else {
216 258 $this->error[] = "Java runtime environment required";
217 259 }
... ... @@ -220,6 +262,39 @@ class services extends Step
220 262 }
221 263  
222 264 /**
  265 + * Check if Zend Bridge is enabled
  266 + *
  267 + * @author KnowledgeTree Team
  268 + * @param none
  269 + * @access public
  270 + * @return boolean
  271 + */
  272 + public function zendBridge() {
  273 + $mods = get_loaded_extensions();
  274 + if(in_array('Zend Java Bridge', $mods))
  275 + return true;
  276 + else
  277 + return false;
  278 + }
  279 +
  280 + /**
  281 + * Check if Zend Bridge is functional
  282 + *
  283 + * @author KnowledgeTree Team
  284 + * @param none
  285 + * @access public
  286 + * @return boolean
  287 + */
  288 + public function checkZendBridge() {
  289 + if($this->util->javaBridge()) { // Check if java bridge is functional
  290 + return true;
  291 + } else {
  292 + return false;
  293 + }
  294 + }
  295 +
  296 +
  297 + /**
223 298 * Installs services
224 299 *
225 300 * @author KnowledgeTree Team
... ... @@ -236,7 +311,6 @@ class services extends Step
236 311 $this->temp_variables['services'][] = array('class'=>'tick', 'msg'=>$service->getName()." has been added as a Service");
237 312 } else {
238 313 $this->temp_variables['services'][] = array('class'=>'cross', 'msg'=>$service->getName()." Could not be added as a Service");
239   - $this->temp_variables['service_check'] = 'cross';
240 314 }
241 315 }
242 316  
... ... @@ -328,7 +402,7 @@ class services extends Step
328 402 }
329 403  
330 404 /**
331   - * Returns service errors
  405 + * Returns services errors
332 406 *
333 407 * @author KnowledgeTree Team
334 408 * @access public
... ... @@ -339,6 +413,18 @@ class services extends Step
339 413 return $this->error;
340 414 }
341 415  
  416 + /**
  417 + * Returns services warnings
  418 + *
  419 + * @author KnowledgeTree Team
  420 + * @access public
  421 + * @params none
  422 + * @return array
  423 + */
  424 + public function getWarnings() {
  425 + return $this->warnings;
  426 + }
  427 +
342 428 /**
343 429 * Get the variables to be passed to the template
344 430 *
... ...
setup/wizard/templates/services.tpl
  1 +<form action="index.php?step_name=services" method="post">
1 2 <h1>Services Dependencies Check</h1>
2 3  
3 4 <p class="description">
... ... @@ -11,7 +12,7 @@ if($errors || $warnings){
11 12 }
12 13 ?>
13 14  
14   -<h3><?php echo "<span class='{$java_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Java Version Check</h3>
  15 +<h3><?php echo "<span class='{$java_check}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>"; ?>Java Check</h3>
15 16 <?php if($silent) { ?>
16 17 <div id="options" class="onclick" onclick="javascript:{w.toggleClass('java_details');}">Show Details</div>
17 18 <div class="java_details" style="display:none">
... ... @@ -35,6 +36,12 @@ A PHP Java Bridge is required for KnowledgeTree to perform at an optimal level.
35 36 </p>
36 37 <?php echo "<span class='{$step_vars['extensions']['class']}'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span>{$step_vars['extensions']['found']}"; ?>
37 38 <br />
  39 +<?php if($java_ext_check != 'tick') { ?>
  40 +<br />
  41 +One is not needed, if you specify the location of you JRE installation
  42 +<br />
  43 +<input name='java' id='port' size='25' value=''/>
  44 +<?php } ?>
38 45 <?php if($silent) { ?>
39 46 </div>
40 47 <?php } ?>
... ... @@ -58,9 +65,10 @@ if($step_vars){
58 65 <?php if($silent) { ?>
59 66 </div>
60 67 <?php } ?>
61   -<form action="index.php?step_name=services" method="post">
  68 +
62 69 <div class="buttons">
63 70 <input type="submit" name="Previous" value="Previous"/>
  71 + <input type="submit" name="Refresh" value="Refresh"/>
64 72 <input type="submit" name="Next" value="Next"/>
65 73 </div>
66 74 </form>
67 75 \ No newline at end of file
... ...