|
1
|
|
|
<?php |
|
2
|
|
|
|
|
3
|
|
|
/***************************************************************************\ |
|
4
|
|
|
* SPIP, Systeme de publication pour l'internet * |
|
5
|
|
|
* * |
|
6
|
|
|
* Copyright (c) 2001-2019 * |
|
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
|
|
|
/** |
|
14
|
|
|
* Fonctions génériques pour les balises `#LOGO_XXXX` |
|
15
|
|
|
* |
|
16
|
|
|
* @package SPIP\Core\Compilateur\Balises |
|
17
|
|
|
**/ |
|
18
|
|
|
|
|
19
|
|
|
if (!defined('_ECRIRE_INC_VERSION')) { |
|
20
|
|
|
return; |
|
21
|
|
|
} |
|
22
|
|
|
|
|
23
|
|
|
|
|
24
|
|
|
/** |
|
25
|
|
|
* Compile la balise dynamique `#LOGO_xx` qui retourne le code HTML |
|
26
|
|
|
* pour afficher l'image de logo d'un objet éditorial de SPIP. |
|
27
|
|
|
* |
|
28
|
|
|
* Le type d'objet est récupéré dans le nom de la balise, tel que |
|
29
|
|
|
* `LOGO_ARTICLE` ou `LOGO_SITE`. |
|
30
|
|
|
* |
|
31
|
|
|
* Ces balises ont quelques options : |
|
32
|
|
|
* |
|
33
|
|
|
* - La balise peut aussi demander explicitement le logo normal ou de survol, |
|
34
|
|
|
* avec `LOGO_ARTICLE_NORMAL` ou `LOGO_ARTICLE_SURVOL`. |
|
35
|
|
|
* - On peut demander un logo de rubrique en absence de logo sur l'objet éditorial |
|
36
|
|
|
* demandé avec `LOGO_ARTICLE_RUBRIQUE` |
|
37
|
|
|
* - `LOGO_ARTICLE*` ajoute un lien sur l'image du logo vers l'objet éditorial |
|
38
|
|
|
* - `LOGO_ARTICLE**` retourne le nom du fichier de logo. |
|
39
|
|
|
* - `LOGO_ARTICLE{right}`. Valeurs possibles : top left right center bottom |
|
40
|
|
|
* - `LOGO_DOCUMENT{icone}`. Valeurs possibles : auto icone apercu vignette |
|
41
|
|
|
* - `LOGO_ARTICLE{200, 0}`. Redimensionnement indiqué |
|
42
|
|
|
* |
|
43
|
|
|
* @balise |
|
44
|
|
|
* @uses logo_survol() |
|
45
|
|
|
* @example |
|
46
|
|
|
* ``` |
|
47
|
|
|
* #LOGO_ARTICLE |
|
48
|
|
|
* ``` |
|
49
|
|
|
* |
|
50
|
|
|
* @param Champ $p |
|
51
|
|
|
* Pile au niveau de la balise |
|
52
|
|
|
* @return Champ |
|
53
|
|
|
* Pile complétée par le code à générer |
|
54
|
|
|
*/ |
|
55
|
|
|
function balise_LOGO__dist($p) { |
|
56
|
|
|
|
|
57
|
|
|
preg_match(',^LOGO_([A-Z_]+?)(|_NORMAL|_SURVOL|_RUBRIQUE)$,i', $p->nom_champ, $regs); |
|
58
|
|
|
$type = strtolower($regs[1]); |
|
59
|
|
|
$suite_logo = $regs[2]; |
|
60
|
|
|
|
|
61
|
|
|
// cas de #LOGO_SITE_SPIP |
|
62
|
|
|
if ($type == 'site_spip') { |
|
63
|
|
|
$type = 'site'; |
|
64
|
|
|
$_id_objet = "\"'0'\""; |
|
65
|
|
|
} |
|
66
|
|
|
|
|
67
|
|
|
$id_objet = id_table_objet($type); |
|
68
|
|
|
if (!isset($_id_objet)) { |
|
69
|
|
|
$_id_objet = champ_sql($id_objet, $p); |
|
70
|
|
|
} |
|
71
|
|
|
|
|
72
|
|
|
$fichier = ($p->etoile === '**') ? -1 : 0; |
|
73
|
|
|
$coord = array(); |
|
74
|
|
|
$align = $lien = ''; |
|
75
|
|
|
$mode_logo = ''; |
|
76
|
|
|
|
|
77
|
|
|
if ($p->param and !$p->param[0][0]) { |
|
78
|
|
|
$params = $p->param[0]; |
|
79
|
|
|
array_shift($params); |
|
80
|
|
|
foreach ($params as $a) { |
|
81
|
|
|
if ($a[0]->type === 'texte') { |
|
82
|
|
|
$n = $a[0]->texte; |
|
83
|
|
|
if (is_numeric($n)) { |
|
84
|
|
|
$coord[] = $n; |
|
85
|
|
|
} elseif (in_array($n, array('top', 'left', 'right', 'center', 'bottom'))) { |
|
86
|
|
|
$align = $n; |
|
87
|
|
|
} elseif (in_array($n, array('auto', 'icone', 'apercu', 'vignette'))) { |
|
88
|
|
|
$mode_logo = $n; |
|
89
|
|
|
} |
|
90
|
|
|
} else { |
|
91
|
|
|
$lien = calculer_liste($a, $p->descr, $p->boucles, $p->id_boucle); |
|
92
|
|
|
} |
|
93
|
|
|
} |
|
94
|
|
|
} |
|
95
|
|
|
|
|
96
|
|
|
$coord_x = !$coord ? 0 : intval(array_shift($coord)); |
|
97
|
|
|
$coord_y = !$coord ? 0 : intval(array_shift($coord)); |
|
98
|
|
|
|
|
99
|
|
|
if ($p->etoile === '*') { |
|
100
|
|
|
include_spip('balise/url_'); |
|
101
|
|
|
$lien = generer_generer_url_arg($type, $p, $_id_objet); |
|
102
|
|
|
} |
|
103
|
|
|
|
|
104
|
|
|
$connect = $p->id_boucle ? $p->boucles[$p->id_boucle]->sql_serveur : ''; |
|
105
|
|
|
if ($type == 'document') { |
|
106
|
|
|
$qconnect = _q($connect); |
|
107
|
|
|
$doc = "quete_document($_id_objet, $qconnect)"; |
|
108
|
|
|
if ($fichier) { |
|
109
|
|
|
$code = "quete_logo_file($doc, $qconnect)"; |
|
110
|
|
|
} else { |
|
111
|
|
|
$code = "quete_logo_document($doc, " . ($lien ? $lien : "''") . ", '$align', '$mode_logo', $coord_x, $coord_y, $qconnect)"; |
|
112
|
|
|
} |
|
113
|
|
|
// (x=non-faux ? y : '') pour affecter x en retournant y |
|
114
|
|
|
if ($p->descr['documents']) { |
|
115
|
|
|
$code = '(($doublons["documents"] .= ",". ' |
|
116
|
|
|
. $_id_objet |
|
117
|
|
|
. ") ? $code : '')"; |
|
118
|
|
|
} |
|
119
|
|
|
} elseif ($connect) { |
|
120
|
|
|
$code = "''"; |
|
121
|
|
|
spip_log('Les logos distants ne sont pas prevus'); |
|
122
|
|
|
} else { |
|
123
|
|
|
$code = logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $lien, $p, $suite_logo); |
|
124
|
|
|
} |
|
125
|
|
|
|
|
126
|
|
|
// demande de reduction sur logo avec ecriture spip 2.1 : #LOGO_xxx{200, 0} |
|
127
|
|
|
if ($coord_x or $coord_y) { |
|
128
|
|
|
$code = "filtrer('image_graver',filtrer('image_reduire'," . $code . ", '$coord_x', '$coord_y'))"; |
|
129
|
|
|
} |
|
130
|
|
|
|
|
131
|
|
|
$p->code = $code; |
|
132
|
|
|
$p->interdire_scripts = false; |
|
133
|
|
|
|
|
134
|
|
|
return $p; |
|
135
|
|
|
} |
|
136
|
|
|
|
|
137
|
|
|
/** |
|
138
|
|
|
* Calcule le code HTML pour l'image d'un logo |
|
139
|
|
|
* |
|
140
|
|
|
* @param string $id_objet |
|
141
|
|
|
* Nom de la clé primaire de l'objet (id_article, ...) |
|
142
|
|
|
* @param string $_id_objet |
|
143
|
|
|
* Code pour la compilation permettant de récupérer la valeur de l'identifiant |
|
144
|
|
|
* @param string $type |
|
145
|
|
|
* Type d'objet |
|
146
|
|
|
* @param string $align |
|
147
|
|
|
* Alignement demandé du logo |
|
148
|
|
|
* @param int $fichier |
|
149
|
|
|
* - -1 pour retourner juste le chemin de l'image |
|
150
|
|
|
* - 0 pour retourner le code HTML de l'image |
|
151
|
|
|
* @param string $lien |
|
|
|
|
|
|
152
|
|
|
* Lien pour encadrer l'image avec si présent |
|
153
|
|
|
* @param Champ $p |
|
154
|
|
|
* Pile au niveau de la balise |
|
155
|
|
|
* @param string $suite |
|
156
|
|
|
* Suite éventuelle de la balise logo, telle que `_SURVOL`, `_NORMAL` ou `_RUBRIQUE`. |
|
157
|
|
|
* @return string |
|
158
|
|
|
* Code compilé retournant le chemin du logo ou le code HTML du logo. |
|
159
|
|
|
**/ |
|
160
|
|
|
function logo_survol($id_objet, $_id_objet, $type, $align, $fichier, $_lien, $p, $suite) { |
|
161
|
|
|
$code = "quete_logo('$id_objet', '" . |
|
162
|
|
|
(($suite == '_SURVOL') ? 'off' : |
|
163
|
|
|
(($suite == '_NORMAL') ? 'on' : 'ON')) . |
|
164
|
|
|
"', $_id_objet," . |
|
165
|
|
|
(($suite == '_RUBRIQUE') ? |
|
166
|
|
|
champ_sql('id_rubrique', $p) : |
|
167
|
|
|
(($type == 'rubrique') ? "quete_parent($_id_objet)" : "''")) . |
|
168
|
|
|
', ' . intval($fichier) . ')'; |
|
169
|
|
|
|
|
170
|
|
|
if ($fichier) { |
|
171
|
|
|
return $code; |
|
172
|
|
|
} |
|
173
|
|
|
|
|
174
|
|
|
$align = preg_replace(",\W,", "", $align); |
|
175
|
|
|
|
|
176
|
|
|
return "quete_html_logo($code, '$align', " .($_lien ? $_lien : "''") .")"; |
|
177
|
|
|
} |
|
178
|
|
|
|
This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.
Consider the following example. The parameter
$italyis not defined by the methodfinale(...).The most likely cause is that the parameter was removed, but the annotation was not.