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