From 06a6e7f01a68e9bc797c3145f8b936dcafd2a638 Mon Sep 17 00:00:00 2001 From: "Committo,Ergo:sum" <esj@rezo.net> Date: Mon, 25 Sep 2006 11:02:52 +0000 Subject: [PATCH] Suite de [7446]: les formulaires Tourner et Legender deviennent surchargeables. --- .gitattributes | 2 + ecrire/fragments/legender.php | 6 +- ecrire/fragments/tourner.php | 5 +- ecrire/inc/documenter.php | 21 +-- ecrire/inc/documents.php | 284 +--------------------------------- ecrire/inc/legender.php | 203 ++++++++++++++++++++++++ ecrire/inc/tourner.php | 115 ++++++++++++++ 7 files changed, 339 insertions(+), 297 deletions(-) create mode 100644 ecrire/inc/legender.php create mode 100644 ecrire/inc/tourner.php diff --git a/.gitattributes b/.gitattributes index e1ca167c96..b66f74c497 100644 --- a/.gitattributes +++ b/.gitattributes @@ -452,6 +452,7 @@ ecrire/inc/install_ldap4.php -text ecrire/inc/install_ldap5.php -text ecrire/inc/install_unpack.php -text ecrire/inc/lang_liste.php -text +ecrire/inc/legender.php -text ecrire/inc/maintenance.php -text ecrire/inc/message_select.php -text ecrire/inc/mini_nav.php -text @@ -464,6 +465,7 @@ ecrire/inc/referencer_traduction.php -text ecrire/inc/sites_voir.php -text ecrire/inc/suivi_versions.php -text ecrire/inc/syndic.php -text +ecrire/inc/tourner.php -text ecrire/inc/utils.php -text ecrire/inc/virtualiser.php -text ecrire/lang/ecrire_br.php -text diff --git a/ecrire/fragments/legender.php b/ecrire/fragments/legender.php index 274c798a94..3d6ee63f73 100644 --- a/ecrire/fragments/legender.php +++ b/ecrire/fragments/legender.php @@ -26,9 +26,7 @@ function fragments_legender_dist() minipres(_T('info_acces_interdit')); } - include_spip('inc/documents'); - include_spip('inc/presentation'); - - return formulaire_legender($id_document, array(), $script, $type, $id, $ancre); + $f = charger_fonction('legender', 'inc'); + return $f($id_document, array(), $script, $type, $id, $ancre); } ?> diff --git a/ecrire/fragments/tourner.php b/ecrire/fragments/tourner.php index da97affce0..6a8716f857 100644 --- a/ecrire/fragments/tourner.php +++ b/ecrire/fragments/tourner.php @@ -27,10 +27,9 @@ function fragments_tourner_dist() minipres(_T('info_acces_interdit')); } - include_spip('inc/documents'); - include_spip('inc/presentation'); + $f = charger_fonction('tourner', 'inc'); - return formulaire_tourner($id_document, array(), $script, 'ajax', $type); + return $f($id_document, array(), $script, 'ajax', $type); } ?> diff --git a/ecrire/inc/documenter.php b/ecrire/inc/documenter.php index 90958e963b..f4aa04a979 100644 --- a/ecrire/inc/documenter.php +++ b/ecrire/inc/documenter.php @@ -42,13 +42,16 @@ function inc_documenter_dist( } else $documents = $doc; if (!$documents) return ''; - include_spip('inc/documents'); + charger_generer_url(); // la derniere case d'une rangee $bord_droit = ($ancre == 'portfolio' ? 2 : 1); $case = 0; $res = ''; + $tourner = charger_fonction('tourner', 'inc'); + $legender = charger_fonction('legender', 'inc'); + foreach ($documents as $document) { $id_document = $document['id_document']; @@ -64,16 +67,14 @@ function inc_documenter_dist( $res .= "<tr style='border-top: 1px solid black;'>"; else if ($case == $bord_droit) $style .= " border-$spip_lang_right: 1px solid $couleur;"; - $res .= "\n<td style='width:33%; text-align: $spip_lang_left; border-$spip_lang_left: 1px solid $couleur; border-bottom: 1px solid $couleur; $style' valign='top'>"; - - $res .= formulaire_tourner($id_document, $document, $script, $flag_modif, $type); - - if ($flag_modif) - $res .= formulaire_legender($id_document, $document, $script, $type, $document["id_$type"], $ancre); + $res .= "\n<td style='width:33%; text-align: $spip_lang_left; border-$spip_lang_left: 1px solid $couleur; border-bottom: 1px solid $couleur; $style' valign='top'>" + . $tourner($id_document, $document, $script, $flag_modif, $type) + . (!$flag_modif ? '' : + $legender($id_document, $document, $script, $type, $document["id_$type"], $ancre)) + . (!isset($document['info']) ? '' : + ("<div class='verdana1'>".$document['info']."</div>")) + . "</td>\n"; - if (isset($document['info'])) - $res .= "<div class='verdana1'>".$document['info']."</div>"; - $res .= "</td>\n"; $case++; if ($case > $bord_droit) { diff --git a/ecrire/inc/documents.php b/ecrire/inc/documents.php index 670b113b03..bfc245a47a 100644 --- a/ecrire/inc/documents.php +++ b/ecrire/inc/documents.php @@ -164,42 +164,6 @@ function texte_upload_manuel($dir, $inclus = '', $mode = 'document') { } -// Bloc d'edition de la taille du doc (pour embed) -// http://doc.spip.org/@formulaire_taille -function formulaire_taille($document) { - - // (on ne le propose pas pour les images qu'on sait - // lire, id_type<=3), sauf bug, ou document distant - if ($document['id_type'] <= 3 - AND $document['hauteur'] - AND $document['largeur'] - AND $document['distant']!='oui') - return ''; - $id_document = $document['id_document']; - - // Donnees sur le type de document - $t = @spip_abstract_fetsel('inclus,extension', - 'spip_types_documents', "id_type=".$document['id_type']); - $type_inclus = $t['inclus']; - $extension = $t['extension']; - - # TODO -- pour le MP3 "l x h pixels" ne va pas - if (($type_inclus == "embed" OR $type_inclus == "image") - AND ( - // documents dont la taille est definie - ($document['largeur'] * $document['hauteur']) - // ou distants - OR $document['distant'] == 'oui' - // ou formats dont la taille ne peut etre lue par getimagesize - OR $extension=='rm' OR $extension=='mov' - OR $extension=='flv' OR $extension=='mpg' - )) { - return "\n<br /><b>"._T('entree_dimensions')."</b><br />\n" . - "<input type='text' name='largeur_document' class='fondl' style='font-size:9px;' value=\"".$document['largeur']."\" size='5' onFocus=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block');\" />" . - " × <input type='text' name='hauteur_document' class='fondl' style='font-size:9px;' value=\"".$document['hauteur']."\" size='5' onFocus=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block');\" /> "._T('info_pixels'); - } -} - // // Construire un formulaire pour telecharger un fichier // @@ -337,103 +301,6 @@ function formulaire_joindre($id, $type = "article", $script, $flag_editable) { . $res; } -// http://doc.spip.org/@formulaire_tourner -function formulaire_tourner($id_document, $document, $script, $flag_modif, $type) -{ - include_spip('inc/filtres'); - global $spip_lang_right; - - if (!$document) { - // retour d'Ajax - $document = spip_fetch_array(spip_query("SELECT * FROM spip_documents WHERE id_document = " . intval($id_document))); - } - - $id = $document["id_$type"]; - $titre = $document['titre']; - $id_vignette = $document['id_vignette']; - $fichier = entites_html($document['fichier']); - - if (isset($document['url'])) - $url = $document['url']; - else { - charger_generer_url(); - $url = generer_url_document($id_document); - } - - if ($flag_modif) - $res .= boutons_rotateurs($document, $type, $id, $id_document,$script, $id_vignette); - else $res = ''; - // Indiquer les documents manquants avec un panneau de warning - - if ($document['distant'] != 'oui' - AND !@file_exists(_DIR_RACINE.$document['fichier'])) { - $c = _T('fichier_introuvable', - array('fichier'=>basename($document['fichier']))); - $res .= "<img src='" . _DIR_IMG_PACK . "warning-24.gif'" - ."\n\tstyle='float: right;'\n\talt=\"$c\"\n\ttitle=\"$c\" />"; - } - - $res .= "<div style='text-align: center;'>"; - $res .= document_et_vignette($document, $url, true); - $res .= "</div>\n"; - - $res .= "<div class='verdana1' style='text-align: center;'>"; - $res .= " <font size='1' face='arial,helvetica,sans-serif' color='333333'><doc$id_document></font>"; - $res .= "</div>"; - - if ($flag_modif === 'ajax') return $res; - - $boite = ''; - - // Signaler les documents distants par une icone de trombone - if ($document['distant'] == 'oui') - $boite .= "\n<img src='"._DIR_IMG_PACK.'attachment.gif'."'\n\t style='float: $spip_lang_right;'\n\talt=\"$fichier\"\n\ttitle=\"$fichier\" />\n"; - return "$boite<div id='tourner-$id_document'>$res</div>"; -} - -// http://doc.spip.org/@boutons_rotateurs -function boutons_rotateurs($document, $type, $id, $id_document, $script, $id_vignette) { - global $spip_lang_right; - static $ftype = array(1 => 'jpg', 2 => 'png', 3 => 'gif'); - - $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 !$id_vignette - AND isset($ftype[$document['id_type']]) - AND strstr($GLOBALS['meta']['formats_graphiques'], - $ftype[$document['id_type']]) - AND ($process == 'imagick' OR $process == 'gd2' - OR $process == 'convert' OR $process == 'netpbm') - AND @file_exists(_DIR_RACINE.$document['fichier']) - ) { - - return "\n<div class='verdana1' style='float: $spip_lang_right; text-align: $spip_lang_right;'>" . - - bouton_tourner_document($id, $id_document, $script, -90, $type, 'tourner-gauche.gif', _T('image_tourner_gauche')) . - - bouton_tourner_document($id, $id_document, $script, 90, $type, 'tourner-droite.gif', _T('image_tourner_droite')) . - - bouton_tourner_document($id, $id_document, $script, 180, $type, 'tourner-180.gif', _T('image_tourner_180')) . - "</div>\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"); -} - // // Afficher un document dans la colonne de gauche // @@ -621,7 +488,8 @@ function afficher_case_document($id_document, $id, $script, $type, $deplier = fa "</font></div>"; } - echo formulaire_legender($id_document, $document, $script, $type, $id, "document$id_document"); + $f = charger_fonction('legender', 'inc'); + echo $f($id_document, $document, $script, $type, $id, "document$id_document"); fin_cadre_enfonce(); } @@ -667,7 +535,8 @@ function afficher_case_document($id_document, $id, $script, $type, $deplier = fa if ($doublon) echo $raccourci_doc; - echo formulaire_legender($id_document, $document, $script, $type, $id, "document$id_document"); + $f = charger_fonction('legender', 'inc'); + echo $f($id_document, $document, $script, $type, $id, "document$id_document"); fin_cadre_relief(); } @@ -683,149 +552,4 @@ function teste_doc_deplie($id_document) { return in_array($id_document, $deplies); } - -function date_formulaire_legender($date, $id_document) { - - if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})", $date, $regs)){ - $mois = $regs[2]; - $jour = $regs[3]; - $annee = $regs[1]; - } - return "<b>"._T('info_mise_en_ligne')."</b><br />\n" . - afficher_jour($jour, "name='jour_doc' size='1' CLASS='fondl' style='font-size:9px;'\n\tonChange=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block');\"") . - afficher_mois($mois, "name='mois_doc' size='1' CLASS='fondl' style='font-size:9px;'\n\tonChange=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block');\"") . - afficher_annee($annee, "name='annee_doc' size='1' CLASS='fondl' style='font-size:9px;'\n\tonChange=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block')\"") . - "<br />\n"; -} - -function vignette_formulaire_legender($id_document, $document, $script, $type, $id, $ancre) -{ - $id_vignette = $document['id_vignette']; - $texte = _T('info_supprimer_vignette'); - - if (preg_match('/_edit$/', $script)) - $action = redirige_action_auteur('supprimer', "document-$id_vignette", $script, "id_$type=$id&show_docs=$id_document#$ancre"); - else { - $s = ($ancre =='documents' ? '': '-'); - $action = ajax_action_auteur('documenter', "$s$id/$type/$id_vignette", $script, "id_$type=$id&type=$type&s=$s&show_docs=$id_document#$ancre", array($texte)); - } - - return "<hr style='margin-left: -5px; margin-right: -5px; height: 1px; border: 0px; color: #eeeeee; background-color: white;' />" - . (!$id_vignette - ? formulaire_upload($script, "id_$type=$id",$id, _T('info_vignette_personnalisee'), 'vignette', $type, $ancre, $id_document) - : icone_horizontale($texte, $action, "vignette-24.png", "supprimer.gif", false)); -} - -// Formulaire de description d'un document (titre, date etc) -// En mode Ajax pour eviter de recharger toute la page ou il se trouve -// (surtout si c'est un portfolio) - -function formulaire_legender($id_document, $document, $script, $type, $id, $ancre) { - - // + securite (avec le script exec=legender ca vient de dehors) - if (!preg_match('/^\w+$/',$type, $r)) { - return; - } - - if ($document) { - // premier appel - $flag_deplie = teste_doc_deplie($id_document); - } else if ($id_document) { - // retour d'Ajax - $document = spip_fetch_array(spip_query("SELECT * FROM spip_documents WHERE id_document = " . intval($id_document))); - $flag_deplie = 'ajax'; - } else { - return; - } - - $descriptif = $document['descriptif']; - $titre = $document['titre']; - $date = $document['date']; - - if ($document['mode'] == 'vignette') { - $supp = 'image-24.gif'; - $label = _T('entree_titre_image'); - $taille = $vignette = ''; - - } else { - $supp = 'doc-24.gif'; - $label = _T('entree_titre_document'); - $taille = formulaire_taille($document); - $vignette = vignette_formulaire_legender($id_document, $document, $script, $type, $id, $ancre); - } - - $entete = basename($document['fichier']); - if (($n=strlen($entete)) > 20) - $entete = substr($entete, 0, 10)."...".substr($entete, $n-10, $n); - if (strlen($document['titre'])) - $entete = "<b>". typo($titre) . "</b>"; - - $contenu = ''; - if ($descriptif) - $contenu .= propre($descriptif) . "<br />\n" ; - if ($document['largeur'] OR $document['hauteur']) - $contenu .= _T('info_largeur_vignette', - array('largeur_vignette' => $document['largeur'], - 'hauteur_vignette' => $document['hauteur'])); - else - $contenu .= taille_en_octets($document['taille']) . ' - '; - - if ($date) $contenu .= "<br />\n" . affdate($date); - - $corps = - (!$contenu ? '' : - "<div class='verdana1' style='text-align: center;'>$contenu</div>") . - "<b>$label</b><br />\n" . - - "<input type='text' name='titre_document' class='formo' value=\"".entites_html($titre). - "\" size='40' onFocus=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block');\" /><br /><br />\n" . - date_formulaire_legender($date, $id_document) . - "<br />\n<b>". - _T('info_description_2'). - "</b><br />\n" . - "<textarea name='descriptif_document' rows='4' class='formo' cols='*' wrap='soft' onFocus=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block');\">" . - entites_html($descriptif) . - "</textarea>\n" . - $taille . - "\n<div " . - ($flag_deplie == 'ajax' ? '' : "class='display_au_chargement'") . - "id='valider_doc$id_document' align='". - $GLOBALS['spip_lang_right']. - "'>\n<input class='fondo' style='font-size:9px;' value='". - _T('bouton_enregistrer') . - "' type='submit' />" . - "</div>\n"; - - $texte = _T('icone_supprimer_document'); - if (preg_match('/_edit$/', $script)) - $action = redirige_action_auteur('supprimer', "document-$id_document", $script, "id_$type=$id#$ancre"); - else { - $s = ($ancre =='documents' ? '': '-'); - $action = ajax_action_auteur('documenter', "$s$id/$type/$id_document", $script, "id_$type=$id&type=$type&s=$s#$ancre", array($texte)); - } - - $corps = ajax_action_auteur("legender", $id_document, $script, "show_docs=$id_document&id_$type=$id#$ancre", $corps, "&id_document=$id_document&id=$id&type=$type&ancre=$ancre"); - - $corps .= $vignette . "\n\n\n\n" - . icone_horizontale($texte, $action, $supp, "supprimer.gif", false); - - $bloc = "legender-aff-$id_document"; - - $corps = "<div style='text-align:center;height:1%'>" - . "<div style='float:".$GLOBALS['spip_lang_left']."'>" - . ($flag_deplie ? - bouton_block_visible($bloc) : bouton_block_invisible($bloc)) - . "</div>\n" - . $entete - . "</div>\n" - . ($flag_deplie ? - debut_block_visible($bloc) : debut_block_invisible($bloc)) - . $corps - . fin_block(); - - return ($flag_deplie === 'ajax') ? $corps : - "<div id='legender-$id_document' class='verdana1' style='color: " . $GLOBALS['couleur_foncee'] . "; border: 1px solid ". $GLOBALS['couleur_foncee'] ."; padding: 5px; margin-top: 3px; background-color: white'>" . - $corps . - '</div>'; -} ?> diff --git a/ecrire/inc/legender.php b/ecrire/inc/legender.php new file mode 100644 index 0000000000..19bb80e758 --- /dev/null +++ b/ecrire/inc/legender.php @@ -0,0 +1,203 @@ +<?php + +/***************************************************************************\ + * SPIP, Systeme de publication pour l'internet * + * * + * Copyright (c) 2001-2006 * + * 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; + +include_spip('inc/actions'); // *action_auteur et determine_upload +include_spip('inc/presentation'); +include_spip('inc/documents'); +include_spip('inc/date'); + +// Formulaire de description d'un document (titre, date etc) +// En mode Ajax pour eviter de recharger toute la page ou il se trouve +// (surtout si c'est un portfolio) + +function inc_legender_dist($id_document, $document, $script, $type, $id, $ancre) { + + // + securite (avec le script exec=legender ca vient de dehors) + if (!preg_match('/^\w+$/',$type, $r)) { + return; + } + + if ($document) { + // premier appel + $flag_deplie = teste_doc_deplie($id_document); + } else if ($id_document) { + // retour d'Ajax + $document = spip_fetch_array(spip_query("SELECT * FROM spip_documents WHERE id_document = " . intval($id_document))); + $flag_deplie = 'ajax'; + } else { + return; + } + + $descriptif = $document['descriptif']; + $titre = $document['titre']; + $date = $document['date']; + + if ($document['mode'] == 'vignette') { + $supp = 'image-24.gif'; + $label = _T('entree_titre_image'); + $taille = $vignette = ''; + + } else { + $supp = 'doc-24.gif'; + $label = _T('entree_titre_document'); + $taille = formulaire_taille($document); + $vignette = vignette_formulaire_legender($id_document, $document, $script, $type, $id, $ancre); + } + + $entete = basename($document['fichier']); + if (($n=strlen($entete)) > 20) + $entete = substr($entete, 0, 10)."...".substr($entete, $n-10, $n); + if (strlen($document['titre'])) + $entete = "<b>". typo($titre) . "</b>"; + + $contenu = ''; + if ($descriptif) + $contenu .= propre($descriptif) . "<br />\n" ; + if ($document['largeur'] OR $document['hauteur']) + $contenu .= _T('info_largeur_vignette', + array('largeur_vignette' => $document['largeur'], + 'hauteur_vignette' => $document['hauteur'])); + else + $contenu .= taille_en_octets($document['taille']) . ' - '; + + if ($date) $contenu .= "<br />\n" . affdate($date); + + $corps = + (!$contenu ? '' : + "<div class='verdana1' style='text-align: center;'>$contenu</div>") . + "<b>$label</b><br />\n" . + + "<input type='text' name='titre_document' class='formo' value=\"".entites_html($titre). + "\" size='40' onFocus=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block');\" /><br /><br />\n" . + date_formulaire_legender($date, $id_document) . + "<br />\n<b>". + _T('info_description_2'). + "</b><br />\n" . + "<textarea name='descriptif_document' rows='4' class='formo' cols='*' wrap='soft' onFocus=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block');\">" . + entites_html($descriptif) . + "</textarea>\n" . + $taille . + "\n<div " . + ($flag_deplie == 'ajax' ? '' : "class='display_au_chargement'") . + "id='valider_doc$id_document' align='". + $GLOBALS['spip_lang_right']. + "'>\n<input class='fondo' style='font-size:9px;' value='". + _T('bouton_enregistrer') . + "' type='submit' />" . + "</div>\n"; + + $texte = _T('icone_supprimer_document'); + if (preg_match('/_edit$/', $script)) + $action = redirige_action_auteur('supprimer', "document-$id_document", $script, "id_$type=$id#$ancre"); + else { + $s = ($ancre =='documents' ? '': '-'); + $action = ajax_action_auteur('documenter', "$s$id/$type/$id_document", $script, "id_$type=$id&type=$type&s=$s#$ancre", array($texte)); + } + + $corps = ajax_action_auteur("legender", $id_document, $script, "show_docs=$id_document&id_$type=$id#$ancre", $corps, "&id_document=$id_document&id=$id&type=$type&ancre=$ancre"); + + $corps .= $vignette . "\n\n\n\n" + . icone_horizontale($texte, $action, $supp, "supprimer.gif", false); + + $bloc = "legender-aff-$id_document"; + + $corps = "<div style='text-align:center;height:1%'>" + . "<div style='float:".$GLOBALS['spip_lang_left']."'>" + . ($flag_deplie ? + bouton_block_visible($bloc) : bouton_block_invisible($bloc)) + . "</div>\n" + . $entete + . "</div>\n" + . ($flag_deplie ? + debut_block_visible($bloc) : debut_block_invisible($bloc)) + . $corps + . fin_block(); + + return ($flag_deplie === 'ajax') ? $corps : + "<div id='legender-$id_document' class='verdana1' style='color: " . $GLOBALS['couleur_foncee'] . "; border: 1px solid ". $GLOBALS['couleur_foncee'] ."; padding: 5px; margin-top: 3px; background-color: white'>" . + $corps . + '</div>'; +} + + +function vignette_formulaire_legender($id_document, $document, $script, $type, $id, $ancre) +{ + $id_vignette = $document['id_vignette']; + $texte = _T('info_supprimer_vignette'); + + if (preg_match('/_edit$/', $script)) + $action = redirige_action_auteur('supprimer', "document-$id_vignette", $script, "id_$type=$id&show_docs=$id_document#$ancre"); + else { + $s = ($ancre =='documents' ? '': '-'); + $action = ajax_action_auteur('documenter', "$s$id/$type/$id_vignette", $script, "id_$type=$id&type=$type&s=$s&show_docs=$id_document#$ancre", array($texte)); + } + + return "<hr style='margin-left: -5px; margin-right: -5px; height: 1px; border: 0px; color: #eeeeee; background-color: white;' />" + . (!$id_vignette + ? formulaire_upload($script, "id_$type=$id",$id, _T('info_vignette_personnalisee'), 'vignette', $type, $ancre, $id_document) + : icone_horizontale($texte, $action, "vignette-24.png", "supprimer.gif", false)); +} + + +// Bloc d'edition de la taille du doc (pour embed) +// http://doc.spip.org/@formulaire_taille +function formulaire_taille($document) { + + // (on ne le propose pas pour les images qu'on sait + // lire, id_type<=3), sauf bug, ou document distant + if ($document['id_type'] <= 3 + AND $document['hauteur'] + AND $document['largeur'] + AND $document['distant']!='oui') + return ''; + $id_document = $document['id_document']; + + // Donnees sur le type de document + $t = @spip_abstract_fetsel('inclus,extension', + 'spip_types_documents', "id_type=".$document['id_type']); + $type_inclus = $t['inclus']; + $extension = $t['extension']; + + # TODO -- pour le MP3 "l x h pixels" ne va pas + if (($type_inclus == "embed" OR $type_inclus == "image") + AND ( + // documents dont la taille est definie + ($document['largeur'] * $document['hauteur']) + // ou distants + OR $document['distant'] == 'oui' + // ou formats dont la taille ne peut etre lue par getimagesize + OR $extension=='rm' OR $extension=='mov' + OR $extension=='flv' OR $extension=='mpg' + )) { + return "\n<br /><b>"._T('entree_dimensions')."</b><br />\n" . + "<input type='text' name='largeur_document' class='fondl' style='font-size:9px;' value=\"".$document['largeur']."\" size='5' onFocus=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block');\" />" . + " × <input type='text' name='hauteur_document' class='fondl' style='font-size:9px;' value=\"".$document['hauteur']."\" size='5' onFocus=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block');\" /> "._T('info_pixels'); + } +} + +function date_formulaire_legender($date, $id_document) { + + if (ereg("([0-9]{4})-([0-9]{2})-([0-9]{2})", $date, $regs)){ + $mois = $regs[2]; + $jour = $regs[3]; + $annee = $regs[1]; + } + return "<b>"._T('info_mise_en_ligne')."</b><br />\n" . + afficher_jour($jour, "name='jour_doc' size='1' CLASS='fondl' style='font-size:9px;'\n\tonChange=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block');\"") . + afficher_mois($mois, "name='mois_doc' size='1' CLASS='fondl' style='font-size:9px;'\n\tonChange=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block');\"") . + afficher_annee($annee, "name='annee_doc' size='1' CLASS='fondl' style='font-size:9px;'\n\tonChange=\"changeVisible(true, 'valider_doc$id_document', 'block', 'block')\"") . + "<br />\n"; +} + +?> diff --git a/ecrire/inc/tourner.php b/ecrire/inc/tourner.php new file mode 100644 index 0000000000..a81337f856 --- /dev/null +++ b/ecrire/inc/tourner.php @@ -0,0 +1,115 @@ +<?php + +/***************************************************************************\ + * SPIP, Systeme de publication pour l'internet * + * * + * Copyright (c) 2001-2006 * + * 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; + +include_spip('inc/actions'); // *action_auteur et determine_upload +include_spip('inc/documents'); +include_spip('inc/presentation'); +include_spip('inc/filtres'); + +// http://doc.spip.org/@formulaire_tourner +function inc_tourner_dist($id_document, $document, $script, $flag_modif, $type) +{ + global $spip_lang_right; + + if (!$document) { + // retour d'Ajax + $document = spip_fetch_array(spip_query("SELECT * FROM spip_documents WHERE id_document = " . intval($id_document))); + } + + $id = $document["id_$type"]; + $titre = $document['titre']; + $id_vignette = $document['id_vignette']; + $fichier = entites_html($document['fichier']); + + if (isset($document['url'])) + $url = $document['url']; + else { + charger_generer_url(); + $url = generer_url_document($id_document); + } + + if ($flag_modif) + $res .= boutons_rotateurs($document, $type, $id, $id_document,$script, $id_vignette); + else $res = ''; + // Indiquer les documents manquants avec un panneau de warning + + if ($document['distant'] != 'oui' + AND !@file_exists(_DIR_RACINE.$document['fichier'])) { + $c = _T('fichier_introuvable', + array('fichier'=>basename($document['fichier']))); + $res .= "<img src='" . _DIR_IMG_PACK . "warning-24.gif'" + ."\n\tstyle='float: right;'\n\talt=\"$c\"\n\ttitle=\"$c\" />"; + } + + $res .= "<div style='text-align: center;'>"; + $res .= document_et_vignette($document, $url, true); + $res .= "</div>\n"; + + $res .= "<div class='verdana1' style='text-align: center;'>"; + $res .= " <font size='1' face='arial,helvetica,sans-serif' color='333333'><doc$id_document></font>"; + $res .= "</div>"; + + if ($flag_modif === 'ajax') return $res; + + $boite = ''; + + // Signaler les documents distants par une icone de trombone + if ($document['distant'] == 'oui') + $boite .= "\n<img src='"._DIR_IMG_PACK.'attachment.gif'."'\n\t style='float: $spip_lang_right;'\n\talt=\"$fichier\"\n\ttitle=\"$fichier\" />\n"; + return "$boite<div id='tourner-$id_document'>$res</div>"; +} + +// http://doc.spip.org/@boutons_rotateurs +function boutons_rotateurs($document, $type, $id, $id_document, $script, $id_vignette) { + global $spip_lang_right; + static $ftype = array(1 => 'jpg', 2 => 'png', 3 => 'gif'); + + $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 !$id_vignette + AND isset($ftype[$document['id_type']]) + AND strstr($GLOBALS['meta']['formats_graphiques'], + $ftype[$document['id_type']]) + AND ($process == 'imagick' OR $process == 'gd2' + OR $process == 'convert' OR $process == 'netpbm') + AND @file_exists(_DIR_RACINE.$document['fichier']) + ) { + + return "\n<div class='verdana1' style='float: $spip_lang_right; text-align: $spip_lang_right;'>" . + + bouton_tourner_document($id, $id_document, $script, -90, $type, 'tourner-gauche.gif', _T('image_tourner_gauche')) . + + bouton_tourner_document($id, $id_document, $script, 90, $type, 'tourner-droite.gif', _T('image_tourner_droite')) . + + bouton_tourner_document($id, $id_document, $script, 180, $type, 'tourner-180.gif', _T('image_tourner_180')) . + "</div>\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"); +} +?> -- GitLab