aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorplegall <plg@piwigo.org>2010-04-28 14:28:05 +0000
committerplegall <plg@piwigo.org>2010-04-28 14:28:05 +0000
commit73db66afa58cb14c6ced4163c10f4603a3399428 (patch)
treee5546bda92f92c4de6c1f104a66efebd3f462df3 /include
parentaaa31653eee276541f693a42159c1ea40421dbfd (diff)
feature 1630: upgrade to Piwigo 2.1 :-)
bug 1604: only activate core themes not all themes. git-svn-id: http://piwigo.org/svn/trunk@5982 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r--include/dblayer/functions_mysql.inc.php26
-rw-r--r--include/functions.inc.php17
-rw-r--r--include/functions_user.inc.php16
3 files changed, 46 insertions, 13 deletions
diff --git a/include/dblayer/functions_mysql.inc.php b/include/dblayer/functions_mysql.inc.php
index 437d603bd..3160e1902 100644
--- a/include/dblayer/functions_mysql.inc.php
+++ b/include/dblayer/functions_mysql.inc.php
@@ -52,18 +52,26 @@ function pwg_db_connect($host, $user, $password, $database)
function pwg_db_check_charset()
{
- defined('PWG_CHARSET') and defined('DB_CHARSET')
- or fatal_error('PWG_CHARSET and/or DB_CHARSET is not defined');
- if ( version_compare(mysql_get_server_info(), '4.1.0', '>=') )
+ $db_charset = 'utf8';
+ if (defined('DB_CHARSET') and DB_CHARSET != '')
{
- if (DB_CHARSET!='')
- {
- pwg_query('SET NAMES "'.DB_CHARSET.'"');
- }
+ $db_charset = DB_CHARSET;
}
- elseif ( strtolower(PWG_CHARSET)!='iso-8859-1' )
+ pwg_query('SET NAMES "'.$db_charset.'"');
+}
+
+function pwg_db_check_version()
+{
+ $current_mysql = pwg_get_db_version();
+ if (version_compare($current_mysql, REQUIRED_MYSQL_VERSION, '<'))
{
- fatal_error('PWG supports only iso-8859-1 charset on MySql version '.mysql_get_server_info());
+ fatal_error(
+ sprintf(
+ 'your MySQL version is too old, you have "%s" and you need at least "%s"',
+ $current_mysql,
+ REQUIRED_MYSQL_VERSION
+ )
+ );
}
}
diff --git a/include/functions.inc.php b/include/functions.inc.php
index 50348f029..16be2fca4 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -694,7 +694,7 @@ SELECT
$result = pwg_query($query);
while ($row = pwg_db_fetch_assoc($result))
{
- if (file_exists($conf['themes_dir'].'/'.$row['id'].'/'.'themeconf.inc.php'))
+ if (check_theme_installed($row['id']))
{
$themes[ $row['id'] ] = $row['name'];
}
@@ -706,6 +706,13 @@ SELECT
return $themes;
}
+function check_theme_installed($theme_id)
+{
+ global $conf;
+
+ return file_exists($conf['themes_dir'].'/'.$theme_id.'/'.'themeconf.inc.php');
+}
+
/* Returns the PATH to the thumbnail to be displayed. If the element does not
* have a thumbnail, the default mime image path is returned. The PATH can be
* used in the php script, but not sent to the browser.
@@ -1148,8 +1155,12 @@ function get_filter_page_value($value_name)
*/
function get_pwg_charset()
{
- defined('PWG_CHARSET') or fatal_error('PWG_CHARSET undefined');
- return PWG_CHARSET;
+ $pwg_charset = 'utf-8';
+ if (defined('PWG_CHARSET'))
+ {
+ $pwg_charset = PWG_CHARSET;
+ }
+ return $pwg_charset;
}
/**
diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php
index 6a63c83e4..41c97d0bb 100644
--- a/include/functions_user.inc.php
+++ b/include/functions_user.inc.php
@@ -848,7 +848,21 @@ function get_default_user_value($value_name, $sos_value)
*/
function get_default_theme()
{
- return get_default_user_value('theme', PHPWG_DEFAULT_TEMPLATE);
+ $theme = get_default_user_value('theme', PHPWG_DEFAULT_TEMPLATE);
+ if (check_theme_installed($theme))
+ {
+ return $theme;
+ }
+
+ // let's find the first available theme
+ $active_themes = get_pwg_themes();
+ foreach (array_keys(get_pwg_themes()) as $theme_id)
+ {
+ if (check_theme_installed($theme_id))
+ {
+ return $theme_id;
+ }
+ }
}
/*