aboutsummaryrefslogtreecommitdiffstats
path: root/admin
diff options
context:
space:
mode:
authornikrou <nikrou@piwigo.org>2010-02-27 20:00:00 +0000
committernikrou <nikrou@piwigo.org>2010-02-27 20:00:00 +0000
commitd4287e2ad82770d8903dc1eb6cb906bb690de63a (patch)
tree614d7d8e12c9cbf94ba09682e09206aef370dd82 /admin
parent4986d620e35d0ddecfb88c444cc220d379a48cda (diff)
Feature 1460 : Customize form installation depending on database engine
- sqlite is proposed by default if severals database engine are available (cf conf) - sqlite is proposed before pdo-sqlite - remove host, user and password for sqlite git-svn-id: http://piwigo.org/svn/trunk@4985 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'admin')
-rw-r--r--admin/include/functions_install.inc.php39
-rw-r--r--admin/template/goto/include/install.inc.tpl19
-rw-r--r--admin/template/goto/install.tpl10
-rw-r--r--admin/template/goto/theme/roma/theme.css1
4 files changed, 58 insertions, 11 deletions
diff --git a/admin/include/functions_install.inc.php b/admin/include/functions_install.inc.php
index 65b1a24d6..166ed6b7d 100644
--- a/admin/include/functions_install.inc.php
+++ b/admin/include/functions_install.inc.php
@@ -86,20 +86,41 @@ function available_engines()
foreach ($dblayers as $engine_name => $engine)
{
- if (file_exists(sprintf($pattern, $engine_name))
- && isset($engine['function_available'])
- && function_exists($engine['function_available']))
+ if (file_exists(sprintf($pattern, $engine_name)))
{
- $engines[$engine_name] = $engine['engine'];
+ $engines[$engine_name]['label'] = $engine['engine'];
+ $engines[$engine_name]['available'] = 'disabled';
+
+ if (isset($engine['function_available'])
+ && function_exists($engine['function_available']))
+ {
+ $engines[$engine_name]['available'] = true;
+ }
+ elseif (isset($engine['class_available'])
+ && class_exists($engine['class_available']))
+ {
+ $engines[$engine_name]['available'] = true;
+ }
+ }
+ }
+
+ if (count($engines)>1)
+ {
+ $engines[$GLOBALS['conf']['dbengine_select_default']]['selected'] = true;
+ }
+
+ if ($engines['sqlite']['available'] && $engines['pdo-sqlite']['available'])
+ {
+ if ($GLOBALS['conf']['db_sqlite_default']=='native')
+ {
+ unset($engines['pdo-sqlite']);
}
- elseif (file_exists(sprintf($pattern, $engine_name))
- && isset($engine['class_available'])
- && class_exists($engine['class_available']))
+ else
{
- $engines[$engine_name] = $engine['engine'];
+ unset($engines['sqlite']);
}
}
-
+
return $engines;
}
?> \ No newline at end of file
diff --git a/admin/template/goto/include/install.inc.tpl b/admin/template/goto/include/install.inc.tpl
new file mode 100644
index 000000000..b153f0f30
--- /dev/null
+++ b/admin/template/goto/include/install.inc.tpl
@@ -0,0 +1,19 @@
+<script type="text/javascript" src="template-common/lib/jquery.packed.js"></script>
+{literal}
+<script type="text/javascript">
+$(function() {
+ $option_selected = $('#dblayer option:selected').attr('value');
+ if ($option_selected=='sqlite' || $option_selected=='pdo-sqlite') {
+ $('input[name=dbhost],input[name=dbuser],input[name=dbpasswd]').parent().parent().hide();
+ }
+ $('#dblayer').change(function() {
+ $db = this;
+ if ($db.value=='sqlite' || $db.value=='pdo-sqlite') {
+ $('input[name=dbhost],input[name=dbuser],input[name=dbpasswd]').parent().parent().hide();
+ } else {
+ $('input[name=dbhost],input[name=dbuser],input[name=dbpasswd]').parent().parent().show();
+ }
+ });
+ });
+</script>
+{/literal}
diff --git a/admin/template/goto/install.tpl b/admin/template/goto/install.tpl
index 6976d8ccc..2b83d3bf4 100644
--- a/admin/template/goto/install.tpl
+++ b/admin/template/goto/install.tpl
@@ -9,6 +9,7 @@
<link rel="stylesheet" type="text/css" href="{$ROOT_URL}admin/template/{$themeconf.template}/layout.css">
<link rel="stylesheet" type="text/css" href="{$ROOT_URL}admin/template/{$themeconf.template}/default-colors.css">
<link rel="stylesheet" type="text/css" href="{$ROOT_URL}admin/template/{$themeconf.template}/theme/{$themeconf.theme}/theme.css">
+{include file="include/install.inc.tpl"}
{literal}
<style type="text/css">
.content {
@@ -88,8 +89,13 @@ TD {
<tr>
<td style="width: 30%;">{'step1_dbengine'|@translate}</td>
<td>
- <select name="dblayer">
- {html_options options=$F_DB_ENGINES selected=$F_DB_LAYER}
+ <select name="dblayer" id="dblayer">
+ {foreach from=$F_DB_ENGINES key=k item=v}
+ <option value="{$k}"
+ {if $k==$F_DB_LAYER or $v.selected} selected="selected"{/if}
+ {if $v.available!=1} disabled="disabled"{/if}
+ >{$v.label}</option>
+ {/foreach}
</select>
</td>
<td>{'step1_dbengine_info'|@translate}</td>
diff --git a/admin/template/goto/theme/roma/theme.css b/admin/template/goto/theme/roma/theme.css
index 0116283b0..85356582a 100644
--- a/admin/template/goto/theme/roma/theme.css
+++ b/admin/template/goto/theme/roma/theme.css
@@ -2,6 +2,7 @@
body, h3, dt, h2, .throw, .content, label,
input.rateButtonSelected /* <= why IE doesn't inherit this ? */ { color:#666; }
INPUT, select, textarea { color:#999; background-color: #444; }
+option[disabled] { background-color: #999; color: #444; }
input[type="radio"], input[type="checkbox"] { background-color: transparent; }
/* INPUT[type="checkbox"], INPUT[type="radio"]
{ color:#999; background-color: #eee; } */