X-Git-Url: http://git.cyclocoop.org/?p=velocampus%2Fweb%2Fwww.git;a=blobdiff_plain;f=www%2Fecrire%2Finc%2Ftourner.php;fp=www%2Fecrire%2Finc%2Ftourner.php;h=161610907ca5fd7a6112fb447e59885eee684896;hp=0000000000000000000000000000000000000000;hb=80b4d3e85f78d402ed2e73f8f5d1bf4c19962eed;hpb=aaf970bf4cdaf76689ecc10609048e18d073820c
diff --git a/www/ecrire/inc/tourner.php b/www/ecrire/inc/tourner.php
new file mode 100644
index 0000000..1616109
--- /dev/null
+++ b/www/ecrire/inc/tourner.php
@@ -0,0 +1,159 @@
+basename($document['fichier'])));
+ $res = "";
+ } else {
+ if ($flag AND !$id_vignette)
+ $res = boutons_rotateurs($document, $type, $id, $id_document,$script);
+ }
+ } else {
+ $res = "\n
";
+
+ // Signaler les documents distants par une icone de trombone
+ $res .= "
\n";
+ // Bouton permettant de copier en local le fichier
+ $res .= bouton_copier_local($document, $type, $id, $id_document, $script);
+
+ $res .= "
\n";
+ }
+ return tourner_greffe($id_document, $document, $url, $res);
+}
+
+// http://doc.spip.org/@tourner_greffe
+function tourner_greffe($id_document, $document, $url, $res)
+{
+ $res .= ""
+ .document_et_vignette($document, $url, true)
+ ."
\n"
+ ."<doc"
+ . $id_document
+ . ">
";
+
+ return ajax_action_greffe("tourner", $id_document, $res);
+}
+
+// http://doc.spip.org/@boutons_rotateurs
+function boutons_rotateurs($document, $type, $id, $id_document, $script) {
+ global $spip_lang_right;
+
+ $process = $GLOBALS['meta']['image_process'];
+
+ // bloc rotation de l'image
+ // si c'est une image, qu'on sait la faire tourner, qu'elle
+ // n'est pas distante, qu'elle est bien presente dans IMG/
+ // qu'elle n'a pas de vignette perso ; et qu'on a la bibli !
+ if ($document['distant']!='oui'
+ AND in_array($document['extension'], array('gif', 'jpg', 'png'))
+ AND (strpos($GLOBALS['meta']['formats_graphiques'], $document['extension'])!==false)
+ AND ($process == 'imagick'
+ OR $process == 'gd2'
+ OR $process == 'convert'
+ OR $process == 'netpbm')
+ AND @file_exists(get_spip_doc($document['fichier']))
+ ) {
+
+ return "\n" .
+
+ bouton_tourner_document($id, $id_document, $script, -90, $type, 'tourner-gauche-10.gif', _T('image_tourner_gauche')) .
+
+ bouton_tourner_document($id, $id_document, $script, 90, $type, 'tourner-droite-10.gif', _T('image_tourner_droite')) .
+
+ bouton_tourner_document($id, $id_document, $script, 180, $type, 'tourner-demitour-10.gif', _T('image_tourner_180')) .
+ "
\n";
+ }
+}
+
+// http://doc.spip.org/@bouton_tourner_document
+function bouton_tourner_document($id, $id_document, $script, $rot, $type, $img, $title)
+{
+ return ajax_action_auteur("tourner",
+ "$id_document-$rot",
+ $script,
+ "show_docs=$id_document&id_$type=$id#tourner-$id_document",
+ array(http_img_pack($img, $title, ''),
+ " 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");
+
+
+ // Hack ?
+ // demander confirmation javascript
+ $u = str_replace("'", "\\'", unicode_to_javascript(html2unicode(_T('copier_en_local') . ' ' . $document['fichier'])));
+ $bouton_copier = str_replace('return AjaxSqueeze',
+ "return (!confirm('$u'))?false:AjaxSqueeze", $bouton_copier);
+ }
+
+ return $bouton_copier;
+}
+?>