mirror of
https://git.code.sf.net/p/seeddms/code
synced 2025-05-09 13:06:14 +00:00
move lots of functions into view
This commit is contained in:
parent
6a72b3c0fa
commit
a26916243c
|
@ -2,6 +2,62 @@
|
|||
include("../views/bootstrap/class.Bootstrap.php");
|
||||
|
||||
class SeedDMS_View_Install extends SeedDMS_Theme_Style {
|
||||
protected function printError($error) { /* {{{ */
|
||||
print "<div class=\"alert alert-error\">\n";
|
||||
print $error;
|
||||
print "</div>";
|
||||
} /* }}} */
|
||||
|
||||
protected function printWarning($error) { /* {{{ */
|
||||
print "<div class=\"alert alert-warning\">";
|
||||
print $error;
|
||||
print "</div>";
|
||||
} /* }}} */
|
||||
|
||||
protected function printCheckError($resCheck) { /* {{{ */
|
||||
$hasError = false;
|
||||
foreach($resCheck as $keyRes => $paramRes) {
|
||||
if(isset($paramRes['type']) && $paramRes['type'] == 'error')
|
||||
$hasError = true;
|
||||
$errorMes = getMLText("settings_$keyRes"). " : " . getMLText("settings_".$paramRes["status"]);
|
||||
|
||||
if (isset($paramRes["currentvalue"]))
|
||||
$errorMes .= "<br/> => " . getMLText("settings_currentvalue") . " : " . $paramRes["currentvalue"];
|
||||
if (isset($paramRes["suggestionvalue"]))
|
||||
$errorMes .= "<br/> => " . getMLText("settings_suggestionvalue") . " : " . $paramRes["suggestionvalue"];
|
||||
if (isset($paramRes["suggestion"]))
|
||||
$errorMes .= "<br/> => " . getMLText("settings_".$paramRes["suggestion"]);
|
||||
if (isset($paramRes["systemerror"]))
|
||||
$errorMes .= "<br/> => " . $paramRes["systemerror"];
|
||||
|
||||
if(isset($paramRes['type']) && $paramRes['type'] == 'error')
|
||||
$this->printError($errorMes);
|
||||
else
|
||||
$this->printWarning($errorMes);
|
||||
}
|
||||
|
||||
return $hasError;
|
||||
} /* }}} */
|
||||
|
||||
protected function openDBConnection($settings) { /* {{{ */
|
||||
switch($settings->_dbDriver) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
case 'mysqlnd':
|
||||
case 'pgsql':
|
||||
$tmp = explode(":", $settings->_dbHostname);
|
||||
$dsn = $settings->_dbDriver.":dbname=".$settings->_dbDatabase.";host=".$tmp[0];
|
||||
if(isset($tmp[1]))
|
||||
$dsn .= ";port=".$tmp[1];
|
||||
break;
|
||||
case 'sqlite':
|
||||
$dsn = $settings->_dbDriver.":".$settings->_dbDatabase;
|
||||
break;
|
||||
}
|
||||
$connTmp = new PDO($dsn, $settings->_dbUser, $settings->_dbPass);
|
||||
return $connTmp;
|
||||
} /* }}} */
|
||||
|
||||
public function intro() { /* {{{ */
|
||||
$this->htmlStartPage("INSTALL");
|
||||
$this->globalBanner();
|
||||
|
@ -69,7 +125,7 @@ echo '<p><a href="install.php">' . getMLText("settings_start_install") . '</a></
|
|||
/**
|
||||
* Check System
|
||||
*/
|
||||
if (printCheckError( $settings->checkSystem())) { /* {{{ */
|
||||
if ($this->printCheckError( $settings->checkSystem())) { /* {{{ */
|
||||
if (function_exists("apache_get_version")) {
|
||||
echo "<br/>Apache version: " . apache_get_version();
|
||||
}
|
||||
|
@ -87,13 +143,12 @@ if (printCheckError( $settings->checkSystem())) { /* {{{ */
|
|||
exit;
|
||||
} /* }}} */
|
||||
|
||||
|
||||
if (isset($_POST["action"])) $action=$_POST["action"];
|
||||
else if (isset($_GET["action"])) $action=$_GET["action"];
|
||||
else $action=NULL;
|
||||
|
||||
$showform = true;
|
||||
if ($action=="setSettings") {
|
||||
if ($action=="setSettings") { /* {{{ */
|
||||
/**
|
||||
* Get Parameters
|
||||
*/
|
||||
|
@ -109,8 +164,8 @@ if ($action=="setSettings") {
|
|||
$settings->_dbDatabase = $_POST["dbDatabase"];
|
||||
$settings->_dbUser = $_POST["dbUser"];
|
||||
$settings->_dbPass = $_POST["dbPass"];
|
||||
$settings->_coreDir = $_POST["coreDir"];
|
||||
$settings->_luceneClassDir = $_POST["luceneClassDir"];
|
||||
$settings->_coreDir = ''; //$_POST["coreDir"];
|
||||
$settings->_luceneClassDir = ''; //$_POST["luceneClassDir"];
|
||||
|
||||
if(isset($settings->_extraPath))
|
||||
ini_set('include_path', $settings->_extraPath. PATH_SEPARATOR .ini_get('include_path'));
|
||||
|
@ -118,7 +173,7 @@ if ($action=="setSettings") {
|
|||
/**
|
||||
* Check Parameters, require version 3.3.x
|
||||
*/
|
||||
$hasError = printCheckError( $settings->check(substr(str_replace('.', '', SEEDDMS_VERSION), 0,2)));
|
||||
$hasError = $this->printCheckError( $settings->check(substr(str_replace('.', '', SEEDDMS_VERSION), 0,2)));
|
||||
|
||||
if (!$hasError) {
|
||||
// Create database
|
||||
|
@ -126,7 +181,7 @@ if ($action=="setSettings") {
|
|||
$createOK = false;
|
||||
$errorMsg = "";
|
||||
|
||||
$connTmp =openDBConnection($settings);
|
||||
$connTmp = $this->openDBConnection($settings);
|
||||
if ($connTmp) {
|
||||
// read SQL file
|
||||
if ($settings->_dbDriver=="mysql")
|
||||
|
@ -174,7 +229,7 @@ if ($action=="setSettings") {
|
|||
$settings->save();
|
||||
|
||||
$needsupdate = false;
|
||||
$connTmp =openDBConnection($settings);
|
||||
$connTmp = $this->openDBConnection($settings);
|
||||
if ($connTmp) {
|
||||
switch($settings->_dbDriver) {
|
||||
case 'mysql':
|
||||
|
@ -241,9 +296,9 @@ if ($action=="setSettings") {
|
|||
echo '<br/>';
|
||||
// echo '<a href="' . $httpRoot . '/install/install.php">' . getMLText("back") . '</a>';
|
||||
|
||||
}
|
||||
} /* }}} */
|
||||
|
||||
if($showform) {
|
||||
if($showform) { /* {{{ */
|
||||
|
||||
/**
|
||||
* Set parameters
|
||||
|
@ -278,6 +333,7 @@ if($showform) {
|
|||
<td><?php printMLText("settings_cacheDir");?>:</td>
|
||||
<td><input type="text" name="cacheDir" value="<?php echo $settings->_cacheDir ?>" size="100" style="background:yellow" /></td>
|
||||
</tr>
|
||||
<!--
|
||||
<tr title="<?php printMLText("settings_coreDir_desc");?>">
|
||||
<td><?php printMLText("settings_coreDir");?>:</td>
|
||||
<td><input type="text" name="coreDir" value="<?php echo $settings->_coreDir ?>" size="100" /></td>
|
||||
|
@ -286,6 +342,7 @@ if($showform) {
|
|||
<td><?php printMLText("settings_luceneClassDir");?>:</td>
|
||||
<td><input type="text" name="luceneClassDir" value="<?php echo $settings->_luceneClassDir ?>" size="100" /></td>
|
||||
</tr>
|
||||
-->
|
||||
<tr title="<?php printMLText("settings_extraPath_desc");?>">
|
||||
<td><?php printMLText("settings_extraPath");?>:</td>
|
||||
<td><input type="text" name="extraPath" value="<?php echo $settings->_extraPath ?>" size="100" /></td>
|
||||
|
@ -328,15 +385,12 @@ if($showform) {
|
|||
</form>
|
||||
<?php
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
*/
|
||||
} /* }}} */
|
||||
|
||||
// just remove info for web page installation
|
||||
$settings->_printDisclaimer = false;
|
||||
$settings->_footNote = false;
|
||||
|
||||
// end of the page
|
||||
$this->contentContainerEnd();
|
||||
$this->contentEnd();
|
||||
|
|
|
@ -46,66 +46,6 @@ if (!file_exists("settings.xml.template_install")) {
|
|||
exit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Functions
|
||||
*/
|
||||
function openDBConnection($settings) { /* {{{ */
|
||||
switch($settings->_dbDriver) {
|
||||
case 'mysql':
|
||||
case 'mysqli':
|
||||
case 'mysqlnd':
|
||||
case 'pgsql':
|
||||
$tmp = explode(":", $settings->_dbHostname);
|
||||
$dsn = $settings->_dbDriver.":dbname=".$settings->_dbDatabase.";host=".$tmp[0];
|
||||
if(isset($tmp[1]))
|
||||
$dsn .= ";port=".$tmp[1];
|
||||
break;
|
||||
case 'sqlite':
|
||||
$dsn = $settings->_dbDriver.":".$settings->_dbDatabase;
|
||||
break;
|
||||
}
|
||||
$connTmp = new PDO($dsn, $settings->_dbUser, $settings->_dbPass);
|
||||
return $connTmp;
|
||||
} /* }}} */
|
||||
|
||||
function printError($error) { /* {{{ */
|
||||
print "<div class=\"alert alert-error\">\n";
|
||||
print $error;
|
||||
print "</div>";
|
||||
} /* }}} */
|
||||
|
||||
function printWarning($error) { /* {{{ */
|
||||
print "<div class=\"install_warning\">";
|
||||
print "Warning<br />";
|
||||
print $error;
|
||||
print "</div>";
|
||||
} /* }}} */
|
||||
|
||||
function printCheckError($resCheck) { /* {{{ */
|
||||
$hasError = false;
|
||||
foreach($resCheck as $keyRes => $paramRes) {
|
||||
if(isset($paramRes['type']) && $paramRes['type'] == 'error')
|
||||
$hasError = true;
|
||||
$errorMes = getMLText("settings_$keyRes"). " : " . getMLText("settings_".$paramRes["status"]);
|
||||
|
||||
if (isset($paramRes["currentvalue"]))
|
||||
$errorMes .= "<br/> => " . getMLText("settings_currentvalue") . " : " . $paramRes["currentvalue"];
|
||||
if (isset($paramRes["suggestionvalue"]))
|
||||
$errorMes .= "<br/> => " . getMLText("settings_suggestionvalue") . " : " . $paramRes["suggestionvalue"];
|
||||
if (isset($paramRes["suggestion"]))
|
||||
$errorMes .= "<br/> => " . getMLText("settings_".$paramRes["suggestion"]);
|
||||
if (isset($paramRes["systemerror"]))
|
||||
$errorMes .= "<br/> => " . $paramRes["systemerror"];
|
||||
|
||||
if(isset($paramRes['type']) && $paramRes['type'] == 'error')
|
||||
printError($errorMes);
|
||||
else
|
||||
printWarning($errorMes);
|
||||
}
|
||||
|
||||
return $hasError;
|
||||
} /* }}} */
|
||||
|
||||
function fileExistsInIncludePath($file) { /* {{{ */
|
||||
$paths = explode(PATH_SEPARATOR, get_include_path());
|
||||
$found = false;
|
||||
|
@ -203,4 +143,3 @@ include("class.Install.php");
|
|||
$view = new SeedDMS_View_Install(array('settings'=>$settings, 'session'=>null, 'sitename'=>'SeedDMS', 'printdisclaimer'=>0, 'showmissingtranslations'=>0, 'absbaseprefix'=>'/', 'enabledropfolderlist'=>0, 'enablemenutasks'=>0, 'configdir'=>$configDir));
|
||||
$view->install();
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in New Issue
Block a user