[SPIP] ~2.1.12 -->2.1.25
[velocampus/web/www.git] / www / ecrire / configuration / reducteur.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2014 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
8 * *
9 * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
10 * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
11 \***************************************************************************/
12
13 if (!defined('_ECRIRE_INC_VERSION')) return;
14
15 include_spip('inc/presentation');
16 include_spip('inc/config');
17
18 function configuration_reducteur_dist()
19 {
20 global $spip_lang_left, $spip_lang_right;
21 $image_process = _request('image_process');
22
23 // application du choix de vignette
24 if ($image_process) {
25 // mettre a jour les formats graphiques lisibles
26 switch ($image_process) {
27 case 'gd1':
28 case 'gd2':
29 $formats_graphiques = $GLOBALS['meta']['gd_formats_read'];
30 break;
31 case 'netpbm':
32 $formats_graphiques = $GLOBALS['meta']['netpbm_formats'];
33 break;
34 case 'convert':
35 case 'imagick':
36 $formats_graphiques = 'gif,jpg,png';
37 break;
38 default: #debug
39 $formats_graphiques = '';
40 $image_process = 'non';
41 break;
42 }
43 ecrire_meta('formats_graphiques', $formats_graphiques,'non');
44 ecrire_meta('image_process', $image_process,'non');
45 } else $formats_graphiques = $GLOBALS['meta']["formats_graphiques"];
46
47 $nb_process = 0;
48 $res = '';
49
50 // Tester les formats
51 if ( /* GD disponible ? */
52 function_exists('ImageGif')
53 OR function_exists('ImageJpeg')
54 OR function_exists('ImagePng')
55 ) {
56 $res .= afficher_choix_vignette($p = 'gd1');
57 if (function_exists("ImageCreateTrueColor")) {
58 $res .= afficher_choix_vignette($p = 'gd2');
59 }
60 }
61
62 if (_PNMSCALE_COMMAND!='') {
63 $res .= afficher_choix_vignette($p = 'netpbm');
64 }
65
66 if (function_exists('imagick_readimage')) {
67 $res .=afficher_choix_vignette('imagick');
68 }
69
70 if (_CONVERT_COMMAND!='') {
71 $res .= afficher_choix_vignette($p = 'convert');
72 }
73
74
75 $test_out = "";
76 if ($GLOBALS['meta']['image_process']=='gd1' OR $GLOBALS['meta']['image_process']=='gd2') {
77 effacer_meta('max_taille_vignettes');
78 $test_out .= "<p>"._T('info_taille_maximale_images')."</p>";
79 $time = time();
80 $url = generer_url_action("tester_taille", "arg=3000&time=$time");
81 $test_out .= "<iframe style='border:0;height:3em;overflow:hidden;' src='$url'></iframe>";
82 $test_out .= "<br style='clear:both;' />";
83 }
84 else {
85 effacer_meta('max_taille_vignettes');
86 }
87
88 return ajax_action_greffe("configurer-reducteur", '',
89 debut_cadre_trait_couleur("image-24.gif", true, "", _T("info_image_process_titre"))
90 . debut_cadre_relief("", true)
91 . "<p class='verdana2'>"
92 . _T('info_image_process')
93 . "</p>"
94 . $res
95 . "<div class='nettoyeur'></div>"
96 . "<p class='verdana2'>"
97 . _T('info_image_process2')
98 . "</p>"
99 . $test_out
100 . fin_cadre_relief(true)
101 . (!$formats_graphiques ? '' : format_choisi())
102 . fin_cadre_trait_couleur(true)
103 );
104 }
105
106 function format_choisi()
107 {
108 global $spip_lang_left, $spip_lang_right;
109
110 $creer_preview = $GLOBALS['meta']["creer_preview"];
111 $taille_preview = $GLOBALS['meta']["taille_preview"];
112 if ($taille_preview < 10) $taille_preview = 120;
113
114 $res .= "<p class='verdana2'>";
115 $res .= _T('info_ajout_image');
116 $res .= "</p>\n";
117 $res .= "<div class='verdana2'>";
118 $res .= bouton_radio("creer_preview", "oui", _T('item_choix_generation_miniature'), $creer_preview == "oui", "changeVisible(this.checked, 'config-preview', 'block', 'none');");
119 $res .= '</div>';
120
121 if ($creer_preview == "oui") $style = "block;"; else $style = "none;";
122
123 $res .= "<div id='config-preview' class='verdana2' style='display: $style margin-$spip_lang_left: 40px;'>"
124 . "<label for='taille_preview'>"
125 ._T('info_taille_maximale_vignette')
126 . "</label>"
127 . "<br /><input type='text' name='taille_preview' id='taille_preview' value='$taille_preview' size='5' />";
128 $res .= " "._T('info_pixels');
129
130 $res .= '<br /><br />';
131 $res .= "</div>";
132 $res .= bouton_radio("creer_preview", "non", _T('item_choix_non_generation_miniature'), $creer_preview != "oui", "changeVisible(this.checked, 'config-preview', 'none', 'block');");
133
134 return
135 debut_cadre_relief("", true, "", _T('info_generation_miniatures_images'))
136 . ajax_action_post('configurer', 'reducteur', 'config_fonctions', '', $res)
137 . fin_cadre_relief(true);
138 }
139
140 // http://doc.spip.org/@afficher_choix_vignette
141 function afficher_choix_vignette($process) {
142
143 //global $taille_preview;
144 $taille_preview = 120;
145
146 // Ici on va tester les capacites de GD independamment des tests realises
147 // dans les images spip_image -- qui servent neanmoins pour la qualite
148 /* if (function_exists('imageformats')) {
149
150 } */
151
152
153 $class = '';
154 if ($process == $GLOBALS['meta']['image_process']) {
155 $class = " selected";
156 }
157 return "\n<div class='vignette_reducteur$class'"
158 . "><a href='"
159 . generer_url_ecrire("config_fonctions", "image_process=$process")
160 . "'><img src='"
161 . generer_url_action("tester", "arg=$process&time=".time())
162 . "' alt='$process' /></a><span>$process</span></div>\n";
163
164 }
165
166 ?>