Changeset 120927 in spip-zone for _plugins_/trad-lang/trunk/salvatore/ecriveur.php
- Timestamp:
- Feb 3, 2020, 11:33:53 AM (15 months ago)
- Location:
- _plugins_/trad-lang/trunk
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
_plugins_/trad-lang/trunk
- Property subgit:lock:b5b18d5ca74af90dd3b6eec1ee901b6243b99995 deleted
-
Property
subgit:lock:97fad06ac2eeb417a2f67d0b6ef90121a4b78dd8
set to
2020-02-03T12:33:59.778
-
_plugins_/trad-lang/trunk/salvatore/ecriveur.php
r120887 r120927 181 181 $comment = salvatore_clean_comment($chaine['comm']); 182 182 183 if ($initiale !==strtoupper($chaine['id'][0])){183 if ($initiale!==strtoupper($chaine['id'][0])){ 184 184 $initiale = strtoupper($chaine['id'][0]); 185 185 $php_lines[] = "\n$indent// $initiale"; … … 207 207 } 208 208 209 salvatore_log(" - traduction (" .$total_chaines['OK']."/$count_trad_reference OK | ".$total_chaines['RELIRE']."/$count_trad_reference RELIRE | ".$total_chaines['MODIF']."/$count_trad_reference MODIFS), export");209 salvatore_log(" - traduction (" . $total_chaines['OK'] . "/$count_trad_reference OK | " . $total_chaines['RELIRE'] . "/$count_trad_reference RELIRE | " . $total_chaines['MODIF'] . "/$count_trad_reference MODIFS), export"); 210 210 $file_name = salvatore_exporter_fichier_php($dir_module, $module, $lang, $php_lines, $url_trad_module, ($lang==$lang_ref) ? $url_repo : false); 211 211 … … 245 245 unset($people_unique); 246 246 247 $commit_infos[$lang]['lang'] = $lang; 248 $commit_infos[$lang]['file_name'] = basename($file_name); 249 $commit_infos[$lang]['lastmodified'] = salvatore_read_lastmodified_file(basename($file_name), $source, $dir_depots); 250 $commit_infos[$lang]['must_add'] = false; 251 252 if ($row_module['limite_trad']==0){ 253 $commit_infos[$lang]['must_add'] = true; 254 } elseif (!in_array($module, array('ecrire', 'spip', 'public'))) { 255 if ((intval(($xml_infos[$lang]['traduits']/$count_trad_reference)*100)>$seuil_export)){ 247 if (salvatore_file_need_commit(basename($file_name), $source, $dir_depots)){ 248 249 $commit_infos[$lang]['lang'] = $lang; 250 $commit_infos[$lang]['file_name'] = basename($file_name); 251 $commit_infos[$lang]['lastmodified'] = salvatore_read_lastmodified_file(basename($file_name), $source, $dir_depots); 252 $commit_infos[$lang]['must_add'] = false; 253 254 if ($row_module['limite_trad']==0){ 256 255 $commit_infos[$lang]['must_add'] = true; 257 } 258 } 259 260 // trouver le commiteur si c'est un fichier deja versionne ou a ajouter 261 if ($commit_infos[$lang]['lastmodified'] or $commit_infos[$lang]['must_add']) { 262 $where = [ 263 "objet='tradlang'", 264 sql_in('id_objet', $id_tradlangs), 265 "id_auteur != '-1'", 266 'id_auteur !=' . intval(_ID_AUTEUR_SALVATORE), 267 ]; 268 if ($commit_infos[$lang]['lastmodified']) { 269 $where[] = "date>".sql_quote(date('Y-m-d H:i:s', $commit_infos[$lang]['lastmodified'])); 270 } 271 $auteur_versions = sql_allfetsel('DISTINCT id_auteur', 'spip_versions', $where); 272 if (count($auteur_versions)==1){ 273 $auteur = sql_fetsel('nom,email', 'spip_auteurs', 'id_auteur = ' . intval($auteur_versions[0]['id_auteur'])); 274 if ($auteur and $auteur['email']){ 275 $commit_infos[$lang]['author'] = $auteur['email']; 276 if ($auteur['nom']) { 277 $commit_infos[$lang]['author'] = $auteur['nom'] . " <" . $commit_infos[$lang]['author'] . ">"; 256 } elseif (!in_array($module, array('ecrire', 'spip', 'public'))) { 257 if ((intval(($xml_infos[$lang]['traduits']/$count_trad_reference)*100)>$seuil_export)){ 258 $commit_infos[$lang]['must_add'] = true; 259 } 260 } 261 262 // trouver le commiteur si c'est un fichier deja versionne ou a ajouter 263 if ($commit_infos[$lang]['lastmodified'] or $commit_infos[$lang]['must_add']){ 264 $where = [ 265 "objet='tradlang'", 266 sql_in('id_objet', $id_tradlangs), 267 "id_auteur != '-1'", 268 'id_auteur !=' . intval(_ID_AUTEUR_SALVATORE), 269 ]; 270 if ($commit_infos[$lang]['lastmodified']){ 271 $where[] = "date>" . sql_quote(date('Y-m-d H:i:s', $commit_infos[$lang]['lastmodified'])); 272 } 273 $auteur_versions = sql_allfetsel('DISTINCT id_auteur', 'spip_versions', $where); 274 if (count($auteur_versions)==1){ 275 $auteur = sql_fetsel('nom,email', 'spip_auteurs', 'id_auteur = ' . intval($auteur_versions[0]['id_auteur'])); 276 if ($auteur and $auteur['email']){ 277 $commit_infos[$lang]['author'] = $auteur['email']; 278 if ($auteur['nom']){ 279 $commit_infos[$lang]['author'] = $auteur['nom'] . " <" . $commit_infos[$lang]['author'] . ">"; 280 } 281 salvatore_log("Le commiteur pour la langue $lang : " . $commit_infos[$lang]['author']); 278 282 } 279 salvatore_log("Le commiteur pour la langue $lang : " . $commit_infos[$lang]['author']);280 283 } 281 284 } 282 } 285 } else { 286 unset($commit_infos[$lang]); 287 } 288 283 289 } 284 290 … … 311 317 $file_xml = $dir_module . '/' . $module . '.xml'; 312 318 file_put_contents($file_xml, $xml); 313 $commit_infos['.xml'] = array( 314 'file_name' => basename($file_xml), 315 'lastmodified' => salvatore_read_lastmodified_file(basename($file_xml), $source, $dir_depots), 316 'must_add' => true, 317 ); 318 319 if (salvatore_file_need_commit(basename($file_xml), $source, $dir_depots)){ 320 $commit_infos['.xml'] = array( 321 'file_name' => basename($file_xml), 322 'lastmodified' => salvatore_read_lastmodified_file(basename($file_xml), $source, $dir_depots), 323 'must_add' => true, 324 ); 325 } 319 326 320 327 … … 438 445 return $vcs_status_file($dir_depots . $source['dir_checkout'], $files_list); 439 446 } 447 448 449 /** 450 * Recuperer le status d'un fichier pour voir si vide ou si modifie/nouveau 451 * @param string $file 452 * @param array $source 453 * @param $dir_depots 454 * @return string 455 */ 456 function salvatore_file_need_commit($file, $source, $dir_depots) { 457 $pre = ""; 458 if ($source['dir']) { 459 $pre = $source['dir'] . DIRECTORY_SEPARATOR; 460 } 461 462 $vcs_status_file = salvatore_vcs_function($source['methode'], "status_file"); 463 $status = $vcs_status_file($dir_depots . $source['dir_checkout'], $pre . $file); 464 return (strlen(trim($status)) ? true : false); 465 }
Note: See TracChangeset
for help on using the changeset viewer.