diff --git a/.gitattributes b/.gitattributes index 17e9adf564cd8f8af742640b31d5dd471845f0b6..1abba21f8eab2434bee59ac54de6583b32ecbc7b 100644 --- a/.gitattributes +++ b/.gitattributes @@ -195,6 +195,7 @@ dist/images/suivi-forum-24.gif -text dist/images/suivi-petition-24.gif -text dist/images/supprimer.gif -text dist/images/synchro-24.gif -text +dist/images/telecharger.gif -text dist/images/test.gif -text dist/images/test.jpg -text dist/images/test.png -text @@ -346,6 +347,7 @@ ecrire/action/acceder_document.php -text ecrire/action/activer_plugins.php -text ecrire/action/configurer.php -text ecrire/action/converser.php -text +ecrire/action/copier_local.php -text ecrire/action/dater.php -text ecrire/action/desinstaller_plugin.php -text ecrire/action/documenter.php -text @@ -463,6 +465,7 @@ ecrire/exec/configurer.php -text ecrire/exec/controle_forum.php -text ecrire/exec/controle_petition.php -text ecrire/exec/convert_utf8.php -text +ecrire/exec/copier_local.php -text ecrire/exec/dater.php -text ecrire/exec/delete_all.php -text ecrire/exec/demande_mise_a_jour.php -text diff --git a/dist/images/telecharger.gif b/dist/images/telecharger.gif new file mode 100644 index 0000000000000000000000000000000000000000..9c1ae78cc34c08c5c54d94b073cc84322a54b100 Binary files /dev/null and b/dist/images/telecharger.gif differ diff --git a/ecrire/action/copier_local.php b/ecrire/action/copier_local.php new file mode 100644 index 0000000000000000000000000000000000000000..e42c85da5a7bcde7e826cb75438a5e0ca603951d --- /dev/null +++ b/ecrire/action/copier_local.php @@ -0,0 +1,61 @@ +<?php + +/***************************************************************************\ + * SPIP, Systeme de publication pour l'internet * + * * + * Copyright (c) 2001-2007 * + * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * + * * + * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * + * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * +\***************************************************************************/ + +if (!defined("_ECRIRE_INC_VERSION")) return; + +// Fonction appellee lorsque l'utilisateur clique sur le bouton +// 'copier en local' (document/portfolio). +// Il s'agit de la partie logique, c'est a dire que cette fonction +// realise la copie. + +// http://doc.spip.org/@action_copier_local_dist +function action_copier_local_dist() { + + // Recupere les arguments. + $securiser_action = charger_fonction('securiser_action', 'inc'); + $arg = $securiser_action(); + + $id_document = intval($arg); + + if (!$id_document) { + spip_log("action_copier_local_dist $arg pas compris"); + } else { + // arguments recuperes, on peut maintenant appeler la fonction. + action_copier_local_post($id_document); + } +} + +// http://doc.spip.org/@action_copier_local_post +function action_copier_local_post($id_document) { + + // Il faut la source du document pour le copier + $s = spip_query("SELECT fichier FROM spip_documents WHERE id_document=$id_document"); + $row = spip_fetch_array($s); + $source = $row['fichier']; + + include_spip('inc/distant'); // pour 'copie_locale' + include_spip('inc/documents'); // pour 'set_spip_doc' + + if ($fichier = copie_locale($source)) { + // $fichier contient IMG/distant/... + // or, dans la table documents, IMG doit etre exclu. + $taille = filesize($fichier); + $fichier = set_spip_doc($fichier); + spip_log("convertit doc $id_document en local: $source => $fichier"); + spip_query("UPDATE spip_documents SET fichier="._q($fichier).", distant='non', taille='$taille' WHERE id_document=".$id_document); + + } else { + spip_log("echec copie locale $source"); + } +} + +?> diff --git a/ecrire/exec/copier_local.php b/ecrire/exec/copier_local.php new file mode 100644 index 0000000000000000000000000000000000000000..608c88c06a8e555f25cfa5d6a6fe99f182c2c3d6 --- /dev/null +++ b/ecrire/exec/copier_local.php @@ -0,0 +1,28 @@ +<?php + +/***************************************************************************\ + * SPIP, Systeme de publication pour l'internet * + * * + * Copyright (c) 2001-2007 * + * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James * + * * + * Ce programme est un logiciel libre distribue sous licence GNU/GPL. * + * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. * +\***************************************************************************/ + +if (!defined("_ECRIRE_INC_VERSION")) return; + +// http://doc.spip.org/@exec_copier_local_dist +function exec_copier_local_dist() +{ + global $id_document, $script, $id, $type, $ancre; + $id = intval($id); + $id_document = intval($id_document); + + // oui, ca parait bizarre d'appeler tourner, mais en fait la copie locale est + // etroitement liee a la mise en page des icones 'tourner' + $tourner = charger_fonction('tourner', 'inc'); + ajax_retour($tourner($id_document, array(), $script, 'ajax', $type)); +} + +?> diff --git a/ecrire/inc/documents.php b/ecrire/inc/documents.php index cf74e08861d7ae777c0ee6ea2828d03c2eb60f68..375c8e3e0a6bac086327cf3471e2f9131b892cae 100644 --- a/ecrire/inc/documents.php +++ b/ecrire/inc/documents.php @@ -331,10 +331,19 @@ function afficher_case_document($id_document, $id, $script, $type, $deplier=fals $ret .= "<a id='document$id_document' name='document$id_document'></a>\n"; $ret .= debut_cadre_enfonce("doc-24.gif", true, "", lignes_longues(typo($cadre),20)); - // Signaler les documents distants par une icone de trombone - $dist = ($document['distant'] == 'oui') - ? "\n<img src='"._DIR_IMG_PACK.'attachment.gif'."'\n\t style='float: $spip_lang_right;'\n\talt=\"$fichier\"\n\ttitle=\"$fichier\" />\n" - :''; + if ($document['distant'] == 'oui') { + $dist = "\n<div class='verdana1' style='float: $spip_lang_right; text-align: $spip_lang_right;'>"; + + // Signaler les documents distants par une icone de trombone + $dist .= "\n<img src='"._DIR_IMG_PACK.'attachment.gif'."'\n\talt=\"$fichier\"\n\ttitle=\"$fichier\" />\n"; + // Bouton permettant de copier en local le fichier + include_spip('inc/tourner'); + $dist .= bouton_copier_local($document, $type, $id, $id_document, $script); + + $dist .="</div>\n"; + } else { + $dist = ''; + } // // Affichage de la vignette diff --git a/ecrire/inc/tourner.php b/ecrire/inc/tourner.php index d3900f860257663d10556b07e55be2448d87af50..64d3ebd94cbb78d88bdd5eb221baf9b538df96ec 100644 --- a/ecrire/inc/tourner.php +++ b/ecrire/inc/tourner.php @@ -58,8 +58,14 @@ function inc_tourner_dist($id_document, $document, $script, $flag, $type) $boite = ''; } else { - // Signaler les documents distants par une icone de trombone - $boite = "\n<img src='"._DIR_IMG_PACK.'attachment.gif'."'\n\t style='float: $spip_lang_right;'\n\talt=\"$fichier\"\n\ttitle=\"$fichier\" />\n"; + $res = "\n<div class='verdana1' style='float: $spip_lang_right; text-align: $spip_lang_right;'>"; + + // Signaler les documents distants par une icone de trombone + $res .= "<img src='"._DIR_IMG_PACK.'attachment.gif'."'\n\t \n\talt=\"$fichier\"\n\ttitle=\"$fichier\" />\n"; + // Bouton permettant de copier en local le fichier + $res .= bouton_copier_local($document, $type, $id, $id_document, $script); + + $res .= "</div>\n"; } $res .= "<div style='text-align: center;'>"; @@ -70,8 +76,6 @@ function inc_tourner_dist($id_document, $document, $script, $flag, $type) . $id_document . "></div>"; - if ($boite) return "$boite<div>$res</div>"; - return ajax_action_greffe("tourner-$id_document", $res, ''); } @@ -118,4 +122,31 @@ function bouton_tourner_document($id, $id_document, $script, $rot, $type, $img, " class='bouton_rotation'"), "&id_document=$id_document&id=$id&type=$type"); } + +// Retourne le code HTML du bouton "copier en local". +// http://doc.spip.org/@bouton_copier_local +function bouton_copier_local($document, $type, $id, $id_document, $script) { + global $spip_lang_right; + + // pour etre sur qu'il s'agit bien d'un doc distant + // et qu'il existe + $bouton_copier = ''; + if ($document['distant'] == 'oui' /* on pourrait verifier l'existence du + // fichier ici, mais ne risque pas-t-on de degrader les performances ? + // il sera toujours temps de le verifier lorsque l'utilisateur cliquera + // sur le bouton. */) { + $bouton_copier = ajax_action_auteur("copier_local", + "$id_document", + $script, + "show_docs=$id_document&id_$type=$id#tourner-$id_document", + array(http_img_pack('telecharger.gif', _T('copier_en_local'), ''), + " class='bouton_rotation'"), + // on aurait pu faire un nouveau style 'bouton-telecharger', + // mais pour l'instant on se contente de reutiliser celui-ci + // afin de garder une homogeneite entre les differents boutons. + "&id_document=$id_document&id=$id&type=$type"); + + } + return $bouton_copier; +} ?>