From 1f71a31084add9a8fbf2947eff85ee50c5913f5b Mon Sep 17 00:00:00 2001 From: z0rglub Date: Fri, 3 Sep 2004 15:01:05 +0000 Subject: - in admin/configuration, add new step with "sections" (general, comments, default, upload, metadata, sessions) - admin/configuration.php and its template have been higly simplificated by making things more generic : for example, for each configuration parameter, its name must correspond to the name we find in the config table and belongs to a section, in the lang array we find : - $lang['conf_
_'] - $lang['conf_
__info'] - $lang['conf_
__error'] optionnaly - more described message when connection to database server is impossible - redefinitions of get_languages and get_templates functions - deletion of configuration parameters : webmaster, session_keyword - rename of configuration parameters : - default_lang => default_language - default_style => default_template git-svn-id: http://piwigo.org/svn/trunk@512 68402e56-0260-453c-a942-63ccdbb3a9ee --- include/common.inc.php | 2 +- include/functions.inc.php | 51 ++++++++++++++++++++++++++++-------------- include/functions_html.inc.php | 34 ++++++---------------------- include/page_tail.php | 2 +- 4 files changed, 43 insertions(+), 46 deletions(-) (limited to 'include') 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 = ''; - 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 .= ''; - } + $selected = ( $template == $default_style ) ? ' selected="selected"' : ''; + $style_select.= ''; } - 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'] )); -- cgit v1.2.3