New extension added, more EL-rewrites, naming-convention applied:
[mailer.git] / inc / modules / admin / what-repair_lang.php
1 <?php
2 /************************************************************************
3  * Mailer v0.2.1-FINAL                                Start: 02/12/2004 *
4  * ===================                          Last change: 02/12/2004 *
5  *                                                                      *
6  * -------------------------------------------------------------------- *
7  * File              : what-repair_lang.php                             *
8  * -------------------------------------------------------------------- *
9  * Short description : "Repairs" the language system                    *
10  * -------------------------------------------------------------------- *
11  * Kurzbeschreibung  : "Repariert" das Sprachsystem                     *
12  * -------------------------------------------------------------------- *
13  * $Revision::                                                        $ *
14  * $Date::                                                            $ *
15  * $Tag:: 0.2.1-FINAL                                                 $ *
16  * $Author::                                                          $ *
17  * Needs to be in all Files and every File needs "svn propset           *
18  * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
19  * -------------------------------------------------------------------- *
20  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
21  * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
22  * For more information visit: http://www.mxchange.org                  *
23  *                                                                      *
24  * This program is free software; you can redistribute it and/or modify *
25  * it under the terms of the GNU General Public License as published by *
26  * the Free Software Foundation; either version 2 of the License, or    *
27  * (at your option) any later version.                                  *
28  *                                                                      *
29  * This program is distributed in the hope that it will be useful,      *
30  * but WITHOUT ANY WARRANTY; without even the implied warranty of       *
31  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        *
32  * GNU General Public License for more details.                         *
33  *                                                                      *
34  * You should have received a copy of the GNU General Public License    *
35  * along with this program; if not, write to the Free Software          *
36  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston,               *
37  * MA  02110-1301  USA                                                  *
38  ************************************************************************/
39
40 // Some security stuff...
41 if ((!defined('__SECURITY')) || (!isAdmin())) {
42         die();
43 } // END - if
44
45 // Add description as navigation point
46 addMenuDescription('admin', __FILE__);
47
48 // Get a list with current language files
49 $langFiles = getArrayFromDirectory('inc/language/', '', false, false, array('_de.php'), '.php', '@(\.|\.\.)$@', true, getCurrentLanguage());
50
51 // By default nothing is checked, which is isn't right...
52 $SW = 2; $OUT = '';
53
54 // Get valid languages
55 $validLanguages = getValidLanguages(getCurrentLanguage());
56
57 // Check for all languages except current language
58 foreach ($validLanguages as $lang) {
59         // Now check for all files
60         foreach ($langFiles as $langFile) {
61                 // Get prefix
62                 $prefix = explode('_', $langFile);
63                 $prefix = $prefix[0];
64
65                 // If we have a prefix append the underscore
66                 if ((!empty($prefix)) && ($prefix != $langFile)) {
67                         // Add underscore for prefix files
68                         $prefix .= '_';
69                 } else {
70                         // Keep it empty for general language file
71                         $prefix = '';
72                 }
73
74                 // Construct english include filename
75                 $INC = sprintf("inc/language/%s%s.php", $prefix, $lang);
76
77                 // Is the file readable?
78                 if (isIncludeReadable($INC)) {
79                         // Readable so compare both
80                         if (ifLanguageFilesCompares('inc/language/' . $langFile, $INC, $lang)) {
81                                 // Compares so prepare content
82                                 $content = array(
83                                         'source' => $langFile,
84                                         'target' => basename($INC),
85                                         'sw'     => $SW,
86                                 );
87
88                                 // Compares, all fine
89                                 $OUT .= loadTemplate('admin_repair_lang_row_compares', true, $content);
90                         } else {
91                                 // Generate difference output only if count is smaller/equals 100 entries
92                                 $diffContent = '<ul>';
93                                 if (count($GLOBALS['lang_diff'][$INC]) <= 100) {
94                                         // Display them, it is not more than 100 entries difference
95                                         foreach ($GLOBALS['lang_diff'][$INC] as $key => $value) {
96                                                 $diffContent .= '<li>' . $key . '=' . htmlentities($value) . '</li>';
97                                         } // END - foreach
98                                 } else {
99                                         // To much to display!
100                                         $diffContent .= '<li>{--ADMIN_REPAIR_LANGUAGE_TO_MUCH--}</li>';
101                                 }
102                                 $diffContent .= '</ul>';
103
104                                 // Prepare content
105                                 $content = array(
106                                         'source'       => $langFile,
107                                         'target'       => basename($INC),
108                                         'diff_count'   => translateComma(getLanguageComparisonDifference($INC)),
109                                         'diff_content' => $diffContent,
110                                         'sw'           => $SW,
111                                 );
112
113                                 // Compares, all fine
114                                 $OUT .= loadTemplate('admin_repair_lang_row_diff', true, $content);
115                         }
116                 } else {
117                         // Not readable, prepare content
118                         $content = array(
119                                 'file'    => basename($INC),
120                                 'lang'    => $lang,
121                                 'sw'      => $SW,
122                         );
123
124                         // Load template
125                         $OUT .= loadTemplate('admin_repair_lang_row_404', true, $content);
126                 }
127
128                 // Switch color
129                 $SW = 3 - $SW;
130         } // END - foreach
131 } // END - foreach
132
133 // Preapre content
134 $content = array(
135         'rows'       => $OUT,
136         'file_count' => translateComma(count($langFiles)),
137         'total_diff' => translateComma($GLOBALS['lang_diff_count']['total']),
138         'total_msgs' => translateComma($GLOBALS['msg_count'][getCurrentLanguage()]),
139 );
140
141 // Load main template
142 loadTemplate('admin_repair_lang', false, $content);
143
144 // [EOF]
145 ?>