summaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authorBart Visscher <bartv@thisnet.nl>2014-01-31 17:31:19 +0100
committerBart Visscher <bartv@thisnet.nl>2014-01-31 17:31:19 +0100
commitd8ec7e270167594ed407b22cb9ae78b1501ca946 (patch)
tree116a3a636e0cfca33a8f830b6488615b778eed9a /core
parent12a900de2539a31b0bbfbba9ffa861fb0f36e8cd (diff)
downloadnextcloud-server-d8ec7e270167594ed407b22cb9ae78b1501ca946.tar.gz
nextcloud-server-d8ec7e270167594ed407b22cb9ae78b1501ca946.zip
DRY for database type radiolist
Diffstat (limited to 'core')
-rw-r--r--core/setup/controller.php17
-rw-r--r--core/templates/installation.php62
2 files changed, 25 insertions, 54 deletions
diff --git a/core/setup/controller.php b/core/setup/controller.php
index 5189aba2f34..c628bda609b 100644
--- a/core/setup/controller.php
+++ b/core/setup/controller.php
@@ -85,6 +85,22 @@ class Controller {
$hasPostgreSQL = is_callable('pg_connect');
$hasOracle = is_callable('oci_connect');
$hasMSSQL = is_callable('sqlsrv_connect');
+ $databases = array();
+ if ($hasSQLite) {
+ $databases['sqlite'] = 'SQLite';
+ }
+ if ($hasMySQL) {
+ $databases['mysql'] = 'MySQL';
+ }
+ if ($hasPostgreSQL) {
+ $databases['pgsql'] = 'PostgreSQL';
+ }
+ if ($hasOracle) {
+ $databases['oci'] = 'Oracle';
+ }
+ if ($hasMSSQL) {
+ $databases['mssql'] = 'MS SQL';
+ }
$datadir = \OC_Config::getValue('datadirectory', \OC::$SERVERROOT.'/data');
$vulnerableToNullByte = false;
if(@file_exists(__FILE__."\0Nullbyte")) { // Check if the used PHP version is vulnerable to the NULL Byte attack (CVE-2006-7243)
@@ -111,6 +127,7 @@ class Controller {
'hasPostgreSQL' => $hasPostgreSQL,
'hasOracle' => $hasOracle,
'hasMSSQL' => $hasMSSQL,
+ 'databases' => $databases,
'directory' => $datadir,
'secureRNG' => \OC_Util::secureRNGAvailable(),
'htaccessWorking' => $htaccessWorking,
diff --git a/core/templates/installation.php b/core/templates/installation.php
index 7e216d0ee99..9356e62aa6c 100644
--- a/core/templates/installation.php
+++ b/core/templates/installation.php
@@ -86,62 +86,16 @@
$hasOtherDB = true; else $hasOtherDB =false; //other than SQLite ?>
<legend><?php p($l->t( 'Configure the database' )); ?></legend>
<div id="selectDbType">
- <?php if($_['hasSQLite']): ?>
- <input type='hidden' id='hasSQLite' value="true" />
- <?php if(!$hasOtherDB): ?>
- <p>SQLite <?php p($l->t( 'will be used' )); ?>.</p>
- <input type="hidden" id="dbtype" name="dbtype" value="sqlite" />
+ <?php foreach($_['databases'] as $type => $label): ?>
+ <?php if(count($_['databases']) == 1): ?>
+ <p><?php p($label . $l->t( 'will be used' )); ?>.</p>
+ <input type="hidden" id="dbtype" name="dbtype" value="<?php p($type) ?>" />
<?php else: ?>
- <input type="radio" name="dbtype" value="sqlite" id="sqlite"
- <?php OC_Helper::init_radio('dbtype', 'sqlite', 'sqlite'); ?>/>
- <label class="sqlite" for="sqlite">SQLite</label>
- <?php endif; ?>
- <?php endif; ?>
-
- <?php if($_['hasMySQL']): ?>
- <input type='hidden' id='hasMySQL' value='true'/>
- <?php if(!$_['hasSQLite'] and !$_['hasPostgreSQL'] and !$_['hasOracle'] and !$_['hasMSSQL']): ?>
- <p>MySQL <?php p($l->t( 'will be used' )); ?>.</p>
- <input type="hidden" id="dbtype" name="dbtype" value="mysql" />
- <?php else: ?>
- <input type="radio" name="dbtype" value="mysql" id="mysql"
- <?php OC_Helper::init_radio('dbtype', 'mysql', 'sqlite'); ?>/>
- <label class="mysql" for="mysql">MySQL</label>
- <?php endif; ?>
- <?php endif; ?>
-
- <?php if($_['hasPostgreSQL']): ?>
- <?php if(!$_['hasSQLite'] and !$_['hasMySQL'] and !$_['hasOracle'] and !$_['hasMSSQL']): ?>
- <p>PostgreSQL <?php p($l->t( 'will be used' )); ?>.</p>
- <input type="hidden" id="dbtype" name="dbtype" value="pgsql" />
- <?php else: ?>
- <label class="pgsql" for="pgsql">PostgreSQL</label>
- <input type="radio" name="dbtype" value='pgsql' id="pgsql"
- <?php OC_Helper::init_radio('dbtype', 'pgsql', 'sqlite'); ?>/>
- <?php endif; ?>
- <?php endif; ?>
-
- <?php if($_['hasOracle']): ?>
- <?php if(!$_['hasSQLite'] and !$_['hasMySQL'] and !$_['hasPostgreSQL'] and !$_['hasMSSQL']): ?>
- <p>Oracle <?php p($l->t( 'will be used' )); ?>.</p>
- <input type="hidden" id="dbtype" name="dbtype" value="oci" />
- <?php else: ?>
- <label class="oci" for="oci">Oracle</label>
- <input type="radio" name="dbtype" value='oci' id="oci"
- <?php OC_Helper::init_radio('dbtype', 'oci', 'sqlite'); ?>/>
- <?php endif; ?>
- <?php endif; ?>
-
- <?php if($_['hasMSSQL']): ?>
- <input type='hidden' id='hasMSSQL' value='true'/>
- <?php if(!$_['hasSQLite'] and !$_['hasMySQL'] and !$_['hasPostgreSQL'] and !$_['hasOracle']): ?>
- <p>MS SQL <?php p($l->t( 'will be used' )); ?>.</p>
- <input type="hidden" id="dbtype" name="dbtype" value="mssql" />
- <?php else: ?>
- <label class="mssql" for="mssql">MS SQL</label>
- <input type="radio" name="dbtype" value='mssql' id="mssql" <?php OC_Helper::init_radio('dbtype', 'mssql', 'sqlite'); ?>/>
- <?php endif; ?>
+ <input type="radio" name="dbtype" value="<?php p($type) ?>" id="<?php p($type) ?>"
+ <?php p($_['dbtype'] === $type ? 'checked="checked" ' : '') ?>/>
+ <label class="<?php p($type) ?>" for="<?php p($type) ?>"><?php p($label) ?></label>
<?php endif; ?>
+ <?php endforeach; ?>
</div>
<?php if($hasOtherDB): ?>