Skip to content
Extraits de code Groupes Projets
Valider a99451d1 rédigé par Fil's avatar Fil
Parcourir les fichiers

bouton pour telecharger un document distant et le transformer en document...

bouton pour telecharger un document distant et le transformer en document local (#677, patch complet donne par tristan)
parent d0633021
Aucune branche associée trouvée
Aucune étiquette associée trouvée
Aucune requête de fusion associée trouvée
...@@ -195,6 +195,7 @@ dist/images/suivi-forum-24.gif -text ...@@ -195,6 +195,7 @@ dist/images/suivi-forum-24.gif -text
dist/images/suivi-petition-24.gif -text dist/images/suivi-petition-24.gif -text
dist/images/supprimer.gif -text dist/images/supprimer.gif -text
dist/images/synchro-24.gif -text dist/images/synchro-24.gif -text
dist/images/telecharger.gif -text
dist/images/test.gif -text dist/images/test.gif -text
dist/images/test.jpg -text dist/images/test.jpg -text
dist/images/test.png -text dist/images/test.png -text
...@@ -346,6 +347,7 @@ ecrire/action/acceder_document.php -text ...@@ -346,6 +347,7 @@ ecrire/action/acceder_document.php -text
ecrire/action/activer_plugins.php -text ecrire/action/activer_plugins.php -text
ecrire/action/configurer.php -text ecrire/action/configurer.php -text
ecrire/action/converser.php -text ecrire/action/converser.php -text
ecrire/action/copier_local.php -text
ecrire/action/dater.php -text ecrire/action/dater.php -text
ecrire/action/desinstaller_plugin.php -text ecrire/action/desinstaller_plugin.php -text
ecrire/action/documenter.php -text ecrire/action/documenter.php -text
...@@ -463,6 +465,7 @@ ecrire/exec/configurer.php -text ...@@ -463,6 +465,7 @@ ecrire/exec/configurer.php -text
ecrire/exec/controle_forum.php -text ecrire/exec/controle_forum.php -text
ecrire/exec/controle_petition.php -text ecrire/exec/controle_petition.php -text
ecrire/exec/convert_utf8.php -text ecrire/exec/convert_utf8.php -text
ecrire/exec/copier_local.php -text
ecrire/exec/dater.php -text ecrire/exec/dater.php -text
ecrire/exec/delete_all.php -text ecrire/exec/delete_all.php -text
ecrire/exec/demande_mise_a_jour.php -text ecrire/exec/demande_mise_a_jour.php -text
......
dist/images/telecharger.gif

112 octets

<?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");
}
}
?>
<?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));
}
?>
...@@ -331,10 +331,19 @@ function afficher_case_document($id_document, $id, $script, $type, $deplier=fals ...@@ -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 .= "<a id='document$id_document' name='document$id_document'></a>\n";
$ret .= debut_cadre_enfonce("doc-24.gif", true, "", lignes_longues(typo($cadre),20)); $ret .= debut_cadre_enfonce("doc-24.gif", true, "", lignes_longues(typo($cadre),20));
// Signaler les documents distants par une icone de trombone if ($document['distant'] == 'oui') {
$dist = ($document['distant'] == 'oui') $dist = "\n<div class='verdana1' style='float: $spip_lang_right; text-align: $spip_lang_right;'>";
? "\n<img src='"._DIR_IMG_PACK.'attachment.gif'."'\n\t style='float: $spip_lang_right;'\n\talt=\"$fichier\"\n\ttitle=\"$fichier\" />\n"
:''; // 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 // Affichage de la vignette
......
...@@ -58,8 +58,14 @@ function inc_tourner_dist($id_document, $document, $script, $flag, $type) ...@@ -58,8 +58,14 @@ function inc_tourner_dist($id_document, $document, $script, $flag, $type)
$boite = ''; $boite = '';
} else { } else {
// Signaler les documents distants par une icone de trombone $res = "\n<div class='verdana1' style='float: $spip_lang_right; text-align: $spip_lang_right;'>";
$boite = "\n<img src='"._DIR_IMG_PACK.'attachment.gif'."'\n\t style='float: $spip_lang_right;'\n\talt=\"$fichier\"\n\ttitle=\"$fichier\" />\n";
// 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;'>"; $res .= "<div style='text-align: center;'>";
...@@ -70,8 +76,6 @@ function inc_tourner_dist($id_document, $document, $script, $flag, $type) ...@@ -70,8 +76,6 @@ function inc_tourner_dist($id_document, $document, $script, $flag, $type)
. $id_document . $id_document
. "&gt;</div>"; . "&gt;</div>";
if ($boite) return "$boite<div>$res</div>";
return ajax_action_greffe("tourner-$id_document", $res, ''); return ajax_action_greffe("tourner-$id_document", $res, '');
} }
...@@ -118,4 +122,31 @@ function bouton_tourner_document($id, $id_document, $script, $rot, $type, $img, ...@@ -118,4 +122,31 @@ function bouton_tourner_document($id, $id_document, $script, $rot, $type, $img,
" class='bouton_rotation'"), " class='bouton_rotation'"),
"&id_document=$id_document&id=$id&type=$type"); "&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;
}
?> ?>
0% Chargement en cours ou .
You are about to add 0 people to the discussion. Proceed with caution.
Terminez d'abord l'édition de ce message.
Veuillez vous inscrire ou vous pour commenter