diff options
author | rvelices <rv-github@modusoptimus.com> | 2012-10-12 20:00:16 +0000 |
---|---|---|
committer | rvelices <rv-github@modusoptimus.com> | 2012-10-12 20:00:16 +0000 |
commit | 267c548896d1e16ace40b6c1cb4df5913ac0bfa4 (patch) | |
tree | 08717cfd200a8beecdacf6d9492efd9e65e785b3 /include | |
parent | 5a061cb37dcd224f4fd33ebe2845660d6d327b38 (diff) |
- remove unsed code; shorten existing code and improve readability ...
git-svn-id: http://piwigo.org/svn/trunk@18629 68402e56-0260-453c-a942-63ccdbb3a9ee
Diffstat (limited to 'include')
-rw-r--r-- | include/functions.inc.php | 60 | ||||
-rw-r--r-- | include/functions_user.inc.php | 44 |
2 files changed, 29 insertions, 75 deletions
diff --git a/include/functions.inc.php b/include/functions.inc.php index 031ee652a..f8727f770 100644 --- a/include/functions.inc.php +++ b/include/functions.inc.php @@ -125,32 +125,6 @@ function get_filename_wo_extension( $filename ) return ($pos===false) ? $filename : substr( $filename, 0, $pos); } -/** - * returns an array contening sub-directories, excluding ".svn" - * - * @param string $dir - * @return array - */ -function get_dirs($directory) -{ - $sub_dirs = array(); - if ($opendir = opendir($directory)) - { - while ($file = readdir($opendir)) - { - if ($file != '.' - and $file != '..' - and is_dir($directory.'/'.$file) - and $file != '.svn') - { - array_push($sub_dirs, $file); - } - } - closedir($opendir); - } - return $sub_dirs; -} - define('MKGETDIR_NONE', 0); define('MKGETDIR_RECURSIVE', 1); define('MKGETDIR_DIE_ON_ERROR', 2); @@ -1274,6 +1248,7 @@ function load_language($filename, $dirname = '', $languages = array_unique($languages); + /*Note: target charset is always utf-8 if ( empty($options['target_charset']) ) { $target_charset = get_pwg_charset(); @@ -1282,7 +1257,7 @@ function load_language($filename, $dirname = '', { $target_charset = $options['target_charset']; } - $target_charset = strtolower($target_charset); + $target_charset = strtolower($target_charset);*/ $source_file = ''; foreach ($languages as $language) { @@ -1309,6 +1284,7 @@ function load_language($filename, $dirname = '', if ( !isset($lang) ) $lang=array(); if ( !isset($lang_info) ) $lang_info=array(); + /* Note: target charset is always utf-8 if ( 'utf-8'!=$target_charset) { if ( is_array($load_lang) ) @@ -1333,16 +1309,16 @@ function load_language($filename, $dirname = '', } } else - { + {*/ $lang = array_merge( $lang, (array)$load_lang ); $lang_info = array_merge( $lang_info, (array)$load_lang_info ); - } + //} return true; } else { $content = @file_get_contents($source_file); - $content = convert_charset($content, 'utf-8', $target_charset); + //Note: target charset is always utf-8 $content = convert_charset($content, 'utf-8', $target_charset); return $content; } } @@ -1604,36 +1580,20 @@ function get_privacy_level_options() global $conf; $options = array(); + $label = ''; foreach (array_reverse($conf['available_permission_levels']) as $level) { - $label = null; - if (0 == $level) { $label = l10n('Everybody'); } else { - $labels = array(); - $sub_levels = array_reverse($conf['available_permission_levels']); - foreach ($sub_levels as $sub_level) + if (strlen($label)) { - if ($sub_level == 0 or $sub_level < $level) - { - break; - } - array_push( - $labels, - l10n( - sprintf( - 'Level %d', - $sub_level - ) - ) - ); + $label .= ', '; } - - $label = implode(', ', $labels); + $label .= l10n( sprintf('Level %d',$level) ); } $options[$level] = $label; } diff --git a/include/functions_user.inc.php b/include/functions_user.inc.php index e6bbe57f8..924233bd0 100644 --- a/include/functions_user.inc.php +++ b/include/functions_user.inc.php @@ -287,8 +287,6 @@ function getuserdata($user_id, $use_cache) { global $conf; - $userdata = array(); - // retrieve basic user data $query = ' SELECT '; @@ -347,24 +345,21 @@ SELECT $user_infos_row = pwg_db_fetch_assoc($result); // then merge basic + additional user data - $row = array_merge($row, $user_infos_row); + $userdata = array_merge($row, $user_infos_row); - foreach ($row as $key => $value) + foreach ($userdata as &$value) { - if (!is_numeric($key)) - { - // If the field is true or false, the variable is transformed into a - // boolean value. - if ($value == 'true' or $value == 'false') + // If the field is true or false, the variable is transformed into a boolean value. + if ($value == 'true') { - $userdata[$key] = get_boolean($value); + $value = true; } - else + elseif ($value == 'false') { - $userdata[$key] = $value; + $value = false; } - } } + unset($value); if ($use_cache) { @@ -643,7 +638,7 @@ function compute_branch_cat_data(&$cats, &$list_cat_id, &$level, &$ref_level) // Last cat updating must be added to list for next branch if ($ref_level <> 0) { - array_push($list_cat_id, $cat_id); + $list_cat_id[] = $cat_id; } } @@ -662,12 +657,12 @@ function compute_categories_data(&$cats) $level = substr_count($category['global_rank'], '.') + 1; if ($level > $ref_level) { - array_push($list_cat_id, $id); + $list_cat_id[] = $id; } else { compute_branch_cat_data($cats, $list_cat_id, $level, $ref_level); - array_push($list_cat_id, $id); + $list_cat_id[] = $id; } $ref_level = $level; } @@ -829,18 +824,17 @@ function get_default_user_info($convert_str = true) if (is_array($cache['default_user']) and $convert_str) { - $default_user = array(); - foreach ($cache['default_user'] as $name => $value) + $default_user = $cache['default_user']; + foreach ($default_user as &$value) { - // If the field is true or false, the variable is transformed into a - // boolean value. - if ($value == 'true' or $value == 'false') + // If the field is true or false, the variable is transformed into a boolean value. + if ($value == 'true') { - $default_user[$name] = get_boolean($value); + $value = true; } - else + elseif ($value == 'false') { - $default_user[$name] = $value; + $value = false; } } return $default_user; @@ -984,7 +978,7 @@ function create_user_infos($arg_id, $override_values = null) 'level' => $level )); - array_push($inserts, $insert); + $inserts[] = $insert; } mass_inserts(USER_INFOS_TABLE, array_keys($inserts[0]), $inserts); |