aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--include/common.inc.php2
-rw-r--r--include/functions.inc.php51
-rw-r--r--include/functions_html.inc.php34
-rw-r--r--include/page_tail.php2
4 files changed, 43 insertions, 46 deletions
diff --git a/include/common.inc.php b/include/common.inc.php
index 6a06706ce..6d4b37195 100644
--- a/include/common.inc.php
+++ b/include/common.inc.php
@@ -130,7 +130,7 @@ include(PHPWG_ROOT_PATH . 'include/template.php');
//
mysql_connect( $dbhost, $dbuser, $dbpasswd )
-or die ( "Could not connect to server" );
+or die ( "Could not connect to database server" );
mysql_select_db( $dbname )
or die ( "Could not connect to database" );
diff --git a/include/functions.inc.php b/include/functions.inc.php
index df5b39e40..afd4f87b0 100644
--- a/include/functions.inc.php
+++ b/include/functions.inc.php
@@ -179,22 +179,25 @@ function get_filename_wo_extension( $filename )
}
/**
- * returns an array contening sub-directories
+ * returns an array contening sub-directories, excluding "CVS"
*
* @param string $dir
* @return array
*/
-function get_dirs( $directory )
+function get_dirs($directory)
{
$sub_dirs = array();
- if ( $opendir = opendir( $directory ) )
+ if ($opendir = opendir($directory))
{
- while ( $file = readdir ( $opendir ) )
+ while ($file = readdir($opendir))
{
- if ( $file != '.' and $file != '..' and is_dir ( $directory.'/'.$file ) )
+ if ($file != '.'
+ and $file != '..'
+ and is_dir($directory.'/'.$file)
+ and $file != 'CVS')
{
- array_push( $sub_dirs, $file );
+ array_push($sub_dirs, $file);
}
}
}
@@ -258,23 +261,29 @@ function get_picture_size( $original_width, $original_height,
}
//-------------------------------------------- PhpWebGallery specific functions
-// get_languages retourne un tableau contenant tous les languages
-// disponibles pour PhpWebGallery
-function get_languages( $rep_language )
+/**
+ * returns an array with a list of {language_code => language_name}
+ *
+ * @returns array
+ */
+function get_languages()
{
- global $lang;
+ $dir = opendir(PHPWG_ROOT_PATH.'language');
$languages = array();
- $i = 0;
- if ( $opendir = opendir ( $rep_language ) )
+
+ while ($file = readdir($dir))
{
- while ( $file = readdir ( $opendir ) )
+ $path = realpath(PHPWG_ROOT_PATH.'language/'.$file);
+ if (is_dir($path) and !is_link($path) and file_exists($path.'/iso.txt'))
{
- if ( is_dir ( $rep_language.$file )&& !substr_count($file,'.') && isset($lang['lang'][$file]))
- {
- $languages[$i++] =$lang['lang'][$file];
- }
+ list($language_name) = @file($path.'/iso.txt');
+ $languages[$file] = $language_name;
}
}
+ closedir($dir);
+ @asort($languages);
+ @reset($languages);
+
return $languages;
}
@@ -539,4 +548,12 @@ function get_query_string_diff($rejects = array())
return $query_string;
}
+
+/**
+ * returns available templates
+ */
+function get_templates()
+{
+ return get_dirs(PHPWG_ROOT_PATH.'template');
+}
?> \ No newline at end of file
diff --git a/include/functions_html.inc.php b/include/functions_html.inc.php
index 015eef155..5d91aa7aa 100644
--- a/include/functions_html.inc.php
+++ b/include/functions_html.inc.php
@@ -113,22 +113,7 @@ function create_navigation_bar( $url, $nb_element, $start,
//
function language_select($default, $select_name = "language")
{
-
- $dir = opendir(PHPWG_ROOT_PATH . 'language');
- $available_lang= array();
-
- while ( $file = readdir($dir) )
- {
- $path= realpath(PHPWG_ROOT_PATH . 'language/'.$file);
- if (is_dir ($path) && !is_link($path) && file_exists($path . '/iso.txt'))
- {
- list($displayname) = @file($path . '/iso.txt');
- $available_lang[$displayname] = $file;
- }
- }
- closedir($dir);
- @asort($available_lang);
- @reset($available_lang);
+ $available_lang = get_languages();
$lang_select = '<select name="' . $select_name . '" onchange="this.form.submit()">';
foreach ($available_lang as $displayname => $code)
@@ -146,19 +131,14 @@ function language_select($default, $select_name = "language")
//
function style_select($default_style, $select_name = "style")
{
- $dir = opendir(PHPWG_ROOT_PATH . 'template');
- $style_select = '<select name="' . $select_name . '">';
- while ( $file = readdir($dir) )
+ $templates = get_templates();
+
+ foreach ($templates as $template)
{
- if (is_dir ( realpath(PHPWG_ROOT_PATH.'template/'.$file) )
- && !is_link(realpath(PHPWG_ROOT_PATH . 'template/' . $file))
- && !strstr($file,'.'))
- {
- $selected = ( $file == $default_style ) ? ' selected="selected"' : '';
- $style_select .= '<option value="' . $file . '"' . $selected . '>' . $file . '</option>';
- }
+ $selected = ( $template == $default_style ) ? ' selected="selected"' : '';
+ $style_select.= '<option value="'.$template.'"'.$selected.'>';
+ $style_select.= $template.'</option>';
}
- closedir($dir);
return $style_select;
}
diff --git a/include/page_tail.php b/include/page_tail.php
index bf1c1d0e3..f8388f766 100644
--- a/include/page_tail.php
+++ b/include/page_tail.php
@@ -34,12 +34,12 @@ $template->assign_vars(
array(
'TIME' => $time,
'VERSION' => $conf['version'],
- 'WEBMASTER'=>$conf['webmaster'],
'MAIL'=>$conf['mail_webmaster'],
'L_GEN_TIME' => $lang['generation_time'],
'L_SEND_MAIL' => $lang['send_mail'],
'L_TITLE_MAIL' => $lang['title_send_mail'],
+ 'L_WEBMASTER'=>$lang['webmaster'],
'U_SITE' => $conf['site_url']
));