aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--admin/include/languages.class.php96
-rw-r--r--admin/languages_installed.php8
-rw-r--r--admin/languages_new.php2
-rw-r--r--install.php8
-rw-r--r--install/db/90-database.php2
-rw-r--r--install/php5_apache_configuration.php4
-rw-r--r--upgrade.php6
7 files changed, 92 insertions, 34 deletions
diff --git a/admin/include/languages.class.php b/admin/include/languages.class.php
index 44d1ee916..abaef1353 100644
--- a/admin/include/languages.class.php
+++ b/admin/include/languages.class.php
@@ -80,8 +80,10 @@ class languages
$query = '
INSERT INTO '.LANGUAGES_TABLE.'
- (id, name)
- VALUES(\''.$language_id.'\', \''.$this->fs_languages[$language_id].'\')
+ (id, version, name)
+ VALUES(\''.$language_id.'\',
+ \''.$this->fs_languages[$language_id]['version'].'\',
+ \''.$this->fs_languages[$language_id]['name'].'\')
;';
pwg_query($query);
break;
@@ -157,21 +159,60 @@ UPDATE '.USER_INFOS_TABLE.'
$target_charset = strtolower($target_charset);
$dir = opendir(PHPWG_ROOT_PATH.'language');
-
while ($file = readdir($dir))
{
- $path = PHPWG_ROOT_PATH.'language/'.$file;
- if (!is_link($path) and is_dir($path) and file_exists($path.'/iso.txt'))
+ if ($file!='.' and $file!='..')
{
- list($language_name) = @file($path.'/iso.txt');
-
- $languages[$file] = convert_charset($language_name, 'utf-8', $target_charset);
+ $path = PHPWG_ROOT_PATH.'language/'.$file;
+ if (is_dir($path) and !is_link($path)
+ and preg_match('/^[a-zA-Z0-9-_]+$/', $file )
+ and file_exists($path.'/common.lang.php')
+ )
+ {
+ $language = array(
+ 'code'=>$file,
+ 'version'=>'0',
+ 'uri'=>'',
+ 'author'=>'',
+ );
+ $plg_data = implode( '', file($path.'/common.lang.php') );
+
+ if ( preg_match("|Language Name: (.*)|", $plg_data, $val) )
+ {
+ $language['name'] = trim( $val[1] );
+ $language['name'] = convert_charset($language['name'], 'utf-8', $target_charset);
+ }
+ if (preg_match("|Version: (.*)|", $plg_data, $val))
+ {
+ $language['version'] = trim($val[1]);
+ }
+ if ( preg_match("|Language URI: (.*)|", $plg_data, $val) )
+ {
+ $language['uri'] = trim($val[1]);
+ }
+ if ( preg_match("|Author: (.*)|", $plg_data, $val) )
+ {
+ $language['author'] = trim($val[1]);
+ }
+ if ( preg_match("|Author URI: (.*)|", $plg_data, $val) )
+ {
+ $language['author uri'] = trim($val[1]);
+ }
+ if (!empty($language['uri']) and strpos($language['uri'] , 'extension_view.php?eid='))
+ {
+ list( , $extension) = explode('extension_view.php?eid=', $language['uri']);
+ if (is_numeric($extension)) $language['extension'] = $extension;
+ }
+ // IMPORTANT SECURITY !
+ $language = array_map('htmlspecialchars', $language);
+ $this->fs_languages[$file] = $language;
+ }
}
}
closedir($dir);
- @asort($languages);
+ @uasort($this->fs_languages, 'name_compare');
- return $languages;
+ return $this->fs_languages;
}
function get_db_languages()
@@ -192,7 +233,7 @@ UPDATE '.USER_INFOS_TABLE.'
/**
* Retrieve PEM server datas to $server_languages
*/
- function get_server_languages()
+ function get_server_languages($new=false)
{
global $user;
@@ -225,6 +266,16 @@ UPDATE '.USER_INFOS_TABLE.'
return false;
}
+ // Languages to check
+ $languages_to_check = array();
+ foreach($this->fs_languages as $fs_language)
+ {
+ if (isset($fs_language['extension']))
+ {
+ $languages_to_check[] = $fs_language['extension'];
+ }
+ }
+
// Retrieve PEM languages infos
$url = PEM_URL . '/api/get_revision_list.php';
$get_data = array_merge($get_data, array(
@@ -233,6 +284,17 @@ UPDATE '.USER_INFOS_TABLE.'
'lang' => $user['language'],
)
);
+ if (!empty($languages_to_check))
+ {
+ if ($new)
+ {
+ $get_data['extension_exclude'] = implode(',', $languages_to_check);
+ }
+ else
+ {
+ $get_data['extension_include'] = implode(',', $languages_to_check);
+ }
+ }
if (fetchRemote($url, $result, $get_data))
{
@@ -243,12 +305,12 @@ UPDATE '.USER_INFOS_TABLE.'
}
foreach ($pem_languages as $language)
{
- if (preg_match('/^.*? \[[A-Z]{2}\]$/', $language['extension_name'])
- and !in_array($language['extension_name'], $this->fs_languages))
+ if (preg_match('/^.*? \[[A-Z]{2}\]$/', $language['extension_name']))
{
- $this->server_languages[] = $language;
+ $this->server_languages[$language['extension_name']] = $language;
}
}
+ @ksort($this->server_languages);
return true;
}
return false;
@@ -280,8 +342,8 @@ UPDATE '.USER_INFOS_TABLE.'
{
foreach ($list as $file)
{
- // we search iso.txt in archive
- if (basename($file['filename']) == 'iso.txt'
+ // we search common.lang.php in archive
+ if (basename($file['filename']) == 'common.lang.php'
and (!isset($main_filepath)
or strlen($file['filename']) < strlen($main_filepath)))
{
@@ -290,7 +352,7 @@ UPDATE '.USER_INFOS_TABLE.'
}
if (isset($main_filepath))
{
- $root = basename(dirname($main_filepath)); // iso.txt path in archive
+ $root = basename(dirname($main_filepath)); // common.lang.php path in archive
if (preg_match('/^[a-z]{2}_[A-Z]{2}$/', $root))
{
if ($action == 'install')
diff --git a/admin/languages_installed.php b/admin/languages_installed.php
index a43883708..2f4c23f30 100644
--- a/admin/languages_installed.php
+++ b/admin/languages_installed.php
@@ -54,13 +54,9 @@ $default_language = get_default_language();
$tpl_languages = array();
-foreach($languages->fs_languages as $language_id => $language_name)
+foreach($languages->fs_languages as $language_id => $language)
{
- $language = array(
- 'id' => $language_id,
- 'name' => $language_name,
- 'u_action' => $base_url.'&amp;language='.$language_id,
- );
+ $language['u_action'] = add_url_params($base_url, array('language' => $language_id));
if (in_array($language_id, array_keys($languages->db_languages)))
{
diff --git a/admin/languages_new.php b/admin/languages_new.php
index 98bd52d9a..6f3d0abfa 100644
--- a/admin/languages_new.php
+++ b/admin/languages_new.php
@@ -107,7 +107,7 @@ if (isset($_GET['installstatus']))
// +-----------------------------------------------------------------------+
// | start template output |
// +-----------------------------------------------------------------------+
-if ($languages->get_server_languages())
+if ($languages->get_server_languages(true))
{
foreach($languages->server_languages as $language)
{
diff --git a/install.php b/install.php
index d613b8c95..c74780dea 100644
--- a/install.php
+++ b/install.php
@@ -192,7 +192,7 @@ else
{
$language = 'en_UK';
// Try to get browser language
- foreach ($languages->fs_languages as $language_code => $language_name)
+ foreach ($languages->fs_languages as $language_code => $fs_language)
{
if (substr($language_code,0,2) == @substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2))
{
@@ -340,7 +340,7 @@ INSERT INTO '.$prefixeTable.'config (param,value,comment)
pwg_query($query);
// fill languages table
- foreach ($languages->get_fs_languages() as $language_code => $language_name)
+ foreach ($languages->get_fs_languages() as $language_code => $fs_language)
{
$languages->perform_action('activate', $language_code);
}
@@ -417,13 +417,13 @@ INSERT INTO '.$prefixeTable.'config (param,value,comment)
//------------------------------------------------------ start template output
$dbengines = available_engines();
-foreach ($languages->fs_languages as $language_code => $language_name)
+foreach ($languages->fs_languages as $language_code => $fs_language)
{
if ($language == $language_code)
{
$template->assign('language_selection', $language_code);
}
- $languages_options[$language_code] = $language_name;
+ $languages_options[$language_code] = $fs_language['name'];
}
$template->assign('language_options', $languages_options);
diff --git a/install/db/90-database.php b/install/db/90-database.php
index c908c4fd5..e911cc879 100644
--- a/install/db/90-database.php
+++ b/install/db/90-database.php
@@ -49,7 +49,7 @@ include_once(PHPWG_ROOT_PATH.'admin/include/languages.class.php');
$languages = new languages(PWG_CHARSET);
-foreach ($languages->fs_languages as $language_code => $language_name)
+foreach ($languages->fs_languages as $language_code => $fs_language)
{
$languages->perform_action('activate', $language_code);
}
diff --git a/install/php5_apache_configuration.php b/install/php5_apache_configuration.php
index f3768be32..8fc7f8021 100644
--- a/install/php5_apache_configuration.php
+++ b/install/php5_apache_configuration.php
@@ -174,10 +174,10 @@ else
<td>'.l10n('Language').'</td>
<td>
<select name="language" onchange="document.location = \''.$script.'.php?language=\'+this.options[this.selectedIndex].value;">';
- foreach ($languages->fs_languages as $code => $name)
+ foreach ($languages->fs_languages as $code => $fs_language)
{
echo '
- <option label="'.$name.'" value="'.$code.'" '.($code == $language ? 'selected="selected"' : '') .'>'.$name.'</option>';
+ <option label="'.$fs_language['name'].'" value="'.$code.'" '.($code == $language ? 'selected="selected"' : '') .'>'.$fs_language['name'].'</option>';
}
echo '
</select>
diff --git a/upgrade.php b/upgrade.php
index 391119303..ef2476e3a 100644
--- a/upgrade.php
+++ b/upgrade.php
@@ -159,7 +159,7 @@ else
{
$language = 'en_UK';
// Try to get browser language
- foreach ($languages->fs_languages as $language_code => $language_name)
+ foreach ($languages->fs_languages as $language_code => $fs_language)
{
if (substr($language_code,0,2) == @substr($_SERVER["HTTP_ACCEPT_LANGUAGE"],0,2))
{
@@ -400,13 +400,13 @@ else
include_once(PHPWG_ROOT_PATH.'admin/include/languages.class.php');
$languages = new languages();
- foreach ($languages->fs_languages as $language_code => $language_name)
+ foreach ($languages->fs_languages as $language_code => $fs_language)
{
if ($language == $language_code)
{
$template->assign('language_selection', $language_code);
}
- $languages_options[$language_code] = $language_name;
+ $languages_options[$language_code] = $fs_language['name'];
}
$template->assign('language_options', $languages_options);