chore: phpcbf

master
Matthieu Marcillaud 3 months ago
parent 5de4157539
commit 3a0730918b

@ -65,17 +65,19 @@ function tradlang_set($id_tradlang, $set = null) {
set_request('md5', md5(_request('str')));
}
$invalideur = "id='id_tradlang/$id_tradlang'";
if ($err = objet_modifier_champs(
'tradlang',
$id_tradlang,
[
'data' => $set,
'nonvide' => [],
'invalideur' => $invalideur,
'indexation' => true
],
$c
)) {
if (
$err = objet_modifier_champs(
'tradlang',
$id_tradlang,
[
'data' => $set,
'nonvide' => [],
'invalideur' => $invalideur,
'indexation' => true
],
$c
)
) {
return $err;
}
@ -84,23 +86,23 @@ function tradlang_set($id_tradlang, $set = null) {
$infos_maj = [];
$bilan = sql_fetsel('chaines_ok,chaines_relire,chaines_modif,chaines_new', 'spip_tradlangs_bilans', 'id_tradlang_module=' . (int) $infos_tradlang['id_tradlang_module'] . ' AND lang=' . sql_quote($infos_tradlang['lang']));
if ($statut == 'OK') {
$infos_maj['chaines_ok'] = ($bilan['chaines_ok']+1);
$infos_maj['chaines_ok'] = ($bilan['chaines_ok'] + 1);
} elseif ($statut == 'RELIRE') {
$infos_maj['chaines_relire'] = ($bilan['chaines_relire']+1);
$infos_maj['chaines_relire'] = ($bilan['chaines_relire'] + 1);
} elseif ($statut == 'MODIF') {
$infos_maj['chaines_modif'] = ($bilan['chaines_modif']+1);
} else if ($statut == 'NEW') {
$infos_maj['chaines_new'] = ($bilan['chaines_new']+1);
$infos_maj['chaines_modif'] = ($bilan['chaines_modif'] + 1);
} elseif ($statut == 'NEW') {
$infos_maj['chaines_new'] = ($bilan['chaines_new'] + 1);
}
if ($infos_tradlang['statut'] == 'OK') {
$infos_maj['chaines_ok'] = ($bilan['chaines_ok']-1);
$infos_maj['chaines_ok'] = ($bilan['chaines_ok'] - 1);
} elseif ($infos_tradlang['statut'] == 'RELIRE') {
$infos_maj['chaines_relire'] = ($bilan['chaines_relire']-1);
$infos_maj['chaines_relire'] = ($bilan['chaines_relire'] - 1);
} elseif ($infos_tradlang['statut'] == 'MODIF') {
$infos_maj['chaines_modif'] = ($bilan['chaines_modif']-1);
$infos_maj['chaines_modif'] = ($bilan['chaines_modif'] - 1);
} elseif ($infos_tradlang['statut'] == 'NEW') {
$infos_maj['chaines_new'] = ($bilan['chaines_new']-1);
$infos_maj['chaines_new'] = ($bilan['chaines_new'] - 1);
}
sql_updateq('spip_tradlangs_bilans', $infos_maj, 'id_tradlang_module=' . (int) $infos_tradlang['id_tradlang_module'] . ' AND lang=' . sql_quote($infos_tradlang['lang']));
@ -145,7 +147,7 @@ function instituer_tradlang($id_tradlang, $c) {
'table' => 'spip_tradlangs',
'objet' => 'tradlang',
'id_objet' => $id_tradlang,
'action'=>'instituer',
'action' => 'instituer',
'statut_ancien' => $statut_ancien
],
'data' => $champs
@ -170,7 +172,7 @@ function instituer_tradlang($id_tradlang, $c) {
'table' => 'spip_tradlangs',
'objet' => 'tradlang',
'id_objet' => $id_tradlang,
'action'=>'instituer',
'action' => 'instituer',
'statut_ancien' => $statut_ancien
],
'data' => $champs

@ -1,4 +1,5 @@
<?php
/**
*
* Trad-lang v2
@ -8,23 +9,23 @@
* Action permettant de récupérer un fichier de langue
*
*/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
function action_tradlang_bon_a_pousser_dist(){
function action_tradlang_bon_a_pousser_dist() {
$securiser_action = charger_fonction('securiser_action', 'inc');
$arg = $securiser_action();
$id_tradlang_module = (int) $arg;
if (!$id_tradlang_module){
if (!$id_tradlang_module) {
spip_log("action_tradlang_bon_a_pousser $arg pas compris", 'tradlang.' . _LOG_ERREUR);
return false;
}
sql_updateq("spip_tradlang_modules", ['bon_a_pousser' => 1], 'id_tradlang_module=' . (int) $id_tradlang_module);
sql_updateq('spip_tradlang_modules', ['bon_a_pousser' => 1], 'id_tradlang_module=' . (int) $id_tradlang_module);
include_spip('inc/invalideur');
suivre_invalideur("'tradlang_module/id=$id_tradlang_module'");
}

@ -1,4 +1,5 @@
<?php
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -27,7 +28,7 @@ function action_tradlang_creer_langue_cible_dist() {
spip_log("action_tradlang_creer_langue_cible : infos_module #$id_tradlang_module non existant", 'tradlang.' . _LOG_ERREUR);
} else {
$ajouter_code_langue = charger_fonction('tradlang_ajouter_code_langue', 'inc');
$ajouter_code_langue($infos_module,$lang_crea);
$ajouter_code_langue($infos_module, $lang_crea);
}
} else {
spip_log("action_tradlang_creer_langue_cible : modification module #$id_tradlang_module interdite", 'tradlang.' . _LOG_ERREUR);

@ -1,4 +1,5 @@
<?php
/**
*
* Trad-lang v2
@ -8,6 +9,7 @@
* Action permettant de récupérer un fichier de langue
*
*/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -51,13 +53,13 @@ function action_tradlang_exporter_langue_dist() {
default:
header('Content-Type: application/x-httpd-php;');
}
header('Content-Length: '.filesize($fichier));
header('Content-Length: ' . filesize($fichier));
header('Content-Transfer-Encoding: binary');
header('Pragma: public'); // required
header('Expires: 0');
header('Cache-Control: must-revalidate, post-check=0, pre-check=0');
header('Cache-Control: private', false); // required for certain browsers
header('Content-Disposition: attachment; filename="'.basename($fichier).'"');
header('Content-Disposition: attachment; filename="' . basename($fichier) . '"');
readfile($fichier);
die();
} else {

@ -1,4 +1,5 @@
<?php
/**
*
* Trad-lang v2
@ -8,6 +9,7 @@
* Action permettant de récupérer un zip des fichiers de langue d'un module
*
*/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -36,7 +38,7 @@ function action_tradlang_exporter_zip_dist() {
* On crée les différents fichiers de langue
*/
while ($langue = sql_fetch($langues)) {
$fichier = $tradlang_sauvegarde_module($module,$langue['lang']);
$fichier = $tradlang_sauvegarde_module($module, $langue['lang']);
if (file_exists($fichier)) {
$fichiers[] = $fichier;
}
@ -46,11 +48,11 @@ function action_tradlang_exporter_zip_dist() {
* On crée le zip
*/
if ((is_countable($fichier) ? count($fichier) : 0) > 0) {
$dir_lang = _DIR_VAR.'cache-lang/'.$module.'/';
$dir_lang = _DIR_VAR . 'cache-lang/' . $module . '/';
if (!is_dir(_DIR_VAR . 'cache-lang/')) {
sous_repertoire(_DIR_VAR, 'cache-lang');
}
$zip = $dir_lang.$module.'_langues.zip';
$zip = $dir_lang . $module . '_langues.zip';
include_spip('inc/pclzip');
if (file_exists($zip)) {
@ -62,15 +64,15 @@ function action_tradlang_exporter_zip_dist() {
$erreur = $contenu_zip->add($fichiers, PCLZIP_OPT_REMOVE_ALL_PATH);
if ($erreur == 0) {
spip_log("$chemin".$contenu_zip->errorInfo(true), 'tradlang');
spip_log("$chemin" . $contenu_zip->errorInfo(true), 'tradlang');
}
}
if (file_exists($zip)) {
header('Content-Type: application/zip;');
header('Content-Length: '.filesize($zip));
header('Content-Disposition: attachment; filename="'.basename($zip).'"');
header('Content-Length: ' . filesize($zip));
header('Content-Disposition: attachment; filename="' . basename($zip) . '"');
header('Expires: 0');
header('Cache-Control: no-cache, must-revalidate');
header('Pragma: no-cache');

@ -1,4 +1,5 @@
<?php
/**
*
* Trad-lang v2
@ -8,6 +9,7 @@
* Action permettant de supprimer une langue cible si vide
*
*/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -33,7 +35,7 @@ function action_tradlang_supprimer_langue_cible_dist() {
) {
if (!_request('confirm')) {
$row_module = sql_fetsel('*', 'spip_tradlang_modules', 'id_tradlang_module = ' . (int) $id_tradlang_module);
$titre = $row_module['nom_mod'] .': ' . _T('tradlang:confirm_suppression_langue_cible', ['lang' => $lang_cible]);
$titre = $row_module['nom_mod'] . ': ' . _T('tradlang:confirm_suppression_langue_cible', ['lang' => $lang_cible]);
$btn_label = _T('tradlang:bouton_supprimer_langue_module');
$redirect = _request('redirect');
$url_action = generer_action_auteur('tradlang_supprimer_langue_cible', "$id_tradlang_module/$lang_cible", $redirect);
@ -41,14 +43,13 @@ function action_tradlang_supprimer_langue_cible_dist() {
// Dans tous les cas on finit sur un minipres qui dit si ok ou echec
include_spip('inc/minipres');
echo minipres($titre, "<style>h1{font-weight: normal}#minipres{text-align: center}</style>". bouton_action($btn_label,$url_action), '', true);
echo minipres($titre, '<style>h1{font-weight: normal}#minipres{text-align: center}</style>' . bouton_action($btn_label, $url_action), '', true);
exit;
} else {
/**
* Suppression des versions et urls
*/
$tradlangs = sql_allfetsel('id_tradlang', 'spip_tradlangs', 'id_tradlang_module = ' . (int) $id_tradlang_module.' AND lang='.sql_quote($lang_cible));
$tradlangs = sql_allfetsel('id_tradlang', 'spip_tradlangs', 'id_tradlang_module = ' . (int) $id_tradlang_module . ' AND lang=' . sql_quote($lang_cible));
$tradlangs_supprimer = [];
foreach ($tradlangs as $tradlang) {
$tradlangs_supprimer[] = $tradlang['id_tradlang'];
@ -68,7 +69,7 @@ function action_tradlang_supprimer_langue_cible_dist() {
sql_delete('spip_tradlangs_bilans', 'id_tradlang_module = ' . (int) $id_tradlang_module . ' AND lang = ' . sql_quote($lang_cible));
include_spip('inc/invalideur');
suivre_invalideur('1');
if ($redirect = _request('redirect')){
if ($redirect = _request('redirect')) {
$redirect = parametre_url($redirect, 'lang_cible', '', '&');
$redirect = parametre_url($redirect, 'var_lang_suppr', $lang_cible, '&');
$GLOBALS['redirect'] = $redirect;
@ -77,5 +78,4 @@ function action_tradlang_supprimer_langue_cible_dist() {
} else {
spip_log("action_tradlang_supprimer_langue_cible_dist : Module $id_tradlang_module est traduit en $lang_cible", 'tradlang');
}
}

@ -1,4 +1,5 @@
<?php
/**
* Action permettant de vérifier si une traduction de la base
* contient les mêmes éléments que la langue mère
@ -19,7 +20,7 @@ function action_tradlang_verifier_langue_base_dist() {
$id_tradlang_module = $r[1];
$lang = $r[2];
$tradlang_verifier_langue_base = charger_fonction('tradlang_verifier_langue_base', 'inc');
$tradlang_verifier_langue_base($id_tradlang_module,$lang);
$tradlang_verifier_langue_base($id_tradlang_module, $lang);
}
return;

@ -1,10 +1,10 @@
<?php
/**
* Plugin Tradlang
* Licence GPL (c) 2009-2013
*/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
@ -14,8 +14,8 @@ function tradlang_declarer_tables_interfaces($interface) {
$interface['table_des_tables']['tradlang_modules'] = 'tradlang_modules';
$interface['table_des_tables']['tradlangs_bilans'] = 'tradlangs_bilans';
$interface['tables_jointures']['spip_tradlang_modules'][] = 'grappes_liens';
$interface['table_des_traitements']['PRIORITE'][]= 'typo(supprimer_numero(%s), "TYPO", $connect)';
$interface['table_des_traitements']['NOM_MOD'][]= 'typo(supprimer_numero(%s), "TYPO", $connect)';
$interface['table_des_traitements']['PRIORITE'][] = 'typo(supprimer_numero(%s), "TYPO", $connect)';
$interface['table_des_traitements']['NOM_MOD'][] = 'typo(supprimer_numero(%s), "TYPO", $connect)';
return $interface;
}
@ -28,25 +28,25 @@ function tradlang_declarer_tables_objets_sql($tables) {
'texte_objets' => 'tradlang:titre_tradlang_modules',
'texte_modifier' => 'tradlang:icone_modifier_tradlang_module',
'texte_logo_objet' => 'tradlang:titre_logo_tradlang_module',
'info_aucun_objet'=> 'tradlang:info_aucun_tradlang_module',
'info_aucun_objet' => 'tradlang:info_aucun_tradlang_module',
'info_1_objet' => 'tradlang:info_1_tradlang_module',
'info_nb_objets' => 'tradlang:info_nb_tradlang_module',
'titre' => "nom_mod AS titre, '' AS lang",
'principale' => 'oui',
'field'=> [
"id_tradlang_module" => "bigint(21) NOT NULL AUTO_INCREMENT",
"module" => "varchar(128) NOT NULL",
"nom_mod" => "text DEFAULT '' NOT NULL",
"lang_mere" => "varchar(16) NOT NULL default 'fr'",
"type_export" => "varchar(16) NOT NULL default 'spip'",
"dir_module" => "varchar(255) NOT NULL",
"dir_lang" => "varchar(255) NOT NULL",
"texte" => "longtext DEFAULT '' NOT NULL",
"priorite" => "varchar(128) NOT NULL",
"gestionnaire" => "varchar(32) DEFAULT 'spip' NOT NULL",
"lang_prefix" => "varchar(32) NOT NULL",
"limite_trad" => "tinyint NOT NULL DEFAULT 0",
"bon_a_pousser" => "tinyint NOT NULL DEFAULT 0"
'field' => [
'id_tradlang_module' => 'bigint(21) NOT NULL AUTO_INCREMENT',
'module' => 'varchar(128) NOT NULL',
'nom_mod' => "text DEFAULT '' NOT NULL",
'lang_mere' => "varchar(16) NOT NULL default 'fr'",
'type_export' => "varchar(16) NOT NULL default 'spip'",
'dir_module' => 'varchar(255) NOT NULL',
'dir_lang' => 'varchar(255) NOT NULL',
'texte' => "longtext DEFAULT '' NOT NULL",
'priorite' => 'varchar(128) NOT NULL',
'gestionnaire' => "varchar(32) DEFAULT 'spip' NOT NULL",
'lang_prefix' => 'varchar(32) NOT NULL',
'limite_trad' => 'tinyint NOT NULL DEFAULT 0',
'bon_a_pousser' => 'tinyint NOT NULL DEFAULT 0'
],
'key' => [
'PRIMARY KEY' => 'id_tradlang_module',
@ -67,42 +67,42 @@ function tradlang_declarer_tables_objets_sql($tables) {
];
$tables['spip_tradlangs'] = [
'page'=>'tradlang',
'page' => 'tradlang',
'texte_retour' => 'icone_retour',
'texte_objets' => 'tradlang:titre_tradlang_chaines',
'texte_modifier' => 'tradlang:icone_modifier_tradlang',
'info_aucun_objet'=> 'tradlang:info_aucun_tradlang',
'info_aucun_objet' => 'tradlang:info_aucun_tradlang',
'info_1_objet' => 'tradlang:info_1_tradlang',
'info_nb_objets' => 'tradlang:info_nb_tradlang',
'date' => 'date_modif',
'champs_editables' => ['str','comm','traducteur','statut','md5'],
'principale' => 'oui',
'field'=> [
"id_tradlang" => "bigint(21) NOT NULL AUTO_INCREMENT",
"id_tradlang_module" => "bigint(21) NOT NULL DEFAULT '0'",
"titre" => "text DEFAULT '' NOT NULL",
"id" => "varchar(128) NOT NULL default ''",
"module" => "varchar(32) NOT NULL default 0",
"lang" => "varchar(10) DEFAULT '' NOT NULL",
"langue_choisie" => "VARCHAR(3) DEFAULT 'non'",
"str" => "text NOT NULL",
"comm" => "text NOT NULL",
"statut" => "varchar(16) NOT NULL default 'NEW'",
"traducteur" => "varchar(32) default NULL",
"md5" => "varchar(32) default NULL",
"orig" => "tinyint(4) NOT NULL default '0'",
"date_modif" => "datetime default NULL",
"maj" => "timestamp NOT NULL"
'field' => [
'id_tradlang' => 'bigint(21) NOT NULL AUTO_INCREMENT',
'id_tradlang_module' => "bigint(21) NOT NULL DEFAULT '0'",
'titre' => "text DEFAULT '' NOT NULL",
'id' => "varchar(128) NOT NULL default ''",
'module' => 'varchar(32) NOT NULL default 0',
'lang' => "varchar(10) DEFAULT '' NOT NULL",
'langue_choisie' => "VARCHAR(3) DEFAULT 'non'",
'str' => 'text NOT NULL',
'comm' => 'text NOT NULL',
'statut' => "varchar(16) NOT NULL default 'NEW'",
'traducteur' => 'varchar(32) default NULL',
'md5' => 'varchar(32) default NULL',
'orig' => "tinyint(4) NOT NULL default '0'",
'date_modif' => 'datetime default NULL',
'maj' => 'timestamp NOT NULL'
],
/**
* Laisser le statut ici sinon on n'agit plus sur le pipeline pre_boucle
*/
'statut' => [
[
'champ'=>'statut',
'publie'=>'OK,NEW,MODIF,RELIRE',
'previsu'=>'OK,NEW,MODIF,RELIRE',
'exception'=>'statut'
'champ' => 'statut',
'publie' => 'OK,NEW,MODIF,RELIRE',
'previsu' => 'OK,NEW,MODIF,RELIRE',
'exception' => 'statut'
]
],
'key' => [
@ -118,7 +118,7 @@ function tradlang_declarer_tables_objets_sql($tables) {
],
'join' => [
'id_tradlang' => 'id_tradlang',
'module' =>'module'
'module' => 'module'
],
'statut_images' => [
'OK' => 'tradlang_statut_ok.png',
@ -150,15 +150,15 @@ function tradlang_declarer_tables_objets_sql($tables) {
function tradlang_declarer_tables_auxiliaires($tables_auxiliaires) {
$spip_tradlangs_bilans = [
"id_tradlang_module" => "bigint(21) NOT NULL",
"module" => "varchar(128) NOT NULL",
"lang" => "varchar(10) DEFAULT '' NOT NULL",
"chaines_total" => "smallint(5) DEFAULT '0' NOT NULL",
"chaines_ok" => "smallint(5) DEFAULT '0' NOT NULL",
"chaines_relire" => "smallint(5) DEFAULT '0' NOT NULL",
"chaines_modif" => "smallint(5) DEFAULT '0' NOT NULL",
"chaines_new" => "smallint(5) DEFAULT '0' NOT NULL",
"maj" => "timestamp NOT NULL"
'id_tradlang_module' => 'bigint(21) NOT NULL',
'module' => 'varchar(128) NOT NULL',
'lang' => "varchar(10) DEFAULT '' NOT NULL",
'chaines_total' => "smallint(5) DEFAULT '0' NOT NULL",
'chaines_ok' => "smallint(5) DEFAULT '0' NOT NULL",
'chaines_relire' => "smallint(5) DEFAULT '0' NOT NULL",
'chaines_modif' => "smallint(5) DEFAULT '0' NOT NULL",
'chaines_new' => "smallint(5) DEFAULT '0' NOT NULL",
'maj' => 'timestamp NOT NULL'
];
$spip_tradlangs_bilans_keys = [

@ -1,4 +1,5 @@
<?php
/**
*
* Trad-lang v2
@ -25,7 +26,7 @@ if (!defined('_ECRIRE_INC_VERSION')) {
* Le fichier final
*/
function export_lang_csv_dist($module, $langue, $dir_lang) {
$chaines_csv=$tous=[];
$chaines_csv = $tous = [];
/**
* Le fichier final
@ -55,11 +56,11 @@ function export_lang_csv_dist($module, $langue, $dir_lang) {
$newmd5 = md5($str);
if ($oldmd5 !== $newmd5) {
sql_updateq('spip_tradlangs', ['md5'=>$newmd5], 'md5 = '.sql_quote($oldmd5) . ' AND id_tradlang_module = ' . (int) $info_module['id_tradlang_module']);
sql_updateq('spip_tradlangs', ['md5' => $newmd5], 'md5 = ' . sql_quote($oldmd5) . ' AND id_tradlang_module = ' . (int) $info_module['id_tradlang_module']);
}
$str_original = sql_getfetsel('str', 'spip_tradlangs', 'id = '.sql_quote($id).' AND id_tradlang_module = ' . (int) $info_module['id_tradlang_module'].' AND lang = ' . sql_quote($info_module['lang_mere']));
$str_original = sql_getfetsel('str', 'spip_tradlangs', 'id = ' . sql_quote($id) . ' AND id_tradlang_module = ' . (int) $info_module['id_tradlang_module'] . ' AND lang = ' . sql_quote($info_module['lang_mere']));
$chaine = ['id' => $row['id'], 'str_orig'=>$str_original, 'str'=>$str, 'statut'=>$row['statut'], 'comm'=>$row['comm']];
$chaine = ['id' => $row['id'], 'str_orig' => $str_original, 'str' => $str, 'statut' => $row['statut'], 'comm' => $row['comm']];
$chaines_csv[] = $chaine;
unset($tous[$id]);
}

@ -1,4 +1,5 @@
<?php
/**
*
* Trad-lang v2
@ -30,7 +31,7 @@ if (!defined('_ECRIRE_INC_VERSION')) {
function export_lang_po_dist($module, $langue, $dir_lang) {
$traducteurs = [];
$lang = null;
$x=$tous=[];
$x = $tous = [];
$contenu = '';
/**
@ -54,7 +55,7 @@ function export_lang_po_dist($module, $langue, $dir_lang) {
*/
$last_auteur = [];
if ($langue != $info_module['lang_mere']) {
$traducteur = sql_fetsel('id_tradlang,traducteur', 'spip_tradlangs', 'id_tradlang_module = ' . (int) $info_module['id_tradlang_module'] . ' AND lang = '.sql_quote($langue), '', 'maj DESC', '0,1');
$traducteur = sql_fetsel('id_tradlang,traducteur', 'spip_tradlangs', 'id_tradlang_module = ' . (int) $info_module['id_tradlang_module'] . ' AND lang = ' . sql_quote($langue), '', 'maj DESC', '0,1');
if (is_numeric($traducteur['traducteur'])) {
$id_auteur = $traducteur['traducteur'];
} else {
@ -65,12 +66,12 @@ function export_lang_po_dist($module, $langue, $dir_lang) {
$traducteurs[$lang] = [];
$people_unique = [];
$liste_traducteurs = sql_select('DISTINCT(traducteur)', 'spip_tradlangs', 'id_tradlang_module = '.(int) $info_module['id_tradlang_module'] . ' AND lang = ' . sql_quote($langue));
$liste_traducteurs = sql_select('DISTINCT(traducteur)', 'spip_tradlangs', 'id_tradlang_module = ' . (int) $info_module['id_tradlang_module'] . ' AND lang = ' . sql_quote($langue));
while ($t = sql_fetch($liste_traducteurs)) {
$traducteurs_lang = explode(',', $t['traducteur']);
foreach ($traducteurs_lang as $traducteur) {
if (!in_array($traducteur, $people_unique)) {
if (is_numeric($traducteur) && ($id_auteur=(int) $traducteur)) {
if (is_numeric($traducteur) && ($id_auteur = (int) $traducteur)) {
$traducteur_supp['nom'] = extraire_multi(sql_getfetsel('nom', 'spip_auteurs', 'id_auteur = ' . $id_auteur));
$traducteur_supp['lien'] = url_absolue(generer_url_entite($id_auteur, 'auteur'), $url_site);
} elseif (trim(strlen($traducteur)) > 0) {
@ -99,25 +100,25 @@ function export_lang_po_dist($module, $langue, $dir_lang) {
* Création de l'entête du fichier généré
*/
$contenu .= '# This is a SPIP language file -- Ceci est un fichier langue de SPIP
# extrait automatiquement de '.$url_trad.'
# extrait automatiquement de ' . $url_trad . '
'
. ($trad_texte ?? '')
. 'msgid ""
msgstr ""
"Project-Id-Version: '.$info_module['nom_mod'].'\n"
"Project-Id-Version: ' . $info_module['nom_mod'] . '\n"
'
. (defined('_DIR_PLUGIN_TICKETS') ? '"Report-Msgid-Bugs-To: '.url_absolue(generer_url_public('tickets')).'\n"
':'')
. (defined('_DIR_PLUGIN_TICKETS') ? '"Report-Msgid-Bugs-To: ' . url_absolue(generer_url_public('tickets')) . '\n"
' : '')
. '"MIME-Version: 1.0\n"
"Content-Type: text/plain; charset=UTF-8\n"
"Content-Transfer-Encoding: 8bit\n"
"X-Generator: SPIP Trad Lang 2.0.5\n"
"X-Poedit-SourceCharset: utf-8\n"
"Language: '.$langue.'\n"
"Language: ' . $langue . '\n"
'
. (isset($last_auteur['nom'])?'"Last-Translator: '.extraire_multi($last_auteur['nom']).' <'.$last_auteur['email'].'>\n"
. (isset($last_auteur['nom']) ? '"Last-Translator: ' . extraire_multi($last_auteur['nom']) . ' <' . $last_auteur['email'] . '>\n"
' : '')
.'"Language-Team: SPIP-trad <spip-trad@rezo.net>\n"
. '"Language-Team: SPIP-trad <spip-trad@rezo.net>\n"
';
/**
@ -130,8 +131,8 @@ msgstr ""
* msgid "Item dans la langue originale"
* msgstr "Item dans la langue actuelle (traduit), si non traduit, vide"
*/
$res=sql_allfetsel("*","spip_tradlangs","id_tradlang_module=".(int) $info_module['id_tradlang_module']." AND lang=".sql_quote($langue)." AND statut != 'attic'","id");
foreach($res as $row){
$res = sql_allfetsel('*', 'spip_tradlangs', 'id_tradlang_module=' . (int) $info_module['id_tradlang_module'] . ' AND lang=' . sql_quote($langue) . " AND statut != 'attic'", 'id');
foreach ($res as $row) {
$tous[$row['id']] = $row;
}
ksort($tous);
@ -151,15 +152,15 @@ msgstr ""
$newmd5 = md5($str);
if ($oldmd5 !== $newmd5) {
sql_updateq('spip_tradlangs', ['md5' => $newmd5], 'md5 = '.sql_quote($oldmd5) . ' AND id_tradlang_module = ' . (int) $info_module['id_tradlang_module']);
sql_updateq('spip_tradlangs', ['md5' => $newmd5], 'md5 = ' . sql_quote($oldmd5) . ' AND id_tradlang_module = ' . (int) $info_module['id_tradlang_module']);
}
$str_original = sql_getfetsel('str', 'spip_tradlangs', 'id =' . sql_quote($id) . ' AND id_tradlang_module=' . (int) $info_module['id_tradlang_module'] . ' AND lang=' . sql_quote($info_module['lang_mere']));
$x[] = ($row['comm'] ? '#' . $row['comm']."\n" : '').
$x[] = ($row['comm'] ? '#' . $row['comm'] . "\n" : '') .
'
#, '.(($row['statut'] == 'MODIF') ? 'fuzzy, php-format' : 'php-format')."
#| msgid \"".$row['id']."\"
msgid \"".str_replace('"', '\"', $str_original)."\"
msgstr \"".(($row['statut'] == 'NEW') ? '' : str_replace('"', '\"', $str))."\"";
#, ' . (($row['statut'] == 'MODIF') ? 'fuzzy, php-format' : 'php-format') . '
#| msgid "' . $row['id'] . '"
msgid "' . str_replace('"', '\"', $str_original) . '"
msgstr "' . (($row['statut'] == 'NEW') ? '' : str_replace('"', '\"', $str)) . '"';
unset($tous[$id]);
}

@ -1,4 +1,5 @@
<?php
/**
*
* Trad-lang v2
@ -39,8 +40,8 @@ function export_lang_spip_dist($module, $langue, $dir_lang, $tout = false) {
if (!$tout) {
$where .= " AND statut IN ('OK','MODIF','RELIRE')";
}
$res=sql_allfetsel('id,str,comm,statut', 'spip_tradlangs', $where, 'id');
$x=[];
$res = sql_allfetsel('id,str,comm,statut', 'spip_tradlangs', $where, 'id');
$x = [];
$prev = '';
/**
* on part de l'origine comme ca on a tout
@ -53,11 +54,11 @@ function export_lang_spip_dist($module, $langue, $dir_lang, $tout = false) {
ksort($tous);
foreach ($tous as $row) {
if ($prev !== strtoupper($row['id'][0])) {
$x[] = "\n$tab// ".strtoupper($row['id'][0]);
$x[] = "\n$tab// " . strtoupper($row['id'][0]);
}
$prev = strtoupper($row['id'][0]);
if (strlen($row['statut']) && $row['statut'] != 'OK') {
$row['comm'] .= ' '.$row['statut'];
$row['comm'] .= ' ' . $row['statut'];
}
if (trim($row['comm'])) {
/**
@ -72,10 +73,10 @@ function export_lang_spip_dist($module, $langue, $dir_lang, $tout = false) {
$str = unicode_to_utf_8(html_entity_decode(preg_replace('/&([lg]t;)/S', '&amp;\1', $str), ENT_NOQUOTES, 'utf-8'));
$newmd5 = md5($str);
if ($oldmd5 !== $newmd5) {
sql_updateq('spip_tradlangs', ['md5'=>$newmd5], 'md5 = ' . sql_quote($oldmd5) . ' AND module = '.sql_quote($module));
sql_updateq('spip_tradlangs', ['md5' => $newmd5], 'md5 = ' . sql_quote($oldmd5) . ' AND module = ' . sql_quote($module));
}
$x[] = "$tab".var_export($row['id'], 1) . ' => ' . var_export($str, 1) . ',' . $row['comm'] ;
$x[] = "$tab" . var_export($row['id'], 1) . ' => ' . var_export($str, 1) . ',' . $row['comm'] ;
}
/**
@ -92,7 +93,7 @@ function export_lang_spip_dist($module, $langue, $dir_lang, $tout = false) {
/**
* On supprime la virgule du dernier item
*/
$x[count($x)-1] = preg_replace('/,([^,]*)$/', '\1', $x[count($x)-1]);
$x[count($x) - 1] = preg_replace('/,([^,]*)$/', '\1', $x[count($x) - 1]);
$contenu = implode("\n", $x);
@ -101,18 +102,18 @@ function export_lang_spip_dist($module, $langue, $dir_lang, $tout = false) {
*/
fwrite(
$fd,
'<'.'?php
'<' . '?php
// This is a SPIP language file -- Ceci est un fichier langue de SPIP
// extrait automatiquement de '.$url_trad.'
// extrait automatiquement de ' . $url_trad . '
// ** ne pas modifier le fichier **
'
."\n".$secure.'$GLOBALS[$GLOBALS[\'idx_lang\']] = array(
. "\n" . $secure . '$GLOBALS[$GLOBALS[\'idx_lang\']] = array(
'
. str_replace("\r\n", "\n", $contenu)
.'
. '
);
?'.'>'
?' . '>'
);
fclose($fd);

@ -18,7 +18,7 @@ function formulaires_configurer_tradlang_charger_dist() {
function formulaires_configurer_tradlang_verifier_dist() {
$erreurs = [];
if (($langues_autorisees = _request('langues_autorisees')) && (is_countable($langues_autorisees) ? count($langues_autorisees) : 0)<2) {
if (($langues_autorisees = _request('langues_autorisees')) && (is_countable($langues_autorisees) ? count($langues_autorisees) : 0) < 2) {
$erreurs['langues_autorisees'] = _T('tradlang:erreur_langues_autorisees_insuffisantes');
}
$limite_trad = _request('seuil_export_tradlang');
@ -30,24 +30,26 @@ function formulaires_configurer_tradlang_verifier_dist() {
function formulaires_configurer_tradlang_traiter_dist() {
$config = [];
$res = ['editable'=>true];
foreach ([
'sauvegarde_locale',
'sauvegarde_post_edition',
'seuil_export_tradlang',
'langues_autorisees',
'limiter_langues_bilan',
'limiter_langues_bilan_nb',
'configurer_type',
'configurer_statuts',
'configurer_auteurs',
'modifier_type',
'modifier_statuts',
'modifier_auteurs',
'voir_type',
'voir_statuts',
'voir_auteurs'
] as $m) {
$res = ['editable' => true];
foreach (
[
'sauvegarde_locale',
'sauvegarde_post_edition',
'seuil_export_tradlang',
'langues_autorisees',
'limiter_langues_bilan',
'limiter_langues_bilan_nb',
'configurer_type',
'configurer_statuts',
'configurer_auteurs',
'modifier_type',
'modifier_statuts',
'modifier_auteurs',
'voir_type',
'voir_statuts',
'voir_auteurs'
] as $m
) {
if (!is_null($v = _request($m))) {
$config[$m] = _request($m);
}
@ -66,12 +68,12 @@ function formulaires_configurer_tradlang_traiter_dist() {
function tradlang_test_repertoire_local() {
global $dossier_squelettes;
if (!$dossier_squelettes && !is_dir(_DIR_RACINE.'squelettes')) {
if (!$dossier_squelettes && !is_dir(_DIR_RACINE . 'squelettes')) {
return false;
} else {
$squelettes = $dossier_squelettes ?: _DIR_RACINE.'squelettes/';
$squelettes = $dossier_squelettes ?: _DIR_RACINE . 'squelettes/';
}
if (!is_dir($dir_lang = $squelettes.'lang')) {
if (!is_dir($dir_lang = $squelettes . 'lang')) {
return false;
}

@ -28,7 +28,7 @@ function formulaires_editer_tradlang_verifier($id_tradlang = 'aucun', $retour =
* On vérifie ici que les variables @...@ des chaines de langue ne sont pas modifiées
*/
$tradlang = sql_fetsel('chaine.id_tradlang_module,chaine.id,module.lang_mere', 'spip_tradlangs AS chaine LEFT JOIN spip_tradlang_modules AS module ON chaine.id_tradlang_module = module.id_tradlang_module', 'id_tradlang = ' . (int) $id_tradlang);
$tradlang_mere = sql_getfetsel('str', 'spip_tradlangs', 'id_tradlang_module = ' . (int) $tradlang['id_tradlang_module'].' AND lang = ' . sql_quote($tradlang['lang_mere']) . ' AND id = ' . sql_quote($tradlang['id']));
$tradlang_mere = sql_getfetsel('str', 'spip_tradlangs', 'id_tradlang_module = ' . (int) $tradlang['id_tradlang_module'] . ' AND lang = ' . sql_quote($tradlang['lang_mere']) . ' AND id = ' . sql_quote($tradlang['id']));
if (preg_match_all(',@[^@]+@,i', $tradlang_mere, $variables)) {
foreach ($variables[0] as $variable) {
if (!preg_match("/$variable/", _request('str'))) {
@ -36,7 +36,7 @@ function formulaires_editer_tradlang_verifier($id_tradlang = 'aucun', $retour =
}
if (is_array($variables_trouvees)) {
$erreurs['str'] = singulier_ou_pluriel(count($variables_trouvees), 'tradlang:erreur_variable_manquante', 'tradlang:erreur_variable_manquantes');
$erreurs['str'] .= '<br />'.implode(' - ', $variables_trouvees);
$erreurs['str'] .= '<br />' . implode(' - ', $variables_trouvees);
}
}
}
@ -51,19 +51,19 @@ function formulaires_editer_tradlang_traiter($id_tradlang = 'aucun', $retour = '
$lang_orig = $lang_orig ?: $module['lang_mere'];
$url_module = parametre_url(parametre_url(generer_url_entite($tradlang['id_tradlang_module'], 'tradlang_module'), 'lang_orig', $lang_orig), 'lang_cible', $tradlang['lang']);
$res['redirect'] = '';
if ($id_tradlang_suivant = sql_getfetsel('id_tradlang', 'spip_tradlangs', 'id_tradlang_module = ' . (int) $tradlang['id_tradlang_module'] . ' AND lang = ' . sql_quote($tradlang['lang']).' AND statut != "OK" AND id_tradlang > ' . (int) $id_tradlang)) {
if ($id_tradlang_suivant = sql_getfetsel('id_tradlang', 'spip_tradlangs', 'id_tradlang_module = ' . (int) $tradlang['id_tradlang_module'] . ' AND lang = ' . sql_quote($tradlang['lang']) . ' AND statut != "OK" AND id_tradlang > ' . (int) $id_tradlang)) {
$url_suivant = parametre_url(parametre_url(generer_url_entite($id_tradlang_suivant, 'tradlang'), 'lang_orig', $lang_orig), 'lang_cible', $tradlang['lang']);
} elseif ($id_tradlang_suivant = sql_getfetsel('id_tradlang', 'spip_tradlangs', 'id_tradlang_module = ' . (int) $tradlang['id_tradlang_module'] . ' AND statut != "OK" AND lang = ' . sql_quote($tradlang['lang']))) {
$url_suivant = parametre_url(parametre_url(generer_url_entite($id_tradlang_suivant, 'tradlang'), 'lang_orig', $lang_orig), 'lang_cible', $tradlang['lang']);
}
$res['message_ok'] .= '<br />';
if (isset($url_suivant)) {
$res['message_ok'] .= '<a href="'.$url_suivant.'"">'._T('tradlang:lien_traduire_suivant_str_module', ['module' => $module['nom_mod']]).'</a>';
$res['message_ok'] .= '<a href="' . $url_suivant . '"">' . _T('tradlang:lien_traduire_suivant_str_module', ['module' => $module['nom_mod']]) . '</a>';
} else {
$res['message_ok'] .= _T('tradlang:info_module_traduit_pc', ['pc'=>'100']);
$res['message_ok'] .= _T('tradlang:info_module_traduit_pc', ['pc' => '100']);
}
$res['message_ok'] .= '<br />';
$res['message_ok'] .= '<a href="'.$url_module.'"">'._T('tradlang:lien_retour_module', ['module' => $module['nom_mod']]).'</a>';
$res['message_ok'] .= '<a href="' . $url_module . '"">' . _T('tradlang:lien_retour_module', ['module' => $module['nom_mod']]) . '</a>';
$res['editable'] = true;
}
return $res;

@ -48,7 +48,7 @@ function formulaires_editer_tradlang_module_verifier($id_tradlang_module, $retou
if ($nouvelle_langue) {
if (in_array($nouvelle_langue, $lgs)) {
$erreur['codelangue'] = _T('tradlang:erreur_code_langue_existant');
} else if (!array_key_exists($nouvelle_langue, $GLOBALS['codes_langues'])) {
} elseif (!array_key_exists($nouvelle_langue, $GLOBALS['codes_langues'])) {
$erreur['codelangue'] = _T('tradlang:erreur_code_langue_invalide');
}
}
@ -92,7 +92,7 @@ function formulaires_editer_tradlang_module_traiter($id_tradlang_module, $retour
if ($langue) {
$sauvegarde = charger_fonction('tradlang_ajouter_code_langue', 'inc');
$sauvegarde($modok, $langue);
$ret['message_ok'] .= '<br />'._T('tradlang:message_module_langue_ajoutee', ['module' => $module, 'langue' => $langue]);
$ret['message_ok'] .= '<br />' . _T('tradlang:message_module_langue_ajoutee', ['module' => $module, 'langue' => $langue]);
}
$ret['editable'] = true;
$ret['redirect'] = $retour;

@ -1,4 +1,5 @@
<?php
/**
* Trad-lang v2
* Plugin SPIP de traduction de fichiers de langue
@ -174,13 +175,13 @@ function formulaires_tradlang_choisir_module_traiter($id_tradlang_module = '', $
if ($traduire = _request('traduire')) {
$res['message_ok'] = _T('tradlang:message_passage_trad');
if ($lang_crea && (include_spip('inc/autoriser') && autoriser('modifier', 'tradlang'))) {
// Import de la langue mere
$infos_module = sql_fetsel('*', 'spip_tradlang_modules', 'id_tradlang_module = ' . (int) $id_tradlang_module);
$ajouter_code_langue = charger_fonction('tradlang_ajouter_code_langue', 'inc');
$ajouter_code_langue($infos_module,$lang_crea);
$lang_cible = $lang_crea;
$res['message_ok'] = _T('tradlang:message_passage_trad_creation_lang', ['lang' => $lang_crea]);
}
// Import de la langue mere
$infos_module = sql_fetsel('*', 'spip_tradlang_modules', 'id_tradlang_module = ' . (int) $id_tradlang_module);
$ajouter_code_langue = charger_fonction('tradlang_ajouter_code_langue', 'inc');
$ajouter_code_langue($infos_module, $lang_crea);
$lang_cible = $lang_crea;
$res['message_ok'] = _T('tradlang:message_passage_trad_creation_lang', ['lang' => $lang_crea]);
}
$res['redirect'] = parametre_url(parametre_url(parametre_url(generer_url_entite($id_tradlang_module, 'tradlang_module'), 'lang_orig', $lang_orig), 'lang_cible', $lang_cible), 'lang_crea', $lang_crea);
} else {
$res['editable'] = true;

@ -14,29 +14,29 @@ function formulaires_tradlang_importer_langue_charger_dist($id_tradlang_module,
$valeurs['lang_orig'] = $lang_orig;
$valeurs['lang_cible'] = $lang;
if (!$nom_mod = sql_getfetsel('nom_mod', 'spip_tradlang_modules', 'id_tradlang_module = ' . (int) $id_tradlang_module)) {
$valeurs['message_erreur'] = _T('tradlang:erreur_import_module_inexistant', ['id'=>$id_tradlang_module]);
$valeurs['message_erreur'] = _T('tradlang:erreur_import_module_inexistant', ['id' => $id_tradlang_module]);
$valeurs['editable'] = false;
} else {
if (_request('_etape') == '2') {
$module = sql_getfetsel('module', 'spip_tradlang_modules', 'id_tradlang_module = ' . (int) $id_tradlang_module);
$fichier_module = $module.'_'.$lang.'.php';
$fichier_module_po = $module.'_'.$lang.'.po';
$fichier_module = $module . '_' . $lang . '.php';
$fichier_module_po = $module . '_' . $lang . '.po';
$dir_lang = sous_repertoire(_DIR_VAR, 'cache-tradlang');
$dest = $dir_lang.$fichier_module;
$dest_po = $dir_lang.$fichier_module_po;
$dest = $dir_lang . $fichier_module;
$dest_po = $dir_lang . $fichier_module_po;
if (file_exists($dest) || file_exists($dest_po)) {
if (file_exists($dest)) {
$modifs = $undefined = [];
$memtrad = $GLOBALS['idx_lang'] = 'i18n_'.crc32($module).'_tmp';
$memtrad = $GLOBALS['idx_lang'] = 'i18n_' . crc32($module) . '_tmp';
include $dest;
/**
* Recuperation des statuts dans le fichier
*/
$contenu=file_get_contents($dest);
$contenu = file_get_contents($dest);
$contenu = str_replace("\t", '', $contenu);
$tab=preg_split("/\r\n|\n\r|;\n|\n\/\/|\(\n|\n\);\n|\'\,\n|\n[\s\t]*(\')|\/\/[\s\t][0-9A-Z]\n[\s\t](\')/", $contenu, '-1', PREG_SPLIT_NO_EMPTY);
$liste_trad=[];
$tab = preg_split("/\r\n|\n\r|;\n|\n\/\/|\(\n|\n\);\n|\'\,\n|\n[\s\t]*(\')|\/\/[\s\t][0-9A-Z]\n[\s\t](\')/", $contenu, '-1', PREG_SPLIT_NO_EMPTY);
$liste_trad = [];
reset($tab);
foreach ($tab as $ligne) {
@ -45,7 +45,7 @@ function formulaires_tradlang_importer_langue_charger_dist($id_tradlang_module,
if (isset($matches[1]) && isset($matches[3]) && strlen(trim($matches[3])) > 0) {
[, $comm] = explode('#', $matches[3]);
if (in_array(trim($comm), ['NEW', 'MODIF', 'RELIRE'])) {
$liste_trad[$matches[1]]=trim($comm);
$liste_trad[$matches[1]] = trim($comm);
}
}
}
@ -58,7 +58,7 @@ function formulaires_tradlang_importer_langue_charger_dist($id_tradlang_module,
if (!is_array($str_lang)) {
$erreurs['fichier_langue'] = _T('tradlang:erreur_upload_fichier_php_array', ['fichier' => $file['name']]);
} else {
$langues_base = sql_allfetsel('id,str,statut', 'spip_tradlangs', 'id_tradlang_module='.(int) $id_tradlang_module.' AND lang='.sql_quote($lang));
$langues_base = sql_allfetsel('id,str,statut', 'spip_tradlangs', 'id_tradlang_module=' . (int) $id_tradlang_module . ' AND lang=' . sql_quote($lang));
foreach ($langues_base as $strings_id => $strings) {
$str_lang[$strings['id']] = preg_replace(',^(<(MODIF|NEW|RELIRE|PLUS_UTILISE)>)+,US', '', $str_lang[$strings['id']]);
if (strlen($str_lang[$strings['id']]) > 0 && $strings['str'] != $str_lang[$strings['id']]) {
@ -66,9 +66,9 @@ function formulaires_tradlang_importer_langue_charger_dist($id_tradlang_module,
} elseif (strlen($str_lang[$strings['id']]) == 0) {
$undefined[] = $strings['id'];
} elseif (in_array($strings['id'], $keys_liste_trad) && $strings['statut'] != $liste_trad[$strings['id']]) {
$modifs[$strings['id']] = ['orig'=>$strings['str'], 'new'=>$str_lang[$strings['id']], 'statut' => $liste_trad[$strings['id']]];
$modifs[$strings['id']] = ['orig' => $strings['str'], 'new' => $str_lang[$strings['id']], 'statut' => $liste_trad[$strings['id']]];
} elseif (!in_array($strings['id'], $keys_liste_trad) && $strings['statut'] != 'OK') {
$modifs[$strings['id']] = ['orig'=>$strings['str'], 'new'=>$str_lang[$strings['id']], 'statut' => 'OK'];
$modifs[$strings['id']] = ['orig' => $strings['str'], 'new' => $str_lang[$strings['id']], 'statut' => 'OK'];
}
unset($langues_base[$strings_id]);
}
@ -94,15 +94,15 @@ function formulaires_tradlang_importer_langue_charger_dist($id_tradlang_module,
$statut = 'MODIF';
}
if ($str != '') {
$array_po[$matches[1]] = ['str'=>$str, 'statut'=>$statut];
$array_po[$matches[1]] = ['str' => $str, 'statut' => $statut];
}
}
$modifs = [];
$langues_base = sql_allfetsel('id,str,statut', 'spip_tradlangs', 'module = ' . sql_quote($module).' AND lang = ' . sql_quote($lang));
$langues_base = sql_allfetsel('id,str,statut', 'spip_tradlangs', 'module = ' . sql_quote($module) . ' AND lang = ' . sql_quote($lang));
foreach ($langues_base as $strings_id => $strings) {
$str_lang[$strings['id']] = tradlang_utf8(preg_replace(',^(<(MODIF|NEW|PLUS_UTILISE)>)+,US', '', $str_lang[$strings['id']]));
if (isset($array_po[$strings['id']]['str']) && strlen(trim($array_po[$strings['id']]['str'])) > 0 && ($strings['str'] != $array_po[$strings['id']]['str'] || $strings['statut'] != $array_po[$strings['id']]['statut'])) {
$modifs[$strings['id']] = ['orig'=>$strings['str'], 'new'=>$array_po[$strings['id']]['str'], 'statut'=>$array_po[$strings['id']]['statut']];
$modifs[$strings['id']] = ['orig' => $strings['str'], 'new' => $array_po[$strings['id']]['str'], 'statut' => $array_po[$strings['id']]['statut']];
}
unset($langues_base[$strings_id]);
}
@ -123,10 +123,10 @@ function formulaires_tradlang_importer_langue_verifier_1_dist($id_tradlang_modul
$fichiers_module = [];
$modifs = [];
$erreurs = [];
if (_request('_etape')==1) {
if (_request('_etape') == 1) {
$module = sql_getfetsel('module', 'spip_tradlang_modules', 'id_tradlang_module = ' . (int) $id_tradlang_module);
$fichier_php = $module.'_'.$lang.'.php';
$fichier_po = $module.'_'.$lang.'.po';
$fichier_php = $module . '_' . $lang . '.php';
$fichier_po = $module . '_' . $lang . '.po';
$fichiers_module[] = $fichier_php;
$fichiers_module[] = $fichier_po;
$post = $_FILES ?? $GLOBALS['HTTP_POST_FILES'];
@ -136,13 +136,13 @@ function formulaires_tradlang_importer_langue_verifier_1_dist($id_tradlang_modul
foreach ($post as $file) {
if ($file['error'] != 4) {
if (!in_array($file['name'], $fichiers_module)) {
$fichier_module = $fichier_php.', '.$fichier_po;
$fichier_module = $fichier_php . ', ' . $fichier_po;
$erreurs['fichier_langue'] = _T('tradlang:erreur_upload_fichier_php', ['fichier' => $file['name'], 'fichier_attendu' => $fichier_module]);
}
if (!$erreurs['fichier_langue']) {
$dir_lang = sous_repertoire(_DIR_VAR, 'cache-tradlang');
$dest = $dir_lang.$file['name'];
$dest = $dir_lang . $file['name'];
@move_uploaded_file($file['tmp_name'], $dest);
if (!file_exists($dest)) {
$erreurs['message_erreur'] = 'Fichier temporaire non créé';
@ -151,16 +151,16 @@ function formulaires_tradlang_importer_langue_verifier_1_dist($id_tradlang_modul
* Gestion du cas des fichiers php
*/
if ($file['name'] == $fichier_php) {
$memtrad = $GLOBALS['idx_lang'] = 'i18n_'.crc32($module).'_tmp';
$memtrad = $GLOBALS['idx_lang'] = 'i18n_' . crc32($module) . '_tmp';
include $dest;
/**
* Recuperation des statuts dans le fichier
*/
$contenu=file_get_contents($dest);
$contenu = file_get_contents($dest);
$contenu = str_replace("\t", '', $contenu);
$tab=preg_split("/\r\n|\n\r|;\n|\n\/\/|\(\n|\n\);\n|\'\,\n|\n[\s\t]*(\')|\/\/[\s\t][0-9A-Z]\n[\s\t](\')/", $contenu, '-1', PREG_SPLIT_NO_EMPTY);
$liste_trad=[];
$tab = preg_split("/\r\n|\n\r|;\n|\n\/\/|\(\n|\n\);\n|\'\,\n|\n[\s\t]*(\')|\/\/[\s\t][0-9A-Z]\n[\s\t](\')/", $contenu, '-1', PREG_SPLIT_NO_EMPTY);
$liste_trad = [];
reset($tab);
foreach ($tab as $ligne) {
@ -169,7 +169,7 @@ function formulaires_tradlang_importer_langue_verifier_1_dist($id_tradlang_modul
if (isset($matches[1]) && isset($matches[3]) && strlen(trim($matches[3])) > 0) {
[, $comm] = explode('#', $matches[3]);
if (in_array(trim($comm), ['NEW', 'MODIF', 'RELIRE'])) {
$liste_trad[$matches[1]]=trim($comm);
$liste_trad[$matches[1]] = trim($comm);
}
}
}
@ -187,11 +187,11 @@ function formulaires_tradlang_importer_langue_verifier_1_dist($id_tradlang_modul
foreach ($langues_base as $strings_id => $strings) {
$str_lang[$strings['id']] = tradlang_utf8(preg_replace(',^(<(MODIF|NEW|PLUS_UTILISE)>)+,US', '', $str_lang[$strings['id']]));
if ($strings['str'] != $str_lang[$strings['id']]) {
$modifs[$strings['id']] = ['orig'=>$strings['str'], 'new'=>$str_lang[$strings['id']]];
$modifs[$strings['id']] = ['orig' => $strings['str'], 'new' => $str_lang[$strings['id']]];
break;
}
if (in_array($strings['id'], $keys_liste_trad) && $strings['statut'] != $liste_trad[$strings['id']]) {
$modifs[$strings['id']] = ['orig'=>$strings['str'], 'new'=>$str_lang[$strings['id']]];
$modifs[$strings['id']] = ['orig' => $strings['str'], 'new' => $str_lang[$strings['id']]];
break;
}
}
@ -213,7 +213,7 @@ function formulaires_tradlang_importer_langue_verifier_1_dist($id_tradlang_modul
preg_match(',\nmsgid \"(.*)\nmsgstr,Uims', $match, $matches_str_orig);
$str_orig = rtrim(trim($matches_str_orig[1]), '"');
$str_orig = trim(str_replace("\"\n\"", '', $str_orig));
$matches[1] = sql_getfetsel('id', 'spip_tradlangs', 'id_tradlang_module = ' . (int) $id_tradlang_module . ' AND str = '.sql_quote($str_orig));
$matches[1] = sql_getfetsel('id', 'spip_tradlangs', 'id_tradlang_module = ' . (int) $id_tradlang_module . ' AND str = ' . sql_quote($str_orig));
}
if (preg_match(',\#\, fuzzy\, php-format,', $match, $matches_statut)) {
$statut = 'MODIF';
@ -231,7 +231,7 @@ function formulaires_tradlang_importer_langue_verifier_1_dist($id_tradlang_modul
&& strlen(trim($array_po[$strings['id']]['str'])) > 0
&& ($strings['str'] != $array_po[$strings['id']]['str'] || $strings['statut'] != $array_po[$strings['id']]['statut'])
) {
$modifs[$strings['id']] = ['orig'=>$strings['str'], 'new'=>$array_po[$strings['id']]['str'], 'statut'=>$array_po[$strings['id']]['statut']];
$modifs[$strings['id']] = ['orig' => $strings['str'], 'new' => $array_po[$strings['id']]['str'], 'statut' => $array_po[$strings['id']]['statut']];
break;
}
}
@ -253,14 +253,14 @@ function formulaires_tradlang_importer_langue_verifier_1_dist($id_tradlang_modul
function formulaires_tradlang_importer_langue_verifier_2_dist($id_tradlang_module, $lang) {
$module = sql_getfetsel('module', 'spip_tradlang_modules', 'id_tradlang_module = ' . (int) $id_tradlang_module);
$fichier_php = $module.'_'.$lang.'.php';
$fichier_po = $module.'_'.$lang.'.po';
$fichier_php = $module . '_' . $lang . '.php';
$fichier_po = $module . '_' . $lang . '.po';
$dir_lang = sous_repertoire(_DIR_VAR, 'cache-tradlang');
$dest = $dir_lang.$fichier_php;
$destpo = $dir_lang.$fichier_po;
$dest = $dir_lang . $fichier_php;
$destpo = $dir_lang . $fichier_po;
$modifs = $erreurs = [];
if (file_exists($dest)) {
$memtrad = $GLOBALS['idx_lang'] = 'i18n_'.crc32($module).'_tmp';
$memtrad = $GLOBALS['idx_lang'] = 'i18n_' . crc32($module) . '_tmp';
include $dest;
$str_lang = $GLOBALS[$memtrad]; // on a vu certains fichiers faire des betises et modifier idx_lang
@ -296,30 +296,30 @@ function formulaires_tradlang_importer_langue_traiter_dist($id_tradlang_module,
include_spip('action/editer_tradlang');
$module = sql_getfetsel('module', 'spip_tradlang_modules', 'id_tradlang_module = ' . (int) $id_tradlang_module);
$fichier_php = $module.'_'.$lang.'.php';
$fichier_po = $module.'_'.$lang.'.po';
$fichier_php = $module . '_' . $lang . '.php';
$fichier_po = $module . '_' . $lang . '.po';
$dir_lang = sous_repertoire(_DIR_VAR, 'cache-tradlang');
$count=0;
if (file_exists($dest = $dir_lang.$fichier_php)) {
$memtrad = $GLOBALS['idx_lang'] = 'i18n_'.crc32($module).'_tmp';
$count = 0;
if (file_exists($dest = $dir_lang . $fichier_php)) {
$memtrad = $GLOBALS['idx_lang'] = 'i18n_' . crc32($module) . '_tmp';
include $dest;
/**
* Recuperation des statuts dans le fichier
*/
$contenu=file_get_contents($dest);
$contenu = file_get_contents($dest);
$contenu = str_replace("\t", '', $contenu);
$tab=preg_split("/\r\n|\n\r|;\n|\n\/\/|\(\n|\n\);\n|\'\,\n|\n[\s\t]*(\')|\/\/[\s\t][0-9A-Z]\n[\s\t](\')/", $contenu, '-1', PREG_SPLIT_NO_EMPTY);
$liste_trad=[];
$tab = preg_split("/\r\n|\n\r|;\n|\n\/\/|\(\n|\n\);\n|\'\,\n|\n[\s\t]*(\')|\/\/[\s\t][0-9A-Z]\n[\s\t](\')/", $contenu, '-1', PREG_SPLIT_NO_EMPTY);
$liste_trad = [];
reset($tab);
foreach ($tab as $ligne) {
$ligne = str_replace("\'", '', $ligne);
if (strlen($ligne)>0 && preg_match("/\'(.*?)\'[\s\t]*=>[\s\t]*\'(.*?)\'[\s\t]*,{0,1}[\s\t]*(#.*)?/ms", $ligne, $matches)) {
if (strlen($ligne) > 0 && preg_match("/\'(.*?)\'[\s\t]*=>[\s\t]*\'(.*?)\'[\s\t]*,{0,1}[\s\t]*(#.*)?/ms", $ligne, $matches)) {
if (isset($matches[1]) && isset($matches[3]) && strlen(trim($matches[3])) > 0) {
[, $comm] = explode('#', $matches[3]);
if (in_array(trim($comm), ['NEW', 'MODIF', 'RELIRE'])) {
$liste_trad[$matches[1]]=trim($comm);
$liste_trad[$matches[1]] = trim($comm);
}
}
}
@ -333,7 +333,7 @@ function formulaires_tradlang_importer_langue_traiter_dist($id_tradlang_module,
spip_log("Erreur, fichier $module mal forme", 'tradlang');
}
$langues_base = sql_allfetsel('*', 'spip_tradlangs', 'module = ' . sql_quote($module).' AND lang = ' . sql_quote($lang));
$langues_base = sql_allfetsel('*', 'spip_tradlangs', 'module = ' . sql_quote($module) . ' AND lang = ' . sql_quote($lang));
$modifs = [];
foreach ($langues_base as $strings_id => $strings) {
if (_request($strings['id']) == 'oui') {
@ -345,7 +345,7 @@ function formulaires_tradlang_importer_langue_traiter_dist($id_tradlang_module,
}
}
spip_unlink($dest);
} else if (file_exists($dest = $dir_lang. $fichier_po)) {
} elseif (file_exists($dest = $dir_lang . $fichier_po)) {
lire_fichier($dest, $contenu_po);
preg_match_all(',(\#\, php-format|\#\, fuzzy\, php-format).*msgstr "(.*)\n(\n|\Z),Uims', $contenu_po, $matches);
$array_po = [];
@ -359,7 +359,7 @@ function formulaires_tradlang_importer_langue_traiter_dist($id_tradlang_module,
preg_match(',\nmsgid \"(.*)\nmsgstr,Uims', $match, $matches_str_orig);
$str_orig = rtrim(trim($matches_str_orig[1]), '"');
$str_orig = trim(str_replace("\"\n\"", '', $str_orig));
$matches[1] = sql_getfetsel('id', 'spip_tradlangs', 'id_tradlang_module = ' . (int) $id_tradlang_module.' AND str = ' . sql_quote($str_orig));
$matches[1] = sql_getfetsel('id', 'spip_tradlangs', 'id_tradlang_module = ' . (int) $id_tradlang_module . ' AND str = ' . sql_quote($str_orig));
}
if (preg_match(',\#\, fuzzy\, php-format,', $match, $matches_statut)) {
$statut = 'MODIF';
@ -373,7 +373,7 @@ function formulaires_tradlang_importer_langue_traiter_dist($id_tradlang_module,
$modifs_po = [];
foreach ($langues_base as $strings_id => $strings) {
if (_request($strings['id']) == 'oui') {
$set=$instit=null;
$set = $instit = null;
if (isset($array_po[$strings['id']]['str']) && strlen(trim($array_po[$strings['id']]['str'])) > 0) {
$set = ['str' => $array_po[$strings['id']]['str']];
tradlang_set($strings['id_tradlang'], $set);

@ -22,5 +22,5 @@ function formulaires_tradlang_recherche_avancee_charger_dist($lien = '') {
'id_tradlang_module' => _request('id_tradlang_module'),
'lang_string' => _request('lang_string'),
'lang' => $lang,
];
];
}

@ -1,4 +1,5 @@
<?php
/**
* Trad-lang v2
* Plugin SPIP de traduction de fichiers de langue
@ -8,6 +9,7 @@
*
* @package SPIP\Tradlang\Formulaires
*/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}

@ -1,27 +1,27 @@
<?php
/*
This file is part of Salvatore, the translation robot of Trad-lang (SPIP)
Salvatore is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Trad-Lang is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Trad-Lang; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Copyright 2003-2013
Florent Jugla <florent.jugla@eledo.com>,
Philippe Riviere <fil@rezo.net>,
Chryjs <chryjs!@!free!.!fr>,
kent1 <kent1@arscenic.info>
This file is part of Salvatore, the translation robot of Trad-lang (SPIP)
Salvatore is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.
Trad-Lang is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with Trad-Lang; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
Copyright 2003-2013
Florent Jugla <florent.jugla@eledo.com>,
Philippe Riviere <fil@rezo.net>,
Chryjs <chryjs!@!free!.!fr>,
kent1 <kent1@arscenic.info>
*/
@ -32,48 +32,48 @@
* @param bool $display_time
* @throws Exception
*/
function salvatore_init($log_function = null, $display_time = false){
function salvatore_init($log_function = null, $display_time = false) {
static $initialized;
// set log function if any
if ($log_function){
if ($log_function) {
salvatore_log('', $log_function, $display_time);
}
if (is_null($initialized)){
if (is_null($initialized)) {
@ini_set('memory_limit', '50M');
if (!defined('_DEBUG_TRAD_LANG')){
if (!defined('_DEBUG_TRAD_LANG')) {
define('_DEBUG_TRAD_LANG', 1); // undef si on ne veut pas de messages
}
if (!defined('_DIR_SALVATORE')){
if (!defined('_DIR_SALVATORE')) {
define('_DIR_SALVATORE', _DIR_RACINE . 'salvatore/');
}
if (!defined('_DIR_SALVATORE_TRADUCTIONS')){
if (!defined('_DIR_SALVATORE_TRADUCTIONS')) {
define('_DIR_SALVATORE_TRADUCTIONS', _DIR_SALVATORE . 'traductions/');
}
if (!defined('_DIR_SALVATORE_TMP')){
if (!defined('_DIR_SALVATORE_TMP')) {
define('_DIR_SALVATORE_TMP', _DIR_SALVATORE . 'tmp/');
}
if (!defined('_DIR_SALVATORE_MODULES')){
if (!defined('_DIR_SALVATORE_MODULES')) {
define('_DIR_SALVATORE_MODULES', _DIR_SALVATORE . 'modules/');
}
if (!defined('_DIR_SALVATORE_DEPOTS')){
if (!defined('_DIR_SALVATORE_DEPOTS')) {
define('_DIR_SALVATORE_DEPOTS', _DIR_SALVATORE . 'depots/');
}
if (defined('_ID_AUTEUR_SALVATORE') && is_numeric(_ID_AUTEUR_SALVATORE)){
if (defined('_ID_AUTEUR_SALVATORE') && is_numeric(_ID_AUTEUR_SALVATORE)) {
$GLOBALS['visiteur_session'] = [];
$GLOBALS['visiteur_session']['id_auteur'] = _ID_AUTEUR_SALVATORE;
// TODO : charger une session complete ?
}
// par defaut on relit les fichiers si modifies depuis moins de 1J
if (!defined('_SALVATORE_LECTEUR_REFRESH_DELAY')){
if (!defined('_SALVATORE_LECTEUR_REFRESH_DELAY')) {
define('_SALVATORE_LECTEUR_REFRESH_DELAY', 24 * 3600);
}
@ -92,12 +92,12 @@ function salvatore_init($log_function = null, $display_time = false){
}
if (!isset($GLOBALS['idx_lang'])){
if (!isset($GLOBALS['idx_lang'])) {
$GLOBALS['idx_lang'] = 0;
}
// verifications des repertoires
foreach ([_DIR_SALVATORE, _DIR_SALVATORE_TRADUCTIONS, _DIR_SALVATORE_MODULES, _DIR_SALVATORE_DEPOTS, _DIR_SALVATORE_TMP] as $dir){
foreach ([_DIR_SALVATORE, _DIR_SALVATORE_TRADUCTIONS, _DIR_SALVATORE_MODULES, _DIR_SALVATORE_DEPOTS, _DIR_SALVATORE_TMP] as $dir) {
salvatore_check_dir($dir);
}
$initialized = true;
@ -113,10 +113,10 @@ function salvatore_init($log_function = null, $display_time = false){
* @return array
* @throws Exception
*/
function salvatore_charger_fichier_traductions($fichier_traductions = null){
function salvatore_charger_fichier_traductions($fichier_traductions = null) {
salvatore_init();
if (is_null($fichier_traductions)){
if (is_null($fichier_traductions)) {
$fichier_traductions = _DIR_SALVATORE_TRADUCTIONS . 'traductions.txt';
}
salvatore_check_file($fichier_traductions);
@ -126,15 +126,15 @@ function salvatore_charger_fichier_traductions($fichier_traductions = null){
$lignes = array_filter($lignes);
$liste_trad = [];
foreach ($lignes as $ligne){
if ($ligne[0]!=='#'){
foreach ($lignes as $ligne) {
if ($ligne[0] !== '#') {
$liste = explode(';', trim($ligne));
$methode = $url = $branche = $dir = $module = $lang = '';
// deprecated ancien format, forcement en svn
// liste courte de type
// url;module;lang
if (count($liste)<=3){
if (count($liste) <= 3) {
$methode = 'svn';
$branche = '';
$url = $liste[0];
@ -159,20 +159,19 @@ function salvatore_charger_fichier_traductions($fichier_traductions = null){
if ($methode && $url && $module && $lang) {
// que fait la $GLOBALS['modules'] ?
if (empty($GLOBALS['modules']) || in_array($module, $GLOBALS['modules'])){
if (empty($GLOBALS['modules']) || in_array($module, $GLOBALS['modules'])) {
// unifier les urls git en https, plus simple a gerer car ne necessitent pas une cle ssh sur le user php (www-data)
if (strpos($url, "git@git.spip.net:") === 0) {
$url = "https://git.spip.net/" . substr($url, 17);
if (strpos($url, 'git@git.spip.net:') === 0) {
$url = 'https://git.spip.net/' . substr($url, 17);
}
// definir un dir checkout unique meme si plusieurs modules de meme nom dans differents repos
$d = explode('/', $url);
while (count($d) && in_array(end($d), ['', 'lang', 'trunk', 'ecrire'])){
while (count($d) && in_array(end($d), ['', 'lang', 'trunk', 'ecrire'])) {
array_pop($d);
}
$source = '';
if (end($d)){
if (end($d)) {
$source = basename(end($d), '.git');
$source = '--' . preg_replace(',[^\w-],', '_', $source);
if ($branche && $branche !== 'master') {
@ -180,7 +179,7 @@ function salvatore_charger_fichier_traductions($fichier_traductions = null){
}
}
$dir_module = "{$module}{$source}-" . substr(md5("$methode:$url:$branche:$dir"), 0, 5);
$dir_checkout = preg_replace(",\W+,", "-", "$methode-$url") . ($branche ? "--$branche-" : "-") . substr(md5("$methode:$url:$branche"), 0, 5);
$dir_checkout = preg_replace(',\W+,', '-', "$methode-$url") . ($branche ? "--$branche-" : '-') . substr(md5("$methode:$url:$branche"), 0, 5);
$liste_trad[] = [
'methode' => $methode,
@ -260,7 +259,7 @@ function salvatore_verifier_gestionnaire_traduction($dir_module, $module) {
* On teste ici si le fichier est géré par un autre salvatore
* Si oui on empeche son import en le signifiant
*/
if ($t = salvatore_lire_gestionnaire_traduction($dir_module, $module)){
if ($t = salvatore_lire_gestionnaire_traduction($dir_module, $module)) {
$url = extraire_attribut($t, 'url');
$gestionnaire = extraire_attribut($t, 'gestionnaire');
$url_gestionnaire = salvatore_get_self_url();
@ -285,14 +284,14 @@ function salvatore_lire_gestionnaire_traduction($dir_module, $module) {
* On teste ici si le fichier est géré par un autre salvatore
* Si oui on empeche son import en le signifiant
*/
if (file_exists($xml_file)){
if (file_exists($xml_file)) {
$xml_content = spip_xml_load($xml_file);
// normalement on a qu'une balise <traduction...> englobante, donc on prend la premiere qu'on trouve
if (
is_array($xml_content)
&& (spip_xml_match_nodes('/^traduction/', $xml_content, $matches)
&& ($nodes = array_keys($matches)) && ($node = reset($nodes)))
){
) {
return "<$node>";
}
}
@ -317,13 +316,13 @@ function salvatore_retrouver_tradlang_module($dir_module, $module) {
// peut-etre c'est un module qui a change d'url repo, et donc son dir_module a change ?
// sur la balise <traduction> le dir_module est ecrit dans id
if ((
if (
(
$t = salvatore_lire_gestionnaire_traduction($dir_module, $module))
&& ($old_dir_module = extraire_attribut($t, 'id'))
&& $old_dir_module !== $base_dir_module
&& ($row_module = sql_fetsel('*', 'spip_tradlang_modules', 'dir_module = ' . sql_quote($old_dir_module)))
){
) {
return $row_module;
}
@ -338,39 +337,38 @@ function salvatore_retrouver_tradlang_module($dir_module, $module) {
* @param string $module
* @return string
*/
function salvatore_set_credentials($methode, $url_repository, $module){
function salvatore_set_credentials($methode, $url_repository, $module) {
global $domaines_exceptions, $domaines_exceptions_credentials,
$SVNUSER, $SVNPASSWD,
$GITUSER, $GITPASSWD;
$SVNUSER, $SVNPASSWD,
$GITUSER, $GITPASSWD;
// on ne sait pas mettre des credentials si c'est du ssh
if (strpos($url_repository, '://')!==false){
if (strpos($url_repository, '://') !== false) {
$user = $pass = false;
$parts = parse_url($url_repository);
if (empty($parts['user']) && empty($parts['pass'])){
if (empty($parts['user']) && empty($parts['pass'])) {
$host = $parts['host'];
require_once(_DIR_ETC . 'salvatore_passwd.inc');
if (!empty($domaines_exceptions) && is_array($domaines_exceptions) && in_array($host, $domaines_exceptions)){
if (!empty($domaines_exceptions) && is_array($domaines_exceptions) && in_array($host, $domaines_exceptions)) {
// on est dans une exception
/**
* Est-ce que cette exception dispose de credentials (Github ou git.spip.net)
*/
if (is_array($domaines_exceptions_credentials) && !empty($domaines_exceptions_credentials[$host])){
if (is_array($domaines_exceptions_credentials) && !empty($domaines_exceptions_credentials[$host])) {
$user = $domaines_exceptions_credentials[$host]['user'];
$pass = $domaines_exceptions_credentials[$host]['pass'];
}
} else {
// un truc perso pour un module en particulier ?
if (isset(${$module . '_user'})){
if (isset(${$module . '_user'})) {
$user = ${$module . '_user'};
$pass = ${$module . '_passwd'};
} elseif ($methode==='svn' && isset($SVNUSER)) {
} elseif ($methode === 'svn' && isset($SVNUSER)) {
$user = $SVNUSER;
$pass = $SVNPASSWD;
} elseif ($methode==='git' && isset($GITUSER)) {
} elseif ($methode === 'git' && isset($GITUSER)) {
$user = $GITUSER;
$pass = $GITPASSWD;
}
@ -378,11 +376,10 @@ function salvatore_set_credentials($methode, $url_repository, $module){
// l'acces par jeton se fait avec user+jeton sur github et simple jeton en guise de user sur gitea
// donc le pass peut etre vide
if ($user){
$url_repository = str_replace("://$host", "://" . urlencode($user) . ($pass ? ":" . urlencode($pass) : "") . "@$host", $url_repository);
if ($user) {
$url_repository = str_replace("://$host", '://' . urlencode($user) . ($pass ? ':' . urlencode($pass) : '') . "@$host", $url_repository);
}
}
}
return $url_repository;
@ -411,8 +408,8 @@ function salvatore_vcs_function($methode, $function) {
* @param $dir
* @throws Exception
*/
function salvatore_check_dir($dir){
if (!is_dir($dir)){
function salvatore_check_dir($dir) {
if (!is_dir($dir)) {
throw new Exception("Erreur : le répertoire $dir n'existe pas");
}
}
@ -422,8 +419,8 @@ function salvatore_check_dir($dir){
* @param $file
* @throws Exception
*/
function salvatore_check_file($file){
if (!file_exists($file)){
function salvatore_check_file($file) {
if (!file_exists($file)) {
throw new Exception("Erreur : Le fichier $file est introuvable");
}
}
@ -434,25 +431,25 @@ function salvatore_check_file($file){
* @param string|array $display_function
* @param bool $display_time
*/
function salvatore_log($msg = '', $display_function = null, $disp