Changeset 23472 for extensions/plugin_lang_analysis/admin.php
- Timestamp:
- Jun 23, 2013, 7:50:07 PM (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
extensions/plugin_lang_analysis/admin.php
r23467 r23472 7 7 8 8 include_once(PLA_PATH . 'include/functions.inc.php'); 9 include_once(PHPWG_ROOT_PATH . ' /admin/include/plugins.class.php');9 include_once(PHPWG_ROOT_PATH . 'admin/include/plugins.class.php'); 10 10 $plugins = new plugins(); 11 11 12 /* PLUGINS LIST */12 /* SELECT */ 13 13 if (!isset($_GET['plugin_id'])) 14 14 { … … 20 20 } 21 21 22 /* FILES LIST*/22 /* CONFIG */ 23 23 else if (!isset($_GET['analyze'])) 24 24 { … … 45 45 foreach ($files as &$file) 46 46 { 47 if (isset($saved_files[ $file]))48 { 49 $file = $saved_files[ $file];47 if (isset($saved_files[ $file ])) 48 { 49 $file = $saved_files[ $file ]; 50 50 $file['lang_files'] = array_intersect($file['lang_files'], array_keys($language_files)); 51 51 } … … 65 65 'PLA_PLUGIN' => $plugins->fs_plugins[ $_GET['plugin_id'] ], 66 66 'PLA_FILES' => $files, 67 'PLA_LANG_FILES' => $language_files,67 'PLA_LANG_FILES' => array_keys($language_files), 68 68 'F_ACTION' => PLA_ADMIN.'&plugin_id='.$_GET['plugin_id'].'&analyze', 69 69 'U_BACK' => PLA_ADMIN, 70 70 )); 71 71 } 72 73 /* ANALYSIS */ 72 74 else 73 75 { … … 78 80 foreach ($_POST['files'] as $file => $data) 79 81 { 80 $files[ $file] = array(82 $files[ $file ] = array( 81 83 'path' => $file, 82 84 'is_admin' => $data['is_admin']=='true', … … 85 87 if (!empty($data['lang_files'])) 86 88 { 87 $files[ $file]['lang_files'] = array_keys(array_filter($data['lang_files'], create_function('$f', 'return $f=="true";')));89 $files[ $file ]['lang_files'] = array_keys(array_filter($data['lang_files'], create_function('$f', 'return $f=="true";'))); 88 90 } 89 91 } … … 125 127 } 126 128 127 // analy ze129 // analyse 128 130 foreach ($strings as $string => &$string_data) 129 131 { 130 // find where t ehstring is defined132 // find where the string is defined 131 133 $string_data['in_common'] = array_key_exists($string, $lang_common); 132 134 $string_data['in_admin'] = array_key_exists($string, $lang_admin); … … 137 139 } 138 140 141 // very rare case 142 if (count($string_data['in_plugin'])>1) 143 { 144 $string_data['warnings'][] = l10n('This string is translated in multiple files'); 145 } 146 139 147 $missing = $useless = $ok = false; 140 148 $string_data['is_admin'] = true; 141 149 142 // analy ze for each file where the string exists150 // analyse for each file where the string exists 143 151 foreach ($string_data['files'] as $file => &$file_data) 144 152 { … … 147 155 148 156 // find if the string is translated in one of the language files included in this file 149 $exists = false; 150 foreach ($file_data['lang_files'] as $lang_file) 151 { 152 if (in_array($lang_file, $string_data['in_plugin'])) 153 { 154 $exists = true; 155 break; 156 } 157 } 157 $exists = count(array_intersect($file_data['lang_files'], $string_data['in_plugin'])) > 0; 158 158 159 159 // useless if translated in the plugin AND in common or admin … … 193 193 else 194 194 { 195 // another very rare case 196 if ($useless) 197 { 198 $string_data['warnings'][] = l10n('This string is useless in some files'); 199 } 200 195 201 $string_data['stat'] = 'ok'; 196 202 $counts['ok']++; … … 199 205 unset($string_data); 200 206 201 uksort($strings, 'strnatcasecmp'); 207 uksort($strings, 'strnatcasecmp'); // natural sort 202 208 $counts['total'] = array_sum($counts); 203 209 … … 206 212 'PLA_PLUGIN' => $plugins->fs_plugins[ $_GET['plugin_id'] ], 207 213 'PLA_STRINGS' => $strings, 208 'PLA_LANG_FILES' => $language_files,214 'PLA_LANG_FILES' => array_keys($language_files), 209 215 'PLA_COUNTS' => $counts, 210 216 'U_BACK' => PLA_ADMIN.'&plugin_id='.$_GET['plugin_id'], … … 215 221 $template->assign(array( 216 222 'PLA_PATH'=> PLA_PATH, 217 'PLA_ABS_PATH'=> realpath(PLA_PATH) ,223 'PLA_ABS_PATH'=> realpath(PLA_PATH).'/', 218 224 'PLA_ADMIN' => PLA_ADMIN, 219 225 ));
Note: See TracChangeset
for help on using the changeset viewer.