[SPIP] ~2.1.12 -->2.1.25
[velocampus/web/www.git] / www / ecrire / inc / iconifier.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/actions');
16 global $logo_libelles;
17 $logo_libelles['id_article'] = _T('logo_article').aide ("logoart");
18 $logo_libelles['id_auteur'] = _T('logo_auteur').aide ("logoart");
19 $logo_libelles['id_breve'] = _T('logo_breve').aide ("breveslogo");
20 $logo_libelles['id_syndic'] = _T('logo_site')." ".aide ("rublogo");
21 $logo_libelles['id_mot'] = _T('logo_mot_cle').aide("breveslogo");
22 $logo_libelles['id_rubrique'] = _T('logo_rubrique')." ".aide ("rublogo");
23 $logo_libelles['id_racine'] = _T('logo_standard_rubrique')." ".aide ("rublogo");
24
25
26 // http://doc.spip.org/@inc_iconifier_dist
27 function inc_iconifier_dist($id_objet, $id, $script, $visible=false, $flag_modif=true) {
28 if ($GLOBALS['spip_display'] == 4) return "";
29 $texteon = $GLOBALS['logo_libelles'][($id OR $id_objet != 'id_rubrique') ? $id_objet : 'id_racine'];
30
31 $chercher_logo = charger_fonction('chercher_logo', 'inc');
32
33 // Add the redirect url when uploading via iframe
34 $iframe_script = generer_url_ecrire('iconifier',"type=$id_objet&$id_objet=$id&script=$script",true);
35 $iframe = "<input type='hidden' name='iframe_redirect' value='".rawurlencode($iframe_script)."' />\n";
36
37 $logo = $chercher_logo($id, $id_objet, 'on');
38 $logo_s = $chercher_logo($id, $id_objet, 'off');
39 if (!$logo) {
40 if ($flag_modif AND $GLOBALS['meta']['activer_logos'] != 'non') {
41 $masque = indiquer_logo($texteon, $id_objet, 'on', $id, $script, $iframe);
42 $masque = "<div class='cadre_padding'>$masque</div>";
43 $bouton = bouton_block_depliable($texteon, $visible, "on-$id_objet-$id");
44 $res = debut_block_depliable($visible,"on-$id_objet-$id") . $masque . fin_block();
45 }
46 } else {
47 list($img, $clic) = decrire_logo($id_objet,'on',$id, 170, 170, $logo, $texteon, $script, $flag_modif AND !$logo_s);
48
49 $bouton = bouton_block_depliable($texteon, $visible, "on-$id_objet-$id");
50
51 $survol = '';
52 $texteoff = _T('logo_survol');
53 if (!$logo = $logo_s) {
54 if ($flag_modif AND $GLOBALS['meta']['activer_logos_survol'] == 'oui') {
55 $masque = "<br />".indiquer_logo($texteoff, $id_objet, 'off', $id, $script, $iframe);
56 $survol .= "<br />".block_parfois_visible("off-$id_objet-$id", $texteoff, $masque, null, $visible);
57 }
58 $masque = debut_block_depliable($visible,"on-$id_objet-$id")
59 . "<div class='cadre_padding'>"
60 . $clic . $survol . "</div>" . fin_block();
61 } else {
62 list($imgoff, $clicoff) = decrire_logo($id_objet, 'off', $id, 170, 170, $logo, $texteoff, $script, $flag_modif);
63 $masque = debut_block_depliable($visible, "off-$id_objet-$id") . $clicoff . fin_block();
64 $survol .= "<br />".bouton_block_depliable($texteoff, $visible, "off-$id_objet-$id")
65 . "<div class='cadre_padding'>".$imgoff.$masque."</div>";
66 $masque = debut_block_depliable($visible,"on-$id_objet-$id") . $clic . fin_block() . $survol;
67 }
68
69 $res = "$img$masque";
70 }
71
72 if ($res) {
73 $res = debut_cadre('r', 'image-24.gif', '', $bouton, '', '', false)
74 . $res
75 . fin_cadre_relief(true);
76
77 if(_request("exec")!="iconifier") {
78 $js = http_script('', 'async_upload.js')
79 . http_script('$("form.form_upload_icon").async_upload(async_upload_icon)');
80
81 } else $js = "";
82 return ajax_action_greffe("iconifier", $id, $res).$js;
83 }
84 else return '';
85
86 }
87
88
89 // http://doc.spip.org/@indiquer_logo
90 function indiquer_logo($titre, $id_objet, $mode, $id, $script, $iframe_script) {
91
92 global $formats_logos;
93 $afficher = "";
94 $reg = '[.](' . join('|', $formats_logos) . ')$';
95
96
97 /*
98 # CODE MORT SI ON DECIDE DE NE PAS LAISSER UPLOADER DES LOGOS PAR FTP
99
100 if ($GLOBALS['flag_upload']
101 AND $dir_ftp = determine_upload('logos')
102 AND $fichiers = preg_files($dir_ftp, $reg)) {
103 foreach ($fichiers as $f) {
104 $f = substr($f, strlen($dir_ftp));
105 $afficher .= "\n<option value='$f'>$f</option>";
106 }
107 }
108 if (!$afficher) {
109 if ($dir_ftp) {
110 $afficher = _T('info_installer_images_dossier',
111 array('upload' => '<b>' . joli_repertoire($dir_ftp) . '</b>'));
112 }
113 } else {
114 $afficher = "\n<div style='text-align: left'>" .
115 _T('info_selectionner_fichier',
116 array('upload' => '<b>' . joli_repertoire($dir_ftp) . '</b>')) .
117 ":</div>" .
118 "\n<select name='source' class='forml' size='1'>$afficher\n</select>" .
119 "\n<div style='text-align:" .
120 $GLOBALS['spip_lang_right'] .
121 "'><input name='sousaction2' type='submit' value='".
122 _T('bouton_choisir') .
123 "' /></div>";
124 }
125 */
126
127 $afficher = "\n<label for='image'>" .
128 _T('info_telecharger_nouveau_logo') .
129 "</label><br />" .
130 "\n<input name='image' id='image' type='file' class='forml spip_xx-small' size='15' />" .
131 "<div style='text-align: " . $GLOBALS['spip_lang_right'] . "'>" .
132 "\n<input name='sousaction1' type='submit' value='" .
133 _T('bouton_telecharger') .
134 "' /></div>" .
135 $afficher;
136
137 $type = type_du_logo($id_objet);
138 return redirige_action_post('iconifier',
139 "$id+$type$mode$id",
140 $script,
141 "$id_objet=$id",
142 $iframe_script.$afficher,
143 " enctype='multipart/form-data' class='form_upload_icon'");
144 }
145
146 // http://doc.spip.org/@decrire_logo
147 function decrire_logo($id_objet, $mode, $id, $width, $height, $img, $titre="", $script="", $flag_modif=true) {
148
149 list($fid, $dir, $nom, $format, $timestamp) = $img;
150 include_spip('inc/filtres_images_mini');
151
152 $res = image_reduire("<img src='$fid' alt='' class='miniature_logo' />", $width, $height);
153
154 if ($res){
155 $src = extraire_attribut($res,'src');
156 $res = inserer_attribut($res, 'src', "$src?$timestamp");
157 $res = "<div><a href='" . $fid . "'>$res</a></div>";
158 }
159 else
160 $res = "<img src='$fid?$timestamp' width='$width' height='$height' alt=\"" . htmlentities($titre) . '" />';
161 if ($taille = @getimagesize($fid))
162 $taille = _T('info_largeur_vignette', array('largeur_vignette' => $taille[0], 'hauteur_vignette' => $taille[1]));
163
164 return array($res,
165 "<div class='spip_xx-small'>" . $taille
166 . ($flag_modif
167 ? "\n<br />["
168 . ajax_action_auteur("iconifier", "$id-$nom.$format",
169 $script, "$id_objet=$id&type=$id_objet",
170 array(_T('lien_supprimer')),
171 '',"function(r,status) {this.innerHTML = r; \$('form.form_upload_icon',this).async_upload(async_upload_icon);}") ."]"
172 : '')
173 . "</div>");
174 }
175 ?>