[5357] | 1 | <?php |
---|
| 2 | // +-----------------------------------------------------------------------+ |
---|
[8728] | 3 | // | Piwigo - a PHP based photo gallery | |
---|
[5357] | 4 | // +-----------------------------------------------------------------------+ |
---|
| 5 | // | Copyright(C) 2008-2009 Piwigo Team http://piwigo.org | |
---|
| 6 | // | Copyright(C) 2003-2008 PhpWebGallery Team http://phpwebgallery.net | |
---|
| 7 | // | Copyright(C) 2002-2003 Pierrick LE GALL http://le-gall.net/pierrick | |
---|
| 8 | // +-----------------------------------------------------------------------+ |
---|
| 9 | // | This program is free software; you can redistribute it and/or modify | |
---|
| 10 | // | it under the terms of the GNU General Public License as published by | |
---|
| 11 | // | the Free Software Foundation | |
---|
| 12 | // | | |
---|
| 13 | // | This program is distributed in the hope that it will be useful, but | |
---|
| 14 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
| 15 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
| 16 | // | General Public License for more details. | |
---|
| 17 | // | | |
---|
| 18 | // | You should have received a copy of the GNU General Public License | |
---|
| 19 | // | along with this program; if not, write to the Free Software | |
---|
| 20 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
| 21 | // | USA. | |
---|
| 22 | // +-----------------------------------------------------------------------+ |
---|
| 23 | |
---|
| 24 | if( !defined("PHPWG_ROOT_PATH") ) |
---|
| 25 | { |
---|
| 26 | die ("Hacking attempt!"); |
---|
| 27 | } |
---|
| 28 | |
---|
| 29 | include_once(PHPWG_ROOT_PATH.'admin/include/languages.class.php'); |
---|
| 30 | |
---|
| 31 | $template->set_filenames(array('languages' => 'languages_installed.tpl')); |
---|
| 32 | |
---|
| 33 | $base_url = get_root_url().'admin.php?page='.$page['page']; |
---|
| 34 | |
---|
| 35 | $languages = new languages(); |
---|
| 36 | $languages->get_db_languages(); |
---|
[5371] | 37 | $languages->set_tabsheet($page['page']); |
---|
[5357] | 38 | |
---|
| 39 | //--------------------------------------------------perform requested actions |
---|
[8126] | 40 | if (isset($_GET['action']) and isset($_GET['language'])) |
---|
[5357] | 41 | { |
---|
| 42 | $page['errors'] = $languages->perform_action($_GET['action'], $_GET['language']); |
---|
| 43 | |
---|
| 44 | if (empty($page['errors'])) |
---|
| 45 | { |
---|
| 46 | redirect($base_url); |
---|
| 47 | } |
---|
| 48 | } |
---|
| 49 | |
---|
| 50 | // +-----------------------------------------------------------------------+ |
---|
| 51 | // | start template output | |
---|
| 52 | // +-----------------------------------------------------------------------+ |
---|
| 53 | $default_language = get_default_language(); |
---|
| 54 | |
---|
[5496] | 55 | $tpl_languages = array(); |
---|
| 56 | |
---|
[9518] | 57 | foreach($languages->fs_languages as $language_id => $language) |
---|
[5357] | 58 | { |
---|
[9518] | 59 | $language['u_action'] = add_url_params($base_url, array('language' => $language_id)); |
---|
[5496] | 60 | |
---|
| 61 | if (in_array($language_id, array_keys($languages->db_languages))) |
---|
| 62 | { |
---|
| 63 | $language['state'] = 'active'; |
---|
| 64 | $language['deactivable'] = true; |
---|
[5642] | 65 | |
---|
[5496] | 66 | if (count($languages->db_languages) <= 1) |
---|
| 67 | { |
---|
| 68 | $language['deactivable'] = false; |
---|
| 69 | $language['deactivate_tooltip'] = l10n('Impossible to deactivate this language, you need at least one language.'); |
---|
| 70 | } |
---|
| 71 | |
---|
| 72 | if ($language_id == $default_language) |
---|
| 73 | { |
---|
| 74 | $language['deactivable'] = false; |
---|
| 75 | $language['deactivate_tooltip'] = l10n('Impossible to deactivate this language, first set another language as default.'); |
---|
| 76 | } |
---|
| 77 | } |
---|
| 78 | else |
---|
| 79 | { |
---|
| 80 | $language['state'] = 'inactive'; |
---|
| 81 | } |
---|
[5642] | 82 | |
---|
[5496] | 83 | if ($language_id == $default_language) |
---|
| 84 | { |
---|
| 85 | $language['is_default'] = true; |
---|
| 86 | array_unshift($tpl_languages, $language); |
---|
| 87 | } |
---|
| 88 | else |
---|
| 89 | { |
---|
[5642] | 90 | $language['is_default'] = false; |
---|
[5496] | 91 | array_push($tpl_languages, $language); |
---|
| 92 | } |
---|
| 93 | } |
---|
| 94 | |
---|
| 95 | $template->assign( |
---|
| 96 | array( |
---|
| 97 | 'languages' => $tpl_languages, |
---|
[5357] | 98 | ) |
---|
| 99 | ); |
---|
[5496] | 100 | $template->append('language_states', 'active'); |
---|
| 101 | $template->append('language_states', 'inactive'); |
---|
[5357] | 102 | |
---|
| 103 | |
---|
| 104 | $missing_language_ids = array_diff( |
---|
| 105 | array_keys($languages->db_languages), |
---|
| 106 | array_keys($languages->fs_languages) |
---|
| 107 | ); |
---|
| 108 | |
---|
| 109 | foreach($missing_language_ids as $language_id) |
---|
| 110 | { |
---|
| 111 | $query = ' |
---|
| 112 | UPDATE '.USER_INFOS_TABLE.' |
---|
[6550] | 113 | SET language = \''.get_default_language().'\' |
---|
| 114 | WHERE language = \''.$language_id.'\' |
---|
[5357] | 115 | ;'; |
---|
| 116 | pwg_query($query); |
---|
| 117 | |
---|
[6550] | 118 | $query = ' |
---|
[5357] | 119 | DELETE |
---|
[6550] | 120 | FROM '.LANGUAGES_TABLE.' |
---|
| 121 | WHERE id= \''.$language_id.'\' |
---|
| 122 | ;'; |
---|
[5357] | 123 | pwg_query($query); |
---|
| 124 | } |
---|
| 125 | |
---|
| 126 | $template->assign_var_from_handle('ADMIN_CONTENT', 'languages'); |
---|
[5642] | 127 | ?> |
---|