[ Index ] |
|
Code source de Claroline 188 |
1 <?php // $Id: progression_translation.php,v 1.20 2007/01/12 09:23:31 mathieu Exp $ 2 //---------------------------------------------------------------------- 3 // CLAROLINE 4 //---------------------------------------------------------------------- 5 // Copyright (c) 2001-2006 Universite catholique de Louvain (UCL) 6 //---------------------------------------------------------------------- 7 // This program is under the terms of the GENERAL PUBLIC LICENSE (GPL) 8 // as published by the FREE SOFTWARE FOUNDATION. The GPL is available 9 // through the world-wide-web at http://www.gnu.org/copyleft/gpl.html 10 //---------------------------------------------------------------------- 11 // Authors: see 'credits' file 12 //---------------------------------------------------------------------- 13 14 require '../../../../inc/claro_init_global.inc.php'; 15 16 // Security check 17 if ( ! claro_is_user_authenticated() ) claro_disp_auth_form(); 18 if ( ! claro_is_platform_admin() ) claro_die(get_lang('Not allowed')); 19 20 /* 21 * This script display progression of all language. 22 */ 23 24 // include configuration and library file 25 include ('language.conf.php'); 26 include ('language.lib.php'); 27 include(get_path('incRepositorySys')."/lib/pager.lib.php"); 28 29 // table 30 31 32 $tbl_used_lang = '`' . get_conf('mainDbName') . '`.`' . get_conf('mainTblPrefix') . TABLE_USED_LANG_VAR . '`'; 33 $tbl_translation = '`' . get_conf('mainDbName') . '`.`' . get_conf('mainTblPrefix') . TABLE_TRANSLATION . '`'; 34 35 // get start time 36 $starttime = get_time(); 37 38 // pager params 39 40 $resultPerPage = 50; 41 42 if (isset($_REQUEST['offset'])) 43 { 44 $offset = $_REQUEST['offset']; 45 } 46 else 47 { 48 $offset = 0; 49 } 50 51 // start content 52 $nameTools = 'Display Progression of Translations'; 53 54 $urlSDK = get_path('rootAdminWeb') . 'xtra/sdk/'; 55 $urlTranslation = $urlSDK . 'translation_index.php'; 56 $interbredcrump[] = array ("url"=>get_path('rootAdminWeb'), "name"=> get_lang('Administration')); 57 $interbredcrump[] = array ("url"=>$urlSDK, "name"=> get_lang('SDK')); 58 $interbredcrump[] = array ("url"=>$urlTranslation, "name"=> get_lang('Translation Tools')); 59 60 include get_path('incRepositorySys')."/claro_init_header.inc.php"; 61 62 // count different variables in script 63 $sql = " SELECT count(DISTINCT varName) 64 FROM " . $tbl_used_lang . ""; 65 66 $results = claro_sql_query($sql); 67 $row = mysql_fetch_row($results); 68 $count_total_diff_var = $row[0]; 69 70 echo claro_html_tool_title($nameTools) 71 . '<p>Total variables in Claroline scripts: <strong>' . $count_total_diff_var . '</strong></p>'; 72 73 if ( isset($_REQUEST['exCmd']) && $_REQUEST['exCmd'] == 'ToTranslate' ) 74 { 75 76 if ( isset($_REQUEST['lang'])) 77 { 78 $language = $_REQUEST['lang']; 79 } 80 else 81 { 82 $language = DEFAULT_LANGUAGE ; 83 } 84 85 printf("<p><a href=\"%s\">Back</a></p>",$_SERVER['PHP_SELF']); 86 printf("<h4>Missing variables in %s</h4>",$language); 87 88 // count missing lang var in devel complete file for this language 89 $sql = " SELECT DISTINCT u.varName, u.sourceFile 90 FROM ". $tbl_used_lang . " u 91 LEFT JOIN " . $tbl_translation . " t ON 92 ( 93 u.varName = t.varName 94 AND t.language=\"" . $language . "\" 95 ) 96 WHERE t.varContent is NULL 97 ORDER BY u.varName, u.sourceFile "; 98 99 // build pager 100 $myPager = new claro_sql_pager($sql, $offset, $resultPerPage); 101 $result_missing_var = $myPager->get_result_list(); 102 103 // display pager 104 echo $myPager->disp_pager_tool_bar($_SERVER['PHP_SELF'].'?exCmd=ToTranslate&lang='.$language); 105 106 // display table header 107 echo "<table class=\"claroTable\" width=\"100%\" >\n"; 108 echo "<thead>" 109 . "<tr class=\"headerX\">" 110 . "<th>VarName</th>" 111 . "<th>SourceFile</th>" 112 . "</tr>" 113 . "</thead>" 114 . "<tbody>\n"; 115 116 // variables used to switch background color 117 $varName = ''; 118 $color = true; 119 120 // browse missing variables 121 foreach ( $result_missing_var as $row_missing_var ) 122 { 123 // get values 124 $sourceFile = $row_missing_var['sourceFile']; 125 if ($row_missing_var['varName'] != $varName) 126 { 127 $varName = $row_missing_var['varName']; 128 $color = !$color; 129 } 130 131 // display row 132 if ($color) 133 { 134 echo "<tr style=\"background-color: #ccc;\">\n"; 135 } 136 else 137 { 138 echo "<tr>\n"; 139 } 140 141 echo "<td>". $varName ."</td>\n" 142 . "<td><a href=\"http://cvs.claroline.net/cgi-bin/viewcvs.cgi/claroline/" . $sourceFile . "\">". $sourceFile ."</a></td>\n" 143 . "</tr>\n"; 144 } 145 146 // display table footer 147 echo "</tbody>"; 148 echo "</table>"; 149 150 // display pager 151 echo $myPager->disp_pager_tool_bar($_SERVER['PHP_SELF'].'?exCmd=ToTranslate&lang='.$language); 152 153 // display nb results 154 echo '<p>' . get_lang('Total') . ': ' . $myPager->totalResultCount . '</p>' ; 155 156 } 157 else 158 { 159 160 /* 161 * Display a table and display each language variable translated, to translate and complete pourcentage of the translation 162 */ 163 164 // get all languages 165 $sql = " SELECT DISTINCT language 166 FROM " . $tbl_translation . ""; 167 $result_language = claro_sql_query($sql); 168 169 // display table header 170 echo "<table class=\"claroTable\">\n"; 171 echo "<thead> 172 <tr class=\"headerX\"> 173 <th>Language</th> 174 <th>Translated</th> 175 <th>To translate</th> 176 <th>Complete %</th> 177 </tr> 178 </thead> 179 <tbody>\n"; 180 181 while ($row_language = mysql_fetch_array($result_language)) 182 { 183 // get language 184 $language = $row_language['language']; 185 186 // count missing lang var in devel complete file for this language 187 $sql = " SELECT count(DISTINCT u.varName) 188 FROM ". $tbl_used_lang . " u 189 LEFT JOIN " . $tbl_translation . " t ON 190 ( 191 u.varName = t.varName 192 AND t.language=\"" . $language . "\" 193 ) 194 WHERE t.varContent is NOT NULL "; 195 196 // execute query and get result 197 $result_missing_var_count = claro_sql_query($sql); 198 $row_missing_var_count = mysql_fetch_row($result_missing_var_count); 199 200 // compute field 201 $count_var_translated = $row_missing_var_count[0]; 202 $count_var_to_translate = $count_total_diff_var - $count_var_translated; 203 $pourcent_progession = (float) round (1000 * $count_var_translated / $count_total_diff_var) / 10; 204 205 // display row 206 207 if ( $pourcent_progession > 60 ) echo "<tr style=\"font-weight: bold;\">\n"; 208 else echo "<tr>\n"; 209 210 echo "<td>" . $language . "</td>\n" 211 . "<td style=\"text-align: right\">" . $count_var_translated . "</td>\n" 212 . "<td style=\"text-align: right\">" ; 213 214 if ( isset($_REQUEST['cmd']) && $_REQUEST['cmd'] == 'export' ) 215 { 216 echo $count_var_to_translate; 217 } 218 else 219 { 220 echo "<a href=\"" . $_SERVER['PHP_SELF'] . "?exCmd=ToTranslate&lang=" . $language . "\">" . $count_var_to_translate . "</a>"; 221 } 222 223 echo "</td>\n" 224 . "<td style=\"text-align: right\">" . $pourcent_progession . " %</td>\n" 225 . "</tr>\n"; 226 } 227 228 echo "</tbody>"; 229 echo "</table>"; 230 } 231 232 // get end time 233 $endtime = get_time(); 234 $totaltime = ($endtime - $starttime); 235 236 echo "<p><em>Execution time: $totaltime</em></p>"; 237 238 // display footer 239 240 include get_path('incRepositorySys') . '/claro_init_footer.inc.php'; 241 242 ?>
titre
Description
Corps
titre
Description
Corps
titre
Description
Corps
titre
Corps
Généré le : Thu Nov 29 14:38:42 2007 | par Balluche grâce à PHPXref 0.7 |
![]() |