]> source.dussan.org Git - nextcloud-server.git/commitdiff
DRY for database type radiolist
authorBart Visscher <bartv@thisnet.nl>
Fri, 31 Jan 2014 16:31:19 +0000 (17:31 +0100)
committerBart Visscher <bartv@thisnet.nl>
Fri, 31 Jan 2014 16:31:19 +0000 (17:31 +0100)
core/setup/controller.php
core/templates/installation.php

index 5189aba2f34cddf349934bcf545fd7e982ee2135..c628bda609b6e10108fed4cd9431feeba3e74910 100644 (file)
@@ -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,
index 7e216d0ee9936682c45e0868ded5db5f1f6e5ed4..9356e62aa6cc1a2fe9ef2a63555097545dd0d0ab 100644 (file)
                        $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): ?>