]> git.agnieray.net Git - galette.git/blob - galette/install/steps/db.php
9d730f9e9b2c887572acfd177aaac622c5328090
[galette.git] / galette / install / steps / db.php
1 <?php
2
3 /* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
4
5 /**
6 * Galette installation, database step
7 *
8 * PHP version 5
9 *
10 * Copyright © 2013-2014 The Galette Team
11 *
12 * This file is part of Galette (http://galette.tuxfamily.org).
13 *
14 * Galette is free software: you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License as published by
16 * the Free Software Foundation, either version 3 of the License, or
17 * (at your option) any later version.
18 *
19 * Galette is distributed in the hope that it will be useful,
20 * but WITHOUT ANY WARRANTY; without even the implied warranty of
21 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
22 * GNU General Public License for more details.
23 *
24 * You should have received a copy of the GNU General Public License
25 * along with Galette. If not, see <http://www.gnu.org/licenses/>.
26 *
27 * @category Core
28 * @package Galette
29 *
30 * @author Johan Cwiklinski <johan@x-tnd.be>
31 * @copyright 2013-2014 The Galette Team
32 * @license http://www.gnu.org/licenses/gpl-3.0.html GPL License 3.0 or (at your option) any later version
33 * @version SVN: $Id$
34 * @link http://galette.tuxfamily.org
35 * @since Available since 0.8 - 2013-01-09
36 */
37
38 use Galette\Core\Install as GaletteInstall;
39 use Galette\Core\Db as GaletteDb;
40 ?>
41 <h2><?php echo _T("Database"); ?></h2>
42 <p>
43 <?php
44 if ($install->getMode() === GaletteInstall::INSTALL) {
45 echo _T("If it hadn't been made, create a database and a user for Galette.");
46 }
47 if ($install->isUpgrade()) {
48 echo _T("Enter connection data for the existing database.");
49 $install->loadExistingConfig($_POST, $error_detected);
50 } else {
51 if (file_exists(GALETTE_CONFIG_PATH . 'config.inc.php')) {
52 echo '<div id="warningbox">' . _T("It seems that you have already installed Galette once.<br/>All existing data will be removed if you keep going on using existing database!") . "</div>";
53 }
54 }
55
56 //define default database port
57 $default_dbport = GaletteDb::MYSQL_DEFAULT_PORT;
58 if (!isset($_POST['install_dbtype']) || $_POST['install_dbtype'] == 'mysql') {
59 $default_dbport = GaletteDb::MYSQL_DEFAULT_PORT;
60 } elseif ($_POST['install_dbtype'] == 'pgsql') {
61 $default_dbport = GaletteDb::PGSQL_DEFAULT_PORT;
62 }
63 ?><br />
64 <?php echo _T("The needed permissions are CREATE, DROP, DELETE, UPDATE, SELECT and INSERT."); ?></p>
65 <form action="installer.php" method="post">
66 <fieldset class="cssform">
67 <legend class="ui-state-active ui-corner-top"><?php echo _T("Database"); ?></legend>
68 <p>
69 <label class="bline" for="install_dbtype"><?php echo _T("Database type:"); ?></label>
70 <select name="install_dbtype" id="install_dbtype">
71 <option value="mysql"<?php if ( $install->getDbType() === GaletteDb::MYSQL ) {echo ' selected="selected"';} ?>>Mysql</option>
72 <option value="pgsql"<?php if ( $install->getDbType() === GaletteDb::PGSQL ) {echo ' selected="selected"';} ?>>Postgresql</option>
73 </select>
74 </p>
75 <div id="install_dbconfig">
76 <p>
77 <label class="bline" for="install_dbhost"><?php echo _T("Host:"); ?></label>
78 <input type="text" name="install_dbhost" id="install_dbhost" value="<?php echo ($install->getDbHost() !== null)?$install->getDbHost():'localhost'; ?>" required/>
79 </p>
80 <p>
81 <label class="bline" for="install_dbport"><?php echo _T("Port:"); ?></label>
82 <input type="text" name="install_dbport" id="install_dbport" value="<?php echo ($install->getDbPort() !== null)?$install->getDbPort():$default_dbport; ?>" required/>
83 </p>
84 <p>
85 <label class="bline" for="install_dbuser"><?php echo _T("User:"); ?></label>
86 <input type="text" name="install_dbuser" id="install_dbuser" value="<?php echo $install->getDbUser(); ?>" required/>
87 </p>
88 <p>
89 <label class="bline" for="install_dbpass"><?php echo _T("Password:"); ?></label>
90 <input type="password" name="install_dbpass" id="install_dbpass" value="" required/>
91 </p>
92 <p>
93 <label class="bline" for="install_dbname"><?php echo _T("Database:"); ?></label>
94 <input type="text" name="install_dbname" id="install_dbname" value="<?php echo $install->getDbName(); ?>" required/>
95 </p>
96 <p>
97 <label class="bline" for="install_dbprefix"><?php echo _T("Table prefix:"); ?></label>
98 <input type="text" name="install_dbprefix" id="install_dbprefix" value="<?php echo ($install->getTablesPrefix() !== null)?$install->getTablesPrefix():'galette_'; ?>" required/>
99 </p>
100 <?php
101 if ($install->isUpgrade()) {
102 echo '<div id="warningbox">' .
103 _T("(Indicate the CURRENT prefix of your Galette tables)") .
104 '</div>';
105 }
106 ?>
107
108 </div>
109 </fieldset>
110 <p id="btn_box">
111 <input id="next_btn" type="submit" value="<?php echo _T("Next step"); ?>"/>
112 <input type="submit" id="btnback" name="stepback_btn" value="<?php echo _T("Back"); ?>" formnovalidate/>
113 </p>
114 </form>
115 <script type="text/javascript">
116 $(function(){
117 $('#install_dbtype').change(function(){
118 var _db = $(this).val();
119 var _port = null;
120 if ( _db === 'pgsql' ) {
121 _port = <?php echo GaletteDb::PGSQL_DEFAULT_PORT; ?>;
122 } else if ( _db === 'mysql' ) {
123 _port = <?php echo GaletteDb::MYSQL_DEFAULT_PORT; ?>;
124 }
125 $('#install_dbport').val(_port);
126 });
127 });
128 </script>