Skip to content
Extraits de code Groupes Projets

Comparer les révisions

Les modifications sont affichées comme si la révision source était fusionnée avec la révision cible. En savoir plus sur la comparaison des révisions.

Source

Sélectionner le projet cible
No results found

Cible

Sélectionner le projet cible
  • spip/medias
  • pierre.laszczak/medias
  • cy.altern/medias
  • MathieuAlphamosa/medias
  • taffit/medias
  • RealET/medias
  • johan/medias
  • Yohooo/medias
  • pierretux/medias
  • placido/medias
  • JLuc/medias
11 résultats
Afficher les modifications
Validations sur la source (12)
Affichage de
avec 296 ajouts et 234 suppressions
/vendor/
/composer.phar
/composer.lock
/phpcs.xml
/phpstan.neon
/.php_cs.cache
/.php_cs.txt
......@@ -31,7 +31,8 @@ function action_acceder_document_dist() {
$arg = rawurldecode(_request('arg'));
$status = false;
if (strpos($f, '../') !== false
if (
strpos($f, '../') !== false
or preg_match(',^\w+://,', $f)
) {
$status = 403;
......@@ -52,7 +53,8 @@ function action_acceder_document_dist() {
} else {
// ETag pour gerer le status 304
$ETag = md5($file . ': ' . filemtime($file));
if (isset($_SERVER['HTTP_IF_NONE_MATCH'])
if (
isset($_SERVER['HTTP_IF_NONE_MATCH'])
and $_SERVER['HTTP_IF_NONE_MATCH'] == $ETag
) {
http_status(304); // Not modified
......@@ -100,7 +102,8 @@ function action_acceder_document_dist() {
// sinon l'ignorer car certains navigateurs pataugent
$f = basename($file);
if (isset($doc['titre'])
if (
isset($doc['titre'])
and (preg_match('/^\w+[.]\w+$/', $doc['titre']) or $doc['titre'] == 'Makefile')
) {
$f = $doc['titre'];
......
......@@ -44,7 +44,7 @@ include_spip('inc/renseigner_document');
*/
function action_ajouter_documents_dist($id_document, $files, $objet, $id_objet, $mode) {
$ajouter_un_document = charger_fonction('ajouter_un_document', 'action');
$ajoutes = array();
$ajoutes = [];
// on ne peut mettre qu'un seul document a la place d'un autre ou en vignette d'un autre
if (intval($id_document)) {
......@@ -104,9 +104,11 @@ function action_ajouter_un_document_dist($id_document, $file, $objet, $id_objet,
$mode = ((isset($file['mode']) and $file['mode']) ? $file['mode'] : $mode);
include_spip('inc/modifier');
if (isset($file['distant']) and $file['distant']
and !in_array($mode, array('choix', 'auto', 'image', 'document'))) {
spip_log("document distant $source accepte sans verification, mode=$mode", 'medias'._LOG_INFO_IMPORTANTE);
if (
isset($file['distant']) and $file['distant']
and !in_array($mode, ['choix', 'auto', 'image', 'document'])
) {
spip_log("document distant $source accepte sans verification, mode=$mode", 'medias' . _LOG_INFO_IMPORTANTE);
include_spip('inc/distant');
$file['tmp_name'] = _DIR_RACINE . copie_locale($source);
$source = $file['tmp_name'];
......@@ -118,16 +120,24 @@ function action_ajouter_un_document_dist($id_document, $file, $objet, $id_objet,
// content-type est connu, et si possible recuperer la taille, voire plus.
if (isset($file['distant']) and $file['distant']) {
if (!tester_url_absolue($source)) {
return _T('medias:erreur_chemin_distant', array('nom' => $source));
return _T('medias:erreur_chemin_distant', ['nom' => $source]);
}
include_spip('inc/distant');
$source = str_replace(array("'",'"','<'),array("%27",'%22','%3C'), $source);
$source = str_replace(["'",'"','<'], ['%27','%22','%3C'], $source);
if (is_array($a = renseigner_source_distante($source))) {
$champs = $a;
# NB: dans les bonnes conditions (fichier autorise et pas trop gros)
# $a['fichier'] est une copie locale du fichier
# $a['copie_locale'] est une copie locale du fichier
// voir si le document a besoin d'un nettoyage et le cas echeant relire ses infos apres
if (!empty($champs['copie_locale']) and file_exists($champs['copie_locale'])) {
$res_sanitize = sanitizer_document($champs['copie_locale'], $champs['extension']);
$infos = renseigner_taille_dimension_image($champs['copie_locale'], $champs['extension']);
}
else {
$infos = renseigner_taille_dimension_image($champs['fichier'], $champs['extension'], true);
}
$infos = renseigner_taille_dimension_image($champs['fichier'], $champs['extension'], true);
// on ignore erreur eventuelle sur $infos car on est distant, ca ne marche pas forcement
if (is_array($infos)) {
foreach ($infos as $k => $v) {
......@@ -145,10 +155,9 @@ function action_ajouter_un_document_dist($id_document, $file, $objet, $id_objet,
return $a; // message d'erreur
}
} else { // pas distant
$champs = array(
$champs = [
'distant' => 'non'
);
];
$champs['titre'] = '';
if ($titrer) {
......@@ -164,7 +173,7 @@ function action_ajouter_un_document_dist($id_document, $file, $objet, $id_objet,
if (!is_array($fichier = fixer_fichier_upload($file, $mode))) {
return is_string($fichier) ?
$fichier : _T('medias:erreur_upload_type_interdit', array('nom' => $file['name']));
$fichier : _T('medias:erreur_upload_type_interdit', ['nom' => $file['name']]);
}
$champs['inclus'] = $fichier['inclus'];
......@@ -214,7 +223,7 @@ function action_ajouter_un_document_dist($id_document, $file, $objet, $id_objet,
$champs = array_merge($champs, $infos);
// Si mode == 'choix', fixer le mode image/document
if (in_array($mode, array('choix', 'auto'))) {
if (in_array($mode, ['choix', 'auto'])) {
$choisir_mode_document = charger_fonction('choisir_mode_document', 'inc');
$mode = $choisir_mode_document($champs, $champs['inclus'] == 'image', $objet);
}
......@@ -276,7 +285,7 @@ function action_ajouter_un_document_dist($id_document, $file, $objet, $id_objet,
}
}
if (!$id_document) {
return _T('medias:erreur_insertion_document_base', array('fichier' => '<em>' . $file['name'] . '</em>'));
return _T('medias:erreur_insertion_document_base', ['fichier' => '<em>' . $file['name'] . '</em>']);
}
document_modifier($id_document, $champs);
......@@ -286,8 +295,8 @@ function action_ajouter_un_document_dist($id_document, $file, $objet, $id_objet,
// Ce plugin ferait quand même mieux de se placer dans metadata/jpg.php
pipeline(
'post_edition',
array(
'args' => array(
[
'args' => [
'table' => 'spip_documents', // compatibilite
'table_objet' => 'documents',
'spip_table_objet' => 'spip_documents',
......@@ -297,9 +306,9 @@ function action_ajouter_un_document_dist($id_document, $file, $objet, $id_objet,
'serveur' => '', // serveur par defaut, on ne sait pas faire mieux pour le moment
'action' => 'ajouter_document',
'operation' => 'ajouter_document', // compat <= v2.0
),
],
'data' => $champs
)
]
);
return $id_document;
......@@ -317,7 +326,7 @@ function determiner_sous_dossier_document($ext, $fichier, $mode) {
// si mode un logoxx on met dans logo/
if (strncmp($mode, 'logo', 4) === 0) {
return "logo";
return 'logo';
}
return $ext;
......@@ -376,26 +385,31 @@ function corriger_extension($ext) {
* - false ou message d'erreur si l'extension est refusée
*/
function verifier_upload_autorise($source, $mode = '') {
$infos = array('fichier' => $source);
$infos = ['fichier' => $source];
$res = false;
if (preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $match)
if (
preg_match(',\.([a-z0-9]+)(\?.*)?$,i', $source, $match)
and $ext = $match[1]
) {
$ext = corriger_extension(strtolower($ext));
if ($res = sql_fetsel(
'extension,inclus,media_defaut as media',
'spip_types_documents',
'extension=' . sql_quote($ext) . " AND upload='oui'"
)) {
if (
$res = sql_fetsel(
'extension,inclus,media_defaut as media',
'spip_types_documents',
'extension=' . sql_quote($ext) . " AND upload='oui'"
)
) {
$infos = array_merge($infos, $res);
}
}
if (!$res) {
if ($res = sql_fetsel(
'extension,inclus,media_defaut as media',
'spip_types_documents',
"extension='zip' AND upload='oui'"
)) {
if (
$res = sql_fetsel(
'extension,inclus,media_defaut as media',
'spip_types_documents',
"extension='zip' AND upload='oui'"
)
) {
$infos = array_merge($infos, $res);
$res['autozip'] = true;
}
......@@ -449,7 +463,7 @@ function fixer_fichier_upload($file, $mode = '') {
if ($row['fichier'] && (!$taille = @intval(filesize(get_spip_doc($row['fichier']))))) {
spip_log('Echec copie du fichier ' . $file['tmp_name'] . ' (taille de fichier indéfinie)');
spip_unlink(get_spip_doc($row['fichier']));
return _T('medias:erreur_copie_fichier', array('nom' => $file['tmp_name']));
return _T('medias:erreur_copie_fichier', ['nom' => $file['tmp_name']]);
} else {
return $row;
}
......@@ -497,7 +511,7 @@ function fixer_fichier_upload($file, $mode = '') {
spip_log('Echec copie du fichier ' . $file['tmp_name'] . ' (taille de fichier indéfinie)');
spip_unlink(get_spip_doc($row['fichier']));
return _T('medias:erreur_copie_fichier', array('nom' => $file['tmp_name']));
return _T('medias:erreur_copie_fichier', ['nom' => $file['tmp_name']]);
} else {
return $row;
}
......
......@@ -37,7 +37,8 @@ function action_changer_mode_document_dist($id_document = null, $mode = null) {
}
}
if ($id_document
if (
$id_document
and include_spip('inc/autoriser')
and autoriser('modifier', 'document', $id_document)
) {
......@@ -49,10 +50,11 @@ function action_changer_mode_document_dist($id_document = null, $mode = null) {
function action_changer_mode_document_post($id_document, $mode) {
// - id_document le doc a modifier
// - mode le mode a lui donner
if ($id_document = intval($id_document)
and in_array($mode, array('vignette', 'image', 'document'))
if (
$id_document = intval($id_document)
and in_array($mode, ['vignette', 'image', 'document'])
) {
include_spip('action/editer_document');
document_modifier($id_document, array('mode' => $mode));
document_modifier($id_document, ['mode' => $mode]);
}
}
......@@ -54,22 +54,25 @@ function action_copier_local_dist($id_document = null) {
function action_copier_local_post($id_document) {
// Il faut la source du document pour le copier
$row = sql_fetsel('mode,fichier, descriptif, credits', 'spip_documents', 'id_document='.intval($id_document));
$row = sql_fetsel('mode,fichier, descriptif, credits', 'spip_documents', 'id_document=' . intval($id_document));
$source = $row['fichier'];
// si la source est bien un fichier distant
// sinon c'est une donnee moisie, on ne fait rien
if (tester_url_absolue($source)) {
include_spip('inc/distant'); // pour 'copie_locale'
include_spip('inc/distant');
if (tester_url_absolue($source)
and valider_url_distante($source)) {
$fichier = copie_locale($source);
if ($fichier
and tester_url_absolue($source)) {
if (
$fichier
and valider_url_distante($source)
) {
$fichier = _DIR_RACINE . $fichier;
$files = array();
$files[] = array('tmp_name' => $fichier, 'name' => basename($fichier));
$files = [];
$files[] = ['tmp_name' => $fichier, 'name' => basename($fichier)];
$ajouter_documents = charger_fonction('ajouter_documents', 'action');
spip_log("convertit doc $id_document en local: $source => $fichier", 'medias');
$liste = array();
$liste = [];
$ajouter_documents($id_document, $files, '', 0, $row['mode'], $liste);
spip_unlink($fichier);
......@@ -78,16 +81,19 @@ function action_copier_local_post($id_document) {
include_spip('action/editer_document');
document_modifier(
$id_document,
array('credits' => ($row['credits'] ? $row['credits'] . ', ' : '') . $source)
['credits' => ($row['credits'] ? $row['credits'] . ', ' : '') . $source]
);
return true;
} else {
spip_log("echec copie locale $source", 'medias' . _LOG_ERREUR);
if ($fichier) {
@unlink(_DIR_RACINE . $fichier);
}
}
} else {
spip_log("echec copie locale $source n'est pas une URL distante", 'medias' . _LOG_ERREUR);
}
return _T('medias:erreur_copie_fichier', array('nom' => $source));
return _T('medias:erreur_copie_fichier', ['nom' => $source]);
}
......@@ -73,7 +73,7 @@ function desordonner_liens_documents($document, $objet, $id_objet) {
} else {
list($image, $mode) = explode('/', $document);
$image = ($image == 'I');
$typdoc = sql_in('docs.extension', array('gif', 'jpg', 'png'), $image ? '' : 'NOT');
$typdoc = sql_in('docs.extension', ['gif', 'jpg', 'png'], $image ? '' : 'NOT');
$obj = 'id_objet=' . intval($id_objet) . ' AND objet=' . sql_quote($objet);
......@@ -101,8 +101,8 @@ function desordonner_liens_documents($document, $objet, $id_objet) {
*/
function desordonner_liens_document($id_document, $objet, $id_objet) {
objet_qualifier_liens(
array('document' => $id_document),
array($objet => $id_objet),
array('rang_lien' => 0)
['document' => $id_document],
[$objet => $id_objet],
['rang_lien' => 0]
);
}
\ No newline at end of file
}
......@@ -56,7 +56,8 @@ function action_dissocier_document_dist($arg = null) {
if (count($arg) > 4 and $arg[4] == 'safe') {
$check = true;
}
if ($id_objet = intval($id_objet)
if (
$id_objet = intval($id_objet)
and (
($id_objet < 0 and $id_objet == -$GLOBALS['visiteur_session']['id_auteur'])
or autoriser('dissocierdocuments', $objet, $id_objet)
......@@ -91,11 +92,11 @@ function supprimer_lien_document($id_document, $objet, $id_objet, $supprime = fa
// D'abord on ne supprime pas, on dissocie
include_spip('action/editer_liens');
objet_dissocier(array('document' => $id_document), array($objet => $id_objet), array('role' => '*'));
objet_dissocier(['document' => $id_document], [$objet => $id_objet], ['role' => '*']);
// Si c'est une vignette, l'eliminer du document auquel elle appartient
// cas tordu peu probable
sql_updateq('spip_documents', array('id_vignette' => 0), 'id_vignette=' . $id_document);
sql_updateq('spip_documents', ['id_vignette' => 0], 'id_vignette=' . $id_document);
// verifier son statut apres une suppression de lien
include_spip('action/editer_document');
......@@ -107,17 +108,17 @@ function supprimer_lien_document($id_document, $objet, $id_objet, $supprime = fa
pipeline(
'post_edition',
array(
'args' => array(
[
'args' => [
'operation' => 'delier_document', // compat v<=2
'action' => 'delier_document',
'table' => 'spip_documents',
'id_objet' => $id_document,
'objet' => $objet,
'id' => $id_objet
),
],
'data' => null
)
]
);
if ($check) {
......@@ -165,7 +166,7 @@ function dissocier_document($document, $objet, $id_objet, $supprime = false, $ch
} else {
list($image, $mode) = explode('/', $document);
$image = ($image == 'I');
$typdoc = sql_in('docs.extension', array('gif', 'jpg', 'png'), $image ? '' : 'NOT');
$typdoc = sql_in('docs.extension', ['gif', 'jpg', 'png'], $image ? '' : 'NOT');
$obj = 'id_objet=' . intval($id_objet) . ' AND objet=' . sql_quote($objet);
......
......@@ -34,12 +34,12 @@ function action_editer_document_dist($arg = null) {
}
if (!$id_document) {
return array(0, '');
return [0, ''];
} // erreur
$err = document_modifier($id_document);
return array($id_document, $err);
return [$id_document, $err];
}
/**
......@@ -52,10 +52,10 @@ function action_editer_document_dist($arg = null) {
*/
function document_inserer($id_parent = null, $set = null) {
$champs = array(
$champs = [
'statut' => 'prop',
'date' => 'NOW()',
);
];
if ($set) {
$champs = array_merge($champs, $set);
......@@ -64,23 +64,23 @@ function document_inserer($id_parent = null, $set = null) {
// Envoyer aux plugins
$champs = pipeline(
'pre_insertion',
array(
'args' => array(
[
'args' => [
'table' => 'spip_documents',
),
],
'data' => $champs
)
]
);
$id_document = sql_insertq('spip_documents', $champs);
pipeline(
'post_insertion',
array(
'args' => array(
[
'args' => [
'table' => 'spip_documents',
'id_objet' => $id_document
),
],
'data' => $champs
)
]
);
return $id_document;
......@@ -105,7 +105,7 @@ function document_modifier($id_document, $set = null) {
// white list
objet_info('document', 'champs_editables'),
// black list
array('parents', 'ajout_parents'),
['parents', 'ajout_parents'],
// donnees eventuellement fournies
$set
);
......@@ -127,21 +127,24 @@ function document_modifier($id_document, $set = null) {
$ancien_fichier = sql_getfetsel('fichier', 'spip_documents', 'id_document=' . intval($id_document));
}
if ($err = objet_modifier_champs(
'document',
$id_document,
array(
if (
$err = objet_modifier_champs(
'document',
$id_document,
[
'data' => $set,
'invalideur' => $invalideur,
'indexation' => $indexation
),
$champs
)) {
],
$champs
)
) {
return $err;
}
// nettoyer l'ancien fichier si necessaire
if (isset($champs['fichier']) // un plugin a pu interdire la modif du fichier en virant le champ
if (
isset($champs['fichier']) // un plugin a pu interdire la modif du fichier en virant le champ
and $champs['fichier']
and $ancien_fichier // on avait bien note le nom du fichier avant la modif
and $ancien_fichier !== $champs['fichier'] // et il a ete modifie
......@@ -153,7 +156,7 @@ function document_modifier($id_document, $set = null) {
// Changer le statut du document ?
// le statut n'est jamais fixe manuellement mais decoule de celui des objets lies
$champs = collecter_requests(array('parents', 'ajouts_parents'), array(), $set);
$champs = collecter_requests(['parents', 'ajouts_parents'], [], $set);
if (document_instituer($id_document, $champs)) {
//
// Post-modifications
......@@ -174,7 +177,7 @@ function document_modifier($id_document, $set = null) {
* @param array $champs
* @return bool
*/
function document_instituer($id_document, $champs = array()) {
function document_instituer($id_document, $champs = []) {
$statut = isset($champs['statut']) ? $champs['statut'] : null;
$date_publication = isset($champs['date_publication']) ? $champs['date_publication'] : null;
......@@ -185,11 +188,11 @@ function document_instituer($id_document, $champs = array()) {
medias_revision_document_parents($id_document, $champs['ajout_parents'], true);
}
$row = sql_fetsel('statut,date_publication', 'spip_documents', 'id_document='.intval($id_document));
$row = sql_fetsel('statut,date_publication', 'spip_documents', 'id_document=' . intval($id_document));
$statut_ancien = $row['statut'];
$date_publication_ancienne = $row['date_publication'];
$champs = array();
$champs = [];
/* Autodetermination du statut si non fourni */
if (is_null($statut)) {
......@@ -200,7 +203,6 @@ function document_instituer($id_document, $champs = array()) {
if ($champs === false) {
return false;
}
}
else {
if ($statut !== $statut_ancien) {
......@@ -208,24 +210,27 @@ function document_instituer($id_document, $champs = array()) {
}
}
if (!is_null($date_publication)
if (
!is_null($date_publication)
and empty($champs['date_publication'])
and $date_publication != $date_publication_ancienne) {
and $date_publication != $date_publication_ancienne
) {
$champs['date_publication'] = $date_publication;
}
// Envoyer aux plugins
$champs = pipeline('pre_edition',
array(
'args' => array(
$champs = pipeline(
'pre_edition',
[
'args' => [
'table' => 'spip_documents',
'id_objet' => $id_document,
'action' => 'instituer',
'statut_ancien' => $statut_ancien,
'date_ancienne' => $date_publication_ancienne,
),
],
'data' => $champs
)
]
);
if (!count($champs)) {
......@@ -242,7 +247,7 @@ function document_instituer($id_document, $champs = array()) {
if (count($publier_rubriques)) {
include_spip('inc/rubriques');
foreach ($publier_rubriques as $r) {
calculer_rubriques_if($r['id_objet'], array('statut' => $champs['statut']), $statut_ancien, false);
calculer_rubriques_if($r['id_objet'], ['statut' => $champs['statut']], $statut_ancien, false);
}
}
}
......@@ -251,17 +256,18 @@ function document_instituer($id_document, $champs = array()) {
include_spip('inc/invalideur');
suivre_invalideur("id='document/$id_document'");
pipeline('post_edition',
array(
'args' => array(
pipeline(
'post_edition',
[
'args' => [
'table' => 'spip_documents',
'id_objet' => $id_document,
'action' => 'instituer',
'statut_ancien' => $statut_ancien,
'date_ancienne' => $date_publication_ancienne,
),
],
'data' => $champs
)
]
);
return true;
......@@ -283,13 +289,14 @@ function medias_revision_document_parents($id_document, $parents = null, $ajout
return;
}
$insertions = array();
$objets_parents = array(); // array('article'=>array(12,23))
$insertions = [];
$objets_parents = []; // array('article'=>array(12,23))
// au format objet|id_objet
foreach ($parents as $p) {
$p = explode('|', $p);
if (preg_match('/^[a-z0-9_]+$/i', $objet = $p[0])
if (
preg_match('/^[a-z0-9_]+$/i', $objet = $p[0])
and (($p[1] = intval($p[1])) or in_array($objet, ['site', 'rubrique']))
) { // securite
$objets_parents[$p[0]][] = $p[1];
......@@ -298,14 +305,14 @@ function medias_revision_document_parents($id_document, $parents = null, $ajout
include_spip('action/editer_liens');
// les liens actuels
$liens = objet_trouver_liens(array('document' => $id_document), '*');
$deja_parents = array();
$liens = objet_trouver_liens(['document' => $id_document], '*');
$deja_parents = [];
// si ce n'est pas un ajout, il faut supprimer les liens actuels qui ne sont pas dans $objets_parents
if (!$ajout) {
foreach ($liens as $k => $lien) {
if (!isset($objets_parents[$lien['objet']]) or !in_array($lien['id_objet'], $objets_parents[$lien['objet']])) {
if (autoriser('dissocierdocuments', $lien['objet'], $lien['id_objet'])) {
objet_dissocier(array('document' => $id_document), array($lien['objet'] => $lien['id_objet']));
objet_dissocier(['document' => $id_document], [$lien['objet'] => $lien['id_objet']]);
}
unset($liens[$k]);
} else {
......@@ -317,7 +324,8 @@ function medias_revision_document_parents($id_document, $parents = null, $ajout
// trier les objets à traiter : ne pas prendre en compte ceux qui sont déjà associés ou qu'on n'a pas le droit d'associer
foreach ($objets_parents as $objet => $ids) {
foreach ($ids as $k => $id) {
if ((
if (
(
isset($deja_parents[$objet])
and in_array($id, $deja_parents[$objet])
)
......@@ -327,5 +335,5 @@ function medias_revision_document_parents($id_document, $parents = null, $ajout
}
}
}
objet_associer(array('document' => $id_document), $objets_parents);
objet_associer(['document' => $id_document], $objets_parents);
}
......@@ -44,23 +44,25 @@ function action_ordonner_liens_dist() {
list($_id_objet, $table_liens) = objet_associable($objet);
$success = $errors = array();
$success = $errors = [];
$actuels = sql_allfetsel(
array($_id_objet . ' AS id', 'rang_lien'),
[$_id_objet . ' AS id', 'rang_lien'],
$table_liens,
array(
[
sql_in($_id_objet, $ordre),
'objet = ' . sql_quote($objet_lie),
'id_objet = ' . sql_quote($id_objet_lie)
)
]
);
$futurs = array_flip($ordre);
// ordre de 1 à n (pas de 0 à n).
array_walk($futurs, function(&$v) { $v++; });
array_walk($futurs, function (&$v) {
$v++;
});
$updates = array();
$updates = [];
foreach ($actuels as $l) {
if ($futurs[$l['id']] !== $l['rang_lien']) {
......@@ -72,21 +74,21 @@ function action_ordonner_liens_dist() {
foreach ($updates as $id => $ordre) {
sql_updateq(
$table_liens,
array('rang_lien' => $ordre),
array(
['rang_lien' => $ordre],
[
$_id_objet . ' = ' . $id,
'objet = ' . sql_quote($objet_lie),
'id_objet = ' . sql_quote($id_objet_lie)
)
]
);
}
}
return envoyer_json_envoi(array(
return envoyer_json_envoi([
'done' => true,
'success' => $success,
'errors' => $errors,
));
]);
}
function envoyer_json_envoi($data) {
......@@ -95,9 +97,9 @@ function envoyer_json_envoi($data) {
}
function envoyer_json_erreur($msg) {
return envoyer_json_envoi(array(
return envoyer_json_envoi([
'done' => false,
'success' => array(),
'errors' => array($msg)
));
'success' => [],
'errors' => [$msg]
]);
}
......@@ -30,7 +30,7 @@ function action_supprimer_document_dist($id_document = 0) {
// si c'etait une vignette, modifier le document source !
if ($source = sql_getfetsel('id_document', 'spip_documents', 'id_vignette=' . intval($id_document))) {
include_spip('action/editer_document');
document_modifier($source, array('id_vignette' => 0));
document_modifier($source, ['id_vignette' => 0]);
}
include_spip('inc/documents');
......@@ -46,7 +46,7 @@ function action_supprimer_document_dist($id_document = 0) {
// Si c'est un document ayant une vignette, supprimer aussi la vignette
if ($doc['id_vignette']) {
action_supprimer_document_dist($doc['id_vignette']);
objet_dissocier(array('document' => $doc['id_vignette']), '*');
objet_dissocier(['document' => $doc['id_vignette']], '*');
}
// Si c'est un document ayant des documents annexes (sous-titre, ...)
// les supprimer aussi
......@@ -59,7 +59,7 @@ function action_supprimer_document_dist($id_document = 0) {
}
// dereferencer dans la base
objet_dissocier(array('document' => $id_document), '*', array('role' => '*'));
objet_dissocier(['document' => $id_document], '*', ['role' => '*']);
sql_delete('spip_documents', 'id_document=' . intval($id_document));
......@@ -76,16 +76,16 @@ function action_supprimer_document_dist($id_document = 0) {
pipeline(
'post_edition',
array(
'args' => array(
[
'args' => [
'operation' => 'supprimer_document', // compat v<=2
'action' => 'supprimer_document',
'table' => 'spip_documents',
'id_objet' => $id_document,
'document' => $doc,
),
],
'data' => null
)
]
);
return true;
......
......@@ -24,7 +24,7 @@ function action_supprimer_tous_orphelins() {
//on recupere le contexte pour ne supprimer les orphelins que de ce dernier
list($media, $distant, $statut, $sanstitre) = explode('/', $arg);
$where = array();
$where = [];
//critere sur le media
if ($media) {
$select = 'media=' . sql_quote($media);
......
......@@ -104,12 +104,12 @@ function action_tourner_post($id_document, $angle) {
// succes !
if ($largeur > 0 and $hauteur > 0) {
$set = array(
$set = [
'fichier' => set_spip_doc($dest),
'largeur' => $largeur,
'hauteur' => $hauteur,
'distant' => 'non' // le document n'est plus distant apres une transformation
);
];
if ($taille = @filesize($dest)) {
$set['taille'] = $taille;
}
......@@ -121,18 +121,18 @@ function action_tourner_post($id_document, $angle) {
// pipeline pour les plugins
pipeline(
'post_edition',
array(
'args' => array(
[
'args' => [
'table' => 'spip_documents',
'table_objet' => 'documents',
'spip_table_objet' => 'spip_documents',
'type' => 'document',
'id_objet' => $id_document,
'champs' => array('rotation' => $angle, 'orientation' => $var_rot, 'fichier' => $row['fichier']),
'champs' => ['rotation' => $angle, 'orientation' => $var_rot, 'fichier' => $row['fichier']],
'action' => 'tourner',
),
],
'data' => $set
)
]
);
}
}
......@@ -142,7 +142,8 @@ function action_tourner_post($id_document, $angle) {
// https://code.spip.net/@tourner_selon_exif_orientation
function tourner_selon_exif_orientation($id_document, $fichier) {
if (function_exists('exif_read_data')
if (
function_exists('exif_read_data')
and $exif = exif_read_data($fichier)
and (
$ort = $exif['IFD0']['Orientation']
......@@ -161,7 +162,7 @@ function tourner_selon_exif_orientation($id_document, $fichier) {
$rot = -90;
}
if ($rot) {
action_tourner_post(array(null, $id_document, $rot));
action_tourner_post([null, $id_document, $rot]);
}
}
}
......@@ -29,7 +29,7 @@ function action_verifier_documents_brises_dist() {
$res = sql_select('fichier,brise,id_document', 'spip_documents', "distant='non'");
while ($row = sql_fetch($res)) {
if (($brise = !@file_exists(get_spip_doc($row['fichier']))) != $row['brise']) {
sql_updateq('spip_documents', array('brise' => $brise), 'id_document=' . intval($row['id_document']));
sql_updateq('spip_documents', ['brise' => $brise], 'id_document=' . intval($row['id_document']));
}
}
}
......
......@@ -36,5 +36,5 @@ function action_verifier_documents_liens_dist($id_document = null) {
$id_document = ($id_document == '*') ? '*' : intval($id_document);
include_spip('action/editer_liens');
objet_optimiser_liens(array('document' => $id_document), '*');
objet_optimiser_liens(['document' => $id_document], '*');
}
......@@ -30,13 +30,13 @@ function medias_declarer_tables_interfaces($interfaces) {
$interfaces['table_des_tables']['documents'] = 'documents';
$interfaces['table_des_tables']['types_documents'] = 'types_documents';
$interfaces['exceptions_des_tables']['documents']['type_document'] = array('types_documents', 'titre');
$interfaces['exceptions_des_tables']['documents']['extension_document'] = array('types_documents', 'extension');
$interfaces['exceptions_des_tables']['documents']['mime_type'] = array('types_documents', 'mime_type');
$interfaces['exceptions_des_tables']['documents']['media_document'] = array('types_documents', 'media');
$interfaces['exceptions_des_tables']['documents']['type_document'] = ['types_documents', 'titre'];
$interfaces['exceptions_des_tables']['documents']['extension_document'] = ['types_documents', 'extension'];
$interfaces['exceptions_des_tables']['documents']['mime_type'] = ['types_documents', 'mime_type'];
$interfaces['exceptions_des_tables']['documents']['media_document'] = ['types_documents', 'media'];
$interfaces['exceptions_des_jointures']['spip_documents']['id_forum'] = array('spip_documents_liens', 'id_forum');
$interfaces['exceptions_des_jointures']['spip_documents']['vu'] = array('spip_documents_liens', 'vu');
$interfaces['exceptions_des_jointures']['spip_documents']['id_forum'] = ['spip_documents_liens', 'id_forum'];
$interfaces['exceptions_des_jointures']['spip_documents']['vu'] = ['spip_documents_liens', 'vu'];
$interfaces['table_date']['types_documents'] = 'date';
$interfaces['table_des_traitements']['FICHIER'][] = 'get_spip_doc(%s)';
......@@ -53,7 +53,7 @@ function medias_declarer_tables_interfaces($interfaces) {
*/
function medias_declarer_tables_principales($tables_principales) {
$spip_types_documents = array(
$spip_types_documents = [
'extension' => "varchar(10) DEFAULT '' NOT NULL",
'titre' => "text DEFAULT '' NOT NULL",
'descriptif' => "text DEFAULT '' NOT NULL",
......@@ -62,15 +62,15 @@ function medias_declarer_tables_principales($tables_principales) {
'upload' => "ENUM('oui', 'non') DEFAULT 'oui' NOT NULL",
'media_defaut' => "varchar(10) DEFAULT 'file' NOT NULL",
'maj' => 'TIMESTAMP'
);
];
$spip_types_documents_key = array(
$spip_types_documents_key = [
'PRIMARY KEY' => 'extension',
'KEY inclus' => 'inclus'
);
];
$tables_principales['spip_types_documents'] =
array('field' => &$spip_types_documents, 'key' => &$spip_types_documents_key);
['field' => &$spip_types_documents, 'key' => &$spip_types_documents_key];
return $tables_principales;
}
......@@ -83,25 +83,25 @@ function medias_declarer_tables_principales($tables_principales) {
*/
function medias_declarer_tables_auxiliaires($tables_auxiliaires) {
$spip_documents_liens = array(
$spip_documents_liens = [
'id_document' => "bigint(21) DEFAULT '0' NOT NULL",
'id_objet' => "bigint(21) DEFAULT '0' NOT NULL",
'objet' => "VARCHAR (25) DEFAULT '' NOT NULL",
'vu' => "ENUM('non', 'oui') DEFAULT 'non' NOT NULL",
'rang_lien' => "int(4) DEFAULT '0' NOT NULL"
);
];
$spip_documents_liens_key = array(
$spip_documents_liens_key = [
'PRIMARY KEY' => 'id_document,id_objet,objet',
'KEY id_document' => 'id_document',
'KEY id_objet' => 'id_objet',
'KEY objet' => 'objet',
);
];
$tables_auxiliaires['spip_documents_liens'] = array(
$tables_auxiliaires['spip_documents_liens'] = [
'field' => &$spip_documents_liens,
'key' => &$spip_documents_liens_key
);
];
return $tables_auxiliaires;
}
......@@ -121,9 +121,9 @@ function medias_declarer_tables_objets_surnoms($surnoms) {
function medias_declarer_tables_objets_sql($tables) {
$tables['spip_articles']['champs_versionnes'][] = 'jointure_documents';
$tables['spip_documents'] = array(
'table_objet_surnoms' => array('doc', 'img', 'emb'),
'type_surnoms' => array(),
$tables['spip_documents'] = [
'table_objet_surnoms' => ['doc', 'img', 'emb'],
'type_surnoms' => [],
'url_voir' => 'document_edit',
'url_edit' => 'document_edit',
'page' => '',
......@@ -137,7 +137,7 @@ function medias_declarer_tables_objets_sql($tables) {
'titre' => "CASE WHEN length(titre)>0 THEN titre ELSE fichier END as titre, '' AS lang",
'date' => 'date',
'principale' => 'oui',
'field' => array(
'field' => [
'id_document' => 'bigint(21) NOT NULL',
'id_vignette' => "bigint(21) DEFAULT '0' NOT NULL",
'extension' => "VARCHAR(10) DEFAULT '' NOT NULL",
......@@ -158,34 +158,34 @@ function medias_declarer_tables_objets_sql($tables) {
'date_publication' => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL",
'brise' => 'tinyint DEFAULT 0',
'maj' => 'TIMESTAMP'
),
'key' => array(
],
'key' => [
'PRIMARY KEY' => 'id_document',
'KEY id_vignette' => 'id_vignette',
'KEY mode' => 'mode',
'KEY extension' => 'extension'
),
'join' => array(
],
'join' => [
'id_document' => 'id_document',
'extension' => 'extension'
),
'statut' => array(
array(
],
'statut' => [
[
'champ' => 'statut',
'publie' => 'publie',
'previsu' => 'publie,prop,prepa',
'post_date' => 'date_publication',
'exception' => array('statut', 'tout')
)
),
'tables_jointures' => array('types_documents'),
'rechercher_champs' => array(
'exception' => ['statut', 'tout']
]
],
'tables_jointures' => ['types_documents'],
'rechercher_champs' => [
'titre' => 3,
'descriptif' => 1,
'fichier' => 1,
'credits' => 1,
),
'champs_editables' => array(
],
'champs_editables' => [
'titre',
'descriptif',
'date',
......@@ -201,8 +201,8 @@ function medias_declarer_tables_objets_sql($tables) {
'extension',
'id_vignette',
'media'
),
'champs_versionnes' => array(
],
'champs_versionnes' => [
'id_vignette',
'titre',
'descriptif',
......@@ -214,17 +214,17 @@ function medias_declarer_tables_objets_sql($tables) {
'credits',
'fichier',
'distant'
),
'modeles' => array('document', 'doc', 'img', 'emb', 'image', 'video', 'audio', 'file'),
],
'modeles' => ['document', 'doc', 'img', 'emb', 'image', 'video', 'audio', 'file'],
'modeles_styliser' => 'medias_modeles_styliser',
);
];
// jointures sur les forum pour tous les objets
$tables[]['tables_jointures'][] = 'documents_liens';
// recherche jointe sur les documents pour les articles et rubriques
$tables['spip_articles']['rechercher_jointures']['document'] = array('titre' => 2, 'descriptif' => 1);
$tables['spip_rubriques']['rechercher_jointures']['document'] = array('titre' => 2, 'descriptif' => 1);
$tables['spip_articles']['rechercher_jointures']['document'] = ['titre' => 2, 'descriptif' => 1];
$tables['spip_rubriques']['rechercher_jointures']['document'] = ['titre' => 2, 'descriptif' => 1];
return $tables;
}
......@@ -243,13 +243,13 @@ function creer_base_types_doc($serveur = '', $champ_media = 'media_defaut') {
// charger en memoire tous les types deja definis pour limiter les requettes
$rows = sql_allfetsel('mime_type,titre,inclus,extension,' . $champ_media . ',upload,descriptif', 'spip_types_documents', '', '', '', '', '', $serveur);
$deja = array();
$deja = [];
foreach ($rows as $k => $row) {
$deja[$row['extension']] = &$rows[$k];
}
$insertions = array();
$updates = array();
$insertions = [];
$updates = [];
foreach ($tables_mime as $extension => $type_mime) {
if (isset($tables_images[$extension])) {
......@@ -271,18 +271,20 @@ function creer_base_types_doc($serveur = '', $champ_media = 'media_defaut') {
// type de media
$media = 'file';
if (preg_match(',^image/,', $type_mime) or in_array($type_mime, array('application/illustrator'))) {
if (preg_match(',^image/,', $type_mime) or in_array($type_mime, ['application/illustrator'])) {
$media = 'image';
} elseif (preg_match(',^audio/,', $type_mime)) {
$media = 'audio';
} elseif (preg_match(',^video/,', $type_mime) or in_array(
$type_mime,
array('application/ogg', 'application/x-shockwave-flash', 'application/mp4')
)) {
} elseif (
preg_match(',^video/,', $type_mime) or in_array(
$type_mime,
['application/ogg', 'application/x-shockwave-flash', 'application/mp4']
)
) {
$media = 'video';
}
$set = array(
$set = [
'mime_type' => $type_mime,
'titre' => $titre,
'inclus' => $inclus,
......@@ -290,7 +292,7 @@ function creer_base_types_doc($serveur = '', $champ_media = 'media_defaut') {
$champ_media => $media,
'upload' => 'oui',
'descriptif' => '',
);
];
if (!isset($deja[$extension])) {
$insertions[] = $set;
} elseif (array_diff($deja[$extension], $set)) {
......@@ -322,15 +324,17 @@ function medias_optimiser_base_disparus($flux) {
// optimiser les liens morts :
// entre documents vers des objets effaces
// depuis des documents effaces
$flux['data'] += objet_optimiser_liens(array('document' => '*'), '*');
$flux['data'] += objet_optimiser_liens(['document' => '*'], '*');
// on ne nettoie volontairement pas automatiquement les documents orphelins
// mais il faut nettoyer les logos qui ne sont plus liés à rien
$res = sql_select("D.id_document",
"spip_documents AS D
$res = sql_select(
'D.id_document',
'spip_documents AS D
LEFT JOIN spip_documents_liens AS L
ON (L.id_document=D.id_document)",
sql_in('D.mode', ['logoon', 'logooff']) . " AND L.id_document IS NULL");
ON (L.id_document=D.id_document)',
sql_in('D.mode', ['logoon', 'logooff']) . ' AND L.id_document IS NULL'
);
$supprimer_document = charger_fonction('supprimer_document', 'action');
while ($row = sql_fetch($res)) {
......
......@@ -16,7 +16,7 @@ if (!defined('_ECRIRE_INC_VERSION')) {
global $tables_images, $tables_sequences, $tables_documents, $tables_mime, $mime_alias;
$tables_images = array(
$tables_images = [
// Images reconnues par PHP
'jpg' => 'JPEG',
'png' => 'PNG',
......@@ -26,11 +26,11 @@ $tables_images = array(
// Autres images (peuvent utiliser le tag <img>)
'bmp' => 'BMP',
'svg' => 'SVG',
);
];
// Multimedia (peuvent utiliser le tag <embed>)
$tables_sequences = array(
$tables_sequences = [
'aac' => 'Advanced Audio Coding',
'ac3' => 'AC-3 Compressed Audio',
'aifc' => 'Compressed AIFF Audio',
......@@ -86,10 +86,10 @@ $tables_sequences = array(
'y4m' => 'YUV4MPEG2',
'3ga' => '3GP Audio File',
'3gp' => '3rd Generation Partnership Project'
);
];
// Documents varies
$tables_documents = array(
$tables_documents = [
'7z' => '7 Zip',
'abw' => 'Abiword',
'ai' => 'Adobe Illustrator',
......@@ -210,9 +210,9 @@ $tables_documents = array(
'xlsx' => 'Excel',
'xltm' => 'Excel template',
'xltx' => 'Excel template'
);
];
$tables_mime = array(
$tables_mime = [
// Images reconnues par PHP
'jpg' => 'image/jpeg',
'png' => 'image/png',
......@@ -399,10 +399,10 @@ $tables_mime = array(
'xlsx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet',
'xltm' => 'application/vnd.ms-excel.template.macroEnabled.12',
'xltx' => 'application/vnd.openxmlformats-officedocument.spreadsheetml.template'
);
];
$mime_alias = array(
$mime_alias = [
'application/x-ogg' => 'application/ogg',
'audio/3gpp' => 'video/3gpp',
'audio/x-mpeg' => 'audio/mpeg',
......@@ -411,4 +411,4 @@ $mime_alias = array(
'video/flv' => 'video/x-flv',
'video/mp4' => 'application/mp4',
'image/jpg' => 'image/jpeg'
);
];
......@@ -17,7 +17,7 @@ if (!defined('_ECRIRE_INC_VERSION')) {
function formulaires_changer_fichier_document_charger_dist($id_document) {
$valeurs = sql_fetsel('id_document,fichier,distant', 'spip_documents', 'id_document=' . intval($id_document));
if (!$valeurs) {
return array('editable' => false);
return ['editable' => false];
}
$charger = charger_fonction('charger', 'formulaires/joindre_document');
......@@ -29,7 +29,7 @@ function formulaires_changer_fichier_document_charger_dist($id_document) {
}
function formulaires_changer_fichier_document_verifier_dist($id_document) {
$erreurs = array();
$erreurs = [];
if (_request('copier_local')) {
} else {
$verifier = charger_fonction('verifier', 'formulaires/joindre_document');
......@@ -42,7 +42,7 @@ function formulaires_changer_fichier_document_verifier_dist($id_document) {
function formulaires_changer_fichier_document_traiter_dist($id_document) {
if (_request('copier_local')) {
$copier_local = charger_fonction('copier_local', 'action');
$res = array('editable' => true);
$res = ['editable' => true];
if (($err = $copier_local($id_document)) === true) {
$res['message_ok'] = _T('medias:document_copie_locale_succes');
} else {
......@@ -50,7 +50,8 @@ function formulaires_changer_fichier_document_traiter_dist($id_document) {
}
} else {
// liberer le nom de l'ancien fichier pour permettre le remplacement par un fichier du meme nom
if ($ancien_fichier = sql_getfetsel('fichier', 'spip_documents', 'id_document=' . intval($id_document))
if (
$ancien_fichier = sql_getfetsel('fichier', 'spip_documents', 'id_document=' . intval($id_document))
and @file_exists($f = get_spip_doc($ancien_fichier))
) {
spip_unlink($f);
......
......@@ -27,11 +27,13 @@ if (!defined('_ECRIRE_INC_VERSION')) {
* Environnement du formulaire
**/
function formulaires_configurer_documents_charger_dist() {
$valeurs = array();
foreach (array(
$valeurs = [];
foreach (
[
'documents_objets',
'documents_date',
) as $m) {
] as $m
) {
$valeurs[$m] = isset($GLOBALS['meta'][$m]) ? $GLOBALS['meta'][$m] : '';
}
$valeurs['documents_objets'] = explode(',', $valeurs['documents_objets']);
......@@ -46,7 +48,7 @@ function formulaires_configurer_documents_charger_dist() {
* Retours du traitement
**/
function formulaires_configurer_documents_traiter_dist() {
$res = array('editable' => true);
$res = ['editable' => true];
if (!is_null($v = _request($m = 'documents_date'))) {
ecrire_meta($m, $v == 'oui' ? 'oui' : 'non');
}
......
......@@ -25,7 +25,7 @@ function formulaires_editer_document_charger_dist(
$retour = '',
$lier_trad = 0,
$config_fonc = 'documents_edit_config',
$row = array(),
$row = [],
$hidden = ''
) {
$valeurs = formulaires_editer_objet_charger('document', $id_document, $id_parent, $lier_trad, $retour, $config_fonc, $row, $hidden);
......@@ -36,11 +36,11 @@ function formulaires_editer_document_charger_dist(
}
// relier les parents
$valeurs['parents'] = array();
$valeurs['parents'] = [];
$valeurs['_hidden'] = '';
$parents = sql_allfetsel('objet,id_objet', 'spip_documents_liens', 'id_document=' . intval($id_document));
foreach ($parents as $p) {
if (in_array($p['objet'], array('article', 'rubrique')) and $p['id_objet'] > 0) {
if (in_array($p['objet'], ['article', 'rubrique']) and $p['id_objet'] > 0) {
$valeurs['parents'][] = $p['objet'] . '|' . $p['id_objet'];
} else {
$valeurs['_hidden'] .= "<input type='hidden' name='parents[]' value='" . $p['objet'] . '|' . $p['id_objet'] . "' />";
......@@ -66,7 +66,7 @@ function formulaires_editer_document_charger_dist(
);
$valeurs['type_document'] = $row['type_document'];
$valeurs['_inclus'] = $row['inclus'];
if (in_array($valeurs['extension'], array('jpg', 'gif', 'png', 'svg'))) {
if (in_array($valeurs['extension'], ['jpg', 'gif', 'png', 'svg'])) {
$valeurs['apercu'] = get_spip_doc($valeurs['fichier']);
}
......@@ -76,7 +76,8 @@ function formulaires_editer_document_charger_dist(
include_spip('inc/renseigner_document');
$infos = renseigner_taille_dimension_image(get_spip_doc($valeurs['fichier']), $valeurs['extension']);
if ($infos and is_array($infos) and isset($infos['taille'])) {
if ($infos['taille'] != $valeurs['taille']
if (
$infos['taille'] != $valeurs['taille']
or ($infos['type_image'] && ($infos['largeur'] != $valeurs['largeur']))
or ($infos['type_image'] && ($infos['hauteur'] != $valeurs['hauteur']))
) {
......@@ -106,7 +107,7 @@ function formulaires_editer_document_charger_dist(
function documents_edit_config($row) {
global $spip_lang;
$config = array();//$GLOBALS['meta'];
$config = [];//$GLOBALS['meta'];
$config['lignes'] = 8;
$config['langue'] = $spip_lang;
......@@ -121,10 +122,10 @@ function formulaires_editer_document_verifier_dist(
$retour = '',
$lier_trad = 0,
$config_fonc = 'documents_edit_config',
$row = array(),
$row = [],
$hidden = ''
) {
$erreurs = formulaires_editer_objet_verifier('document', $id_document, is_numeric($id_document) ? array() : array('titre'));
$erreurs = formulaires_editer_objet_verifier('document', $id_document, is_numeric($id_document) ? [] : ['titre']);
// verifier l'upload si on a demande a changer le document
if (_request('joindre_upload') or _request('joindre_ftp') or _request('joindre_distant')) {
......@@ -137,7 +138,8 @@ function formulaires_editer_document_verifier_dist(
// On ne vérifie la date que si on avait le droit de la modifier
if (lire_config('documents_date') == 'oui') {
if (!$date = recup_date(_request('saisie_date') . ' ' . _request('saisie_heure') . ':00')
if (
!$date = recup_date(_request('saisie_date') . ' ' . _request('saisie_heure') . ':00')
or !($date = mktime($date[3], $date[4], 0, $date[1], $date[2], $date[0]))
) {
$erreurs['saisie_date'] = _T('medias:format_date_incorrect');
......@@ -158,16 +160,16 @@ function formulaires_editer_document_traiter_dist(
$retour = '',
$lier_trad = 0,
$config_fonc = 'documents_edit_config',
$row = array(),
$row = [],
$hidden = ''
) {
if (is_null(_request('parents'))) {
set_request('parents', array());
set_request('parents', []);
}
// verifier les infos de taille et dimensions sur les fichiers locaux
// cas des maj de fichier directes par ftp
foreach (array('taille', 'largeur', 'hauteur') as $c) {
foreach (['taille', 'largeur', 'hauteur'] as $c) {
if (($v = _request("_{$c}_modif")) and !_request($c)) {
set_request($c, $v);
}
......@@ -176,7 +178,8 @@ function formulaires_editer_document_traiter_dist(
$res = formulaires_editer_objet_traiter('document', $id_document, $id_parent, $lier_trad, $retour, $config_fonc, $row, $hidden);
set_request('parents');
$autoclose = "<script type='text/javascript'>if (window.jQuery) jQuery.modalboxclose();</script>";
if (_request('copier_local')
if (
_request('copier_local')
or _request('joindre_upload')
or _request('joindre_ftp')
or _request('joindre_distant')
......@@ -185,7 +188,7 @@ function formulaires_editer_document_traiter_dist(
$autoclose = '';
if (_request('copier_local')) {
$copier_local = charger_fonction('copier_local', 'action');
$res = array('editable' => true);
$res = ['editable' => true];
if (($err = $copier_local($id_document)) === true) {
$res['message_ok'] = (isset($res['message_ok']) ? $res['message_ok'] . '<br />' : '') . _T('medias:document_copie_locale_succes');
} else {
......@@ -194,7 +197,8 @@ function formulaires_editer_document_traiter_dist(
set_request('credits'); // modifie par la copie locale
} else {
// liberer le nom de l'ancien fichier pour permettre le remplacement par un fichier du meme nom
if ($ancien_fichier = sql_getfetsel('fichier', 'spip_documents', 'id_document=' . intval($id_document))
if (
$ancien_fichier = sql_getfetsel('fichier', 'spip_documents', 'id_document=' . intval($id_document))
and !tester_url_absolue($ancien_fichier)
and @file_exists($rename = get_spip_doc($ancien_fichier))
) {
......