Update of /home/spip-cvs/spip/ecrire
In directory alan:/tmp/cvs-serv31332/ecrire
Modified Files:
articles_edit.php3 auteur_infos.php3 breves_edit.php3
inc_filtres.php3 inc_logos.php3 inc_presentation.php3
inc_version.php3 mots_edit.php3 mots_type.php3
rubriques_edit.php3
Log Message:
* bug du onfocus (Averell)
* réduire les images ... sauf si elles sont déjà suffisamment petites
* mettre les résultats de reduire_image() dans IMG/cache-LxH/
Index: articles_edit.php3
RCS file: /home/spip-cvs/spip/ecrire/articles_edit.php3,v
retrieving revision 1.82
retrieving revision 1.83
diff -u -d -r1.82 -r1.83
--- a/articles_edit.php3 6 Apr 2004 23:59:19 -0000 1.82
+++ b/articles_edit.php3 16 Apr 2004 19:55:56 -0000 1.83
@@ -122,7 +122,7 @@
else {
// Nouvel article : titre par defaut
$titre = filtrer_entites(_T('info_nouvel_article'));
- $onfocus = " onfocus=\"this.value='';\"";
+ $onfocus = " onfocus=\"if(!done){this.value='';done=true;}\"";
}
if (!$id_secteur) {
$row_rub = spip_fetch_array(spip_query("SELECT id_secteur FROM spip_rubriques WHERE id_rubrique=$id_rubrique"));
Index: auteur_infos.php3
RCS file: /home/spip-cvs/spip/ecrire/auteur_infos.php3,v
retrieving revision 1.54
retrieving revision 1.55
diff -u -d -r1.54 -r1.55
--- a/auteur_infos.php3 6 Apr 2004 23:59:19 -0000 1.54
+++ b/auteur_infos.php3 16 Apr 2004 19:55:56 -0000 1.55
@@ -75,7 +75,7 @@
$new = false; // eviter hack
} else {
$auteur['nom'] = filtrer_entites(_T('item_nouvel_auteur'));
- $onfocus = " onfocus=\"this.value='';\"";
+ $onfocus = " onfocus=\"if(!done){this.value='';done=true;}\"";
$auteur['statut'] = '1comite';
$auteur['source'] = 'spip';
}
Index: breves_edit.php3
RCS file: /home/spip-cvs/spip/ecrire/breves_edit.php3,v
retrieving revision 1.37
retrieving revision 1.38
diff -u -d -r1.37 -r1.38
--- a/breves_edit.php3 6 Apr 2004 23:59:19 -0000 1.37
+++ b/breves_edit.php3 16 Apr 2004 19:55:56 -0000 1.38
@@ -54,7 +54,7 @@
}
else {
$titre = filtrer_entites(_T('titre_nouvelle_breve'));
- $onfocus = " onfocus=\"this.value='';\"";
+ $onfocus = " onfocus=\"if(!done){this.value='';done=true;}\"";
$statut = "prop";
}
Index: inc_filtres.php3
RCS file: /home/spip-cvs/spip/ecrire/inc_filtres.php3,v
retrieving revision 1.116
retrieving revision 1.117
diff -u -d -r1.116 -r1.117
--- a/inc_filtres.php3 15 Apr 2004 20:12:14 -0000 1.116
+++ b/inc_filtres.php3 16 Apr 2004 19:55:56 -0000 1.117
@@ -521,10 +521,12 @@
//
// Reduire la taille d'un logo
+// [(#LOGO_ARTICLE||reduire_image{100,60})]
//
function reduire_image($img, $taille = 120, $taille_y=0) {
include_ecrire('inc_logos.php3');
+ include_local('inc-cache.php3');
if (!$taille_y)
$taille_y = $taille;
@@ -538,42 +540,25 @@
if (eregi("hspace=\'([^']+)\'", $img, $regs)) $espace = $regs[1];
if (!$logo)
- $logo = 'IMG/'.ereg_replace('(../|IMG/)', '', $img); // [(#LOGO_ARTICLE|fichier|reduire_image{100})]
+ $logo = $img; // [(#LOGO_ARTICLE|fichier|reduire_image{100})]
- if (@file_exists($logo) AND eregi("(IMG/.*)\.(jpg|gif|png)$", $logo, $regs)) {
+ $logo = 'IMG/'.ereg_replace('(../|IMG/)', '', $logo);
+
+ if (@file_exists($logo) AND eregi("IMG/(.*)\.(jpg|gif|png)$", $logo, $regs)) {
$nom = $regs[1];
$format = $regs[2];
- $destination = $nom.'-'.$taille.'x'.$taille_y;
+ $cache_folder= 'IMG/'.creer_repertoire('IMG', 'cache-'.$taille.'x'.$taille_y);
+ $destination = $cache_folder.$nom.'-'.$taille.'x'.$taille_y;
+
if ($preview = creer_vignette($logo, $taille, $taille_y, $format, $destination)) {
$vignette = $preview['fichier'];
$width = $preview['width'];
$height = $preview['height'];
return "<img src='$vignette' name='$name' border='0' align='$align' alt='' hspace='$espace' vspace='$espace' width='$width' height='$height' class='spip_logos' />";
- } else {
- $taille_origine = @getimagesize("IMG/$logo");
- if ($taille_origine) {
- // Calculer le ratio
- $srcWidth = $taille_origine[0];
- $srcHeight = $taille_origine[1];
-
- if ($srcWidth > $taille OR $srcHeight > $taille) {
- $ratioWidth = $srcWidth/$taille;
- $ratioHeight = $srcHeight/$taille;
-
- if ($ratioWidth < $ratioHeight) {
- $destWidth = floor($srcWidth/$ratioHeight);
- $destHeight = $taille;
- }
- else {
- $destWidth = $taille;
- $destHeight = floor($srcHeight/$ratioWidth);
- }
- } else {
- $destWidth = $srcWidth;
- $destHeight = $srcHeight;
- }
- return "<img src='$logo' name='$name' width='$destWidth' height='$destHeight' border='0' align='$align' alt='' hspace='$espace' vspace='$espace' class='spip_logos' />";
- }
+ }
+ else if ($taille_origine = @getimagesize("IMG/$logo")) {
+ list ($destWidth,$destHeight) = image_ratio($taille_origine[0], $taille_origine[1], $taille, $taille_y);
+ return "<img src='$logo' name='$name' width='$destWidth' height='$destHeight' border='0' align='$align' alt='' hspace='$espace' vspace='$espace' class='spip_logos' />";
}
}
}
Index: inc_logos.php3
RCS file: /home/spip-cvs/spip/ecrire/inc_logos.php3,v
retrieving revision 1.18
retrieving revision 1.19
diff -u -d -r1.18 -r1.19
--- a/inc_logos.php3 15 Apr 2004 19:09:31 -0000 1.18
+++ b/inc_logos.php3 16 Apr 2004 19:55:56 -0000 1.19
@@ -175,7 +175,26 @@
// Creation automatique d'une vignette
//
-function creer_vignette($image, $newWidth, $newHeight, $format, $destination, $process='AUTO', $force=false) {
+// Calculer le ratio
+function image_ratio ($srcWidth, $srcHeight, $maxWidth, $maxHeight) {
+ $ratioWidth = $srcWidth/$maxWidth;
+ $ratioHeight = $srcHeight/$maxHeight;
+
+ if ($ratioWidth <=1 AND $ratioHeight <=1) {
+ $destWidth = $srcWidth;
+ $destHeight = $srcHeight;
+ } else if ($ratioWidth < $ratioHeight) {
+ $destWidth = $srcWidth/$ratioHeight;
+ $destHeight = $maxHeight;
+ }
+ else {
+ $destWidth = $maxWidth;
+ $destHeight = $srcHeight/$ratioWidth;
+ }
+ return array ($destWidth, $destHeight);
+}
+
+function creer_vignette($image, $maxWidth, $maxHeight, $format, $destination, $process='AUTO', $force=false) {
global $convert_command;
if ($process == 'AUTO')
@@ -199,27 +218,14 @@
if ($force OR !$vignette OR (@filemtime($vignette) < @filemtime($image))) {
$creation = true;
-
- // Calculer le ratio
if (!$srcsize = @getimagesize($image)) return;
- $srcWidth = $srcsize[0];
- $srcHeight = $srcsize[1];
- $ratioWidth = $srcWidth/$newWidth;
- $ratioHeight = $srcHeight/$newHeight;
-
- if ($ratioWidth < $ratioHeight) {
- $destWidth = $srcWidth/$ratioHeight;
- $destHeight = $newHeight;
- }
- else {
- $destWidth = $newWidth;
- $destHeight = $srcHeight/$ratioWidth;
- }
+ list ($destWidth,$destHeight) = image_ratio($srcsize[0], $srcsize[1], $maxWidth, $maxHeight);
// imagemagick en ligne de commande
if ($process == 'convert') {
$vignette = $destination.".jpg";
- $commande = "$convert_command -size ${newWidth}x${newHeight} $image -geometry ${newWidth}x${newHeight} +profile \"*\" $vignette";
+ $commande = "$convert_command -size ${destWidth}x${destHeight} $image -geometry ${destWidth}x${destHeight} +profile \"*\" $vignette";
+spip_log($commande);
shell_exec($commande);
}
else
@@ -227,17 +233,11 @@
if ($process == 'imagick') {
$vignette = "$destination.jpg";
- $handle = imagick_create();
- $handle AND imagick_read($handle, $srcImage)
- AND imagick_resize($handle, $destWidth, $destHeight, IMAGICK_FILTER_UNKNOWN, 0)
- AND $ok = imagick_write($handle, $vignette);
-
- if (!$ok) {
- echo imagick_failedreason( $handle ) ;
- echo imagick_faileddescription( $handle ) ;
- return;
- }
- } else
+ $handle = imagick_readimage($image);
+ imagick_resize($handle, $destWidth, $destHeight, IMAGICK_FILTER_UNKNOWN, 0);
+ imagick_write($handle, $vignette);
+ }
+ else
// gd ou gd2
if ($process == 'gd1' OR $process == 'gd2') {
Index: inc_presentation.php3
RCS file: /home/spip-cvs/spip/ecrire/inc_presentation.php3,v
retrieving revision 1.368
retrieving revision 1.369
diff -u -d -r1.368 -r1.369
--- a/inc_presentation.php3 11 Apr 2004 23:42:27 -0000 1.368
+++ b/inc_presentation.php3 16 Apr 2004 19:55:56 -0000 1.369
@@ -1519,7 +1519,7 @@
global $recherche;
if ($recherche == '' AND $spip_display != 2) {
$recherche_aff = _T('info_rechercher');
- $onfocus = "onfocus=this.value='';";
+ $onfocus = " onfocus=\"if(!done){this.value='';done=true;}\"";
} else
$recherche_aff = $recherche;
bandeau_barre_verticale();
@@ -1527,7 +1527,7 @@
echo "<form method='get' style='margin: 0px;' action='recherche.php3'>";
if ($spip_display == "2")
echo "<font face='Verdana,Arial,Sans,sans-serif' size=1 color='#505050'><b>"._T('info_rechercher_02')."</b></font><br>";
- echo '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="spip_recherche" style="width: 70px" accesskey="r" '.$onfocus.'>';
+ echo '<input type="text" size="10" value="'.$recherche_aff.'" name="recherche" class="spip_recherche" style="width: 70px" accesskey="r"'.$onfocus.'>';
echo "</form>";
echo "</td>";
}
Index: inc_version.php3
RCS file: /home/spip-cvs/spip/ecrire/inc_version.php3,v
retrieving revision 1.302
retrieving revision 1.303
diff -u -d -r1.302 -r1.303
--- a/inc_version.php3 15 Apr 2004 14:41:59 -0000 1.302
+++ b/inc_version.php3 16 Apr 2004 19:55:56 -0000 1.303
@@ -218,7 +218,7 @@
$flag_ImageGif = function_exists("ImageGif");
$flag_ImageJpeg = function_exists("ImageJpeg");
$flag_ImagePng = function_exists("ImagePng");
-$flag_imagick = function_exists("imagick_create"); // http://pear.sourceforge.net/en/packages.imagick.php
+$flag_imagick = function_exists("imagick_readimage"); // http://pear.sourceforge.net/en/packages.imagick.php
$flag_multibyte = function_exists("mb_encode_mimeheader");
$flag_iconv = function_exists("iconv");
$flag_strtotime = function_exists("strtotime");
Index: mots_edit.php3
RCS file: /home/spip-cvs/spip/ecrire/mots_edit.php3,v
retrieving revision 1.33
retrieving revision 1.34
diff -u -d -r1.33 -r1.34
--- a/mots_edit.php3 6 Apr 2004 23:59:19 -0000 1.33
+++ b/mots_edit.php3 16 Apr 2004 19:55:56 -0000 1.34
@@ -60,7 +60,7 @@
}
else if ($new == 'oui') {
$titre_mot = filtrer_entites(_T('texte_nouveau_mot'));
- $onfocus = " onfocus=\"this.value='';\"";
+ $onfocus = " onfocus=\"if(!done){this.value='';done=true;}\"";
}
}
Index: mots_type.php3
RCS file: /home/spip-cvs/spip/ecrire/mots_type.php3,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- a/mots_type.php3 6 Apr 2004 23:59:19 -0000 1.15
+++ b/mots_type.php3 16 Apr 2004 19:55:56 -0000 1.16
@@ -6,7 +6,7 @@
if ($connect_statut == '0minirezo' AND $new == "oui") {
$id_groupe = '';
$type = filtrer_entites(_T('titre_nouveau_groupe'));
- $onfocus = " onfocus=\"this.value='';\"";
+ $onfocus = " onfocus=\"if(!done){this.value='';done=true;}\"";
$ancien_type = '';
$unseul = 'non';
$obligatoire = 'non';
Index: rubriques_edit.php3
RCS file: /home/spip-cvs/spip/ecrire/rubriques_edit.php3,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -d -r1.35 -r1.36
--- a/rubriques_edit.php3 6 Apr 2004 23:59:19 -0000 1.35
+++ b/rubriques_edit.php3 16 Apr 2004 19:55:56 -0000 1.36
@@ -65,7 +65,7 @@
$id_parent = intval($id_parent);
$id_rubrique = 0;
$titre = filtrer_entites(_T('titre_nouvelle_rubrique'));
- $onfocus = " onfocus=\"this.value='';\"";
+ $onfocus = " onfocus=\"if(!done){this.value='';done=true;}\"";
$descriptif = "";
$texte = "";
}