Completed
Push — master ( 15390a...45d748 )
by cam
06:41
created

filtres_ecrire.php ➔ parametres_css_prive()   B

Complexity

Conditions 6
Paths 8

Size

Total Lines 24
Code Lines 16

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 6
eloc 16
nc 8
nop 0
dl 0
loc 24
rs 8.5125
c 0
b 0
f 0
1
<?php
2
3
/***************************************************************************\
4
 *  SPIP, Systeme de publication pour l'internet                           *
5
 *                                                                         *
6
 *  Copyright (c) 2001-2017                                                *
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 utilisées au calcul des squelette du privé.
15
 *
16
 * @package SPIP\Core\Filtres
17
 */
18
if (!defined('_ECRIRE_INC_VERSION')) {
19
	return;
20
}
21
22
include_spip('inc/filtres_boites');
23
include_spip('inc/boutons');
24
include_spip('inc/pipelines_ecrire');
25
26
27
/**
28
 * Retourne les paramètres de personnalisation css de l'espace privé
29
 *
30
 * Ces paramètres sont (ltr et couleurs) ce qui permet une écriture comme :
31
 * generer_url_public('style_prive', parametres_css_prive())
32
 * qu'il est alors possible de récuperer dans le squelette style_prive.html avec
33
 *
34
 * #SET{claire,##ENV{couleur_claire,edf3fe}}
35
 * #SET{foncee,##ENV{couleur_foncee,3874b0}}
36
 * #SET{left,#ENV{ltr}|choixsiegal{left,left,right}}
37
 * #SET{right,#ENV{ltr}|choixsiegal{left,right,left}}
38
 *
39
 * @return string
40
 */
41
function parametres_css_prive() {
42
43
	$args = array();
44
	$args['v'] = $GLOBALS['spip_version_code'];
45
	$args['p'] = substr(md5($GLOBALS['meta']['plugin']), 0, 4);
46
	$args['themes'] = implode(',', lister_themes_prives());
47
	$args['ltr'] = $GLOBALS['spip_lang_left'];
48
	// un md5 des menus : si un menu change il faut maj la css
49
	$args['md5b'] = (function_exists('md5_boutons_plugins') ? md5_boutons_plugins() : '');
50
51
	$c = isset($GLOBALS['visiteur_session']['prefs']['couleur'])
52
		? $GLOBALS['visiteur_session']['prefs']['couleur']
53
		: 9;
54
55
	$couleurs = charger_fonction('couleurs', 'inc');
56
	parse_str($couleurs($c), $c);
57
	$args = array_merge($args, $c);
58
59
	if (_request('var_mode') == 'recalcul' or (defined('_VAR_MODE') and _VAR_MODE == 'recalcul')) {
60
		$args['var_mode'] = 'recalcul';
61
	}
62
63
	return http_build_query($args);
64
}
65
66
67
/**
68
 * Afficher le sélecteur de rubrique
69
 *
70
 * Il permet de placer un objet dans la hiérarchie des rubriques de SPIP
71
 *
72
 * @uses inc_chercher_rubrique_dist()
73
 *
74
 * @param string $titre
75
 * @param int $id_objet
76
 * @param int $id_parent
77
 * @param string $objet
78
 * @param int $id_secteur
79
 * @param bool $restreint
80
 * @param bool $actionable
81
 *   true : fournit le selecteur dans un form directement postable
82
 * @param bool $retour_sans_cadre
83
 * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|array? Also, consider making the array more specific, something like array<String>, or String[].

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

If the return type contains the type array, this check recommends the use of a more specific type like String[] or array<String>.

Loading history...
84
 */
85
function chercher_rubrique(
86
	$titre,
87
	$id_objet,
88
	$id_parent,
89
	$objet,
90
	$id_secteur,
91
	$restreint,
92
	$actionable = false,
93
	$retour_sans_cadre = false
94
) {
95
96
	include_spip('inc/autoriser');
97
	if (intval($id_objet) && !autoriser('modifier', $objet, $id_objet)) {
98
		return "";
99
	}
100
	if (!sql_countsel('spip_rubriques')) {
101
		return "";
102
	}
103
	$chercher_rubrique = charger_fonction('chercher_rubrique', 'inc');
104
	$form = $chercher_rubrique($id_parent, $objet, $restreint, ($objet == 'rubrique') ? $id_objet : 0);
105
106
	if ($id_parent == 0) {
107
		$logo = "racine-24.png";
108
	} elseif ($id_secteur == $id_parent) {
109
		$logo = "secteur-24.png";
110
	} else {
111
		$logo = "rubrique-24.png";
112
	}
113
114
	$confirm = "";
115
	if ($objet == 'rubrique') {
116
		// si c'est une rubrique-secteur contenant des breves, demander la
117
		// confirmation du deplacement
118
		$contient_breves = sql_countsel('spip_breves', "id_rubrique=" . intval($id_objet));
119
120
		if ($contient_breves > 0) {
121
			$scb = ($contient_breves > 1 ? 's' : '');
122
			$scb = _T('avis_deplacement_rubrique',
123
				array(
124
					'contient_breves' => $contient_breves,
125
					'scb' => $scb
126
				));
127
			$confirm .= "\n<div class='confirmer_deplacement verdana2'>"
128
				. "<div class='choix'><input type='checkbox' name='confirme_deplace' value='oui' id='confirme-deplace' /><label for='confirme-deplace'>"
129
				. $scb .
130
				"</label></div></div>\n";
131
		} else {
132
			$confirm .= "<input type='hidden' name='confirme_deplace' value='oui' />\n";
133
		}
134
	}
135
	$form .= $confirm;
136
	if ($actionable) {
137
		if (strpos($form, '<select') !== false) {
138
			$form .= "<div style='text-align: " . $GLOBALS['spip_lang_right'] . ";'>"
139
				. '<input class="fondo" type="submit" value="' . _T('bouton_choisir') . '"/>'
140
				. "</div>";
141
		}
142
		$form = "<input type='hidden' name='editer_$objet' value='oui' />\n" . $form;
143
		if ($action = charger_fonction("editer_$objet", "action", true)) {
0 ignored issues
show
Unused Code introduced by
$action is not used, you could remove the assignment.

This check looks for variable assignements that are either overwritten by other assignments or where the variable is not used subsequently.

$myVar = 'Value';
$higher = false;

if (rand(1, 6) > 3) {
    $higher = true;
} else {
    $higher = false;
}

Both the $myVar assignment in line 1 and the $higher assignment in line 2 are dead. The first because $myVar is never used and the second because $higher is always overwritten for every possible time line.

Loading history...
144
			$form = generer_action_auteur("editer_$objet", $id_objet, self(), $form,
145
				" method='post' class='submit_plongeur'");
146
		} else {
147
			$form = generer_action_auteur("editer_objet", "$objet/$id_objet", self(), $form,
148
				" method='post' class='submit_plongeur'");
149
		}
150
	}
151
152
	if ($retour_sans_cadre) {
153
		return $form;
154
	}
155
156
	include_spip('inc/presentation');
157
158
	return debut_cadre_couleur($logo, true, "", $titre) . $form . fin_cadre_couleur(true);
0 ignored issues
show
Unused Code introduced by
The call to fin_cadre_couleur() has too many arguments starting with true.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
159
160
}
161
162
163
/**
164
 * Tester si le site peut avoir des visiteurs
165
 *
166
 * @param bool $past
167
 *   si true, prendre en compte le fait que le site a *deja* des visiteurs
168
 *   comme le droit d'en avoir de nouveaux
169
 * @param bool $accepter
170
 * @return bool
0 ignored issues
show
Documentation introduced by
Should the return type not be boolean|integer?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
171
 */
172
function avoir_visiteurs($past = false, $accepter = true) {
173
	if ($GLOBALS['meta']["forums_publics"] == 'abo') {
174
		return true;
175
	}
176
	if ($accepter and $GLOBALS['meta']["accepter_visiteurs"] <> 'non') {
177
		return true;
178
	}
179
	if (sql_countsel('spip_articles', "accepter_forum='abo'")) {
180
		return true;
181
	}
182
	if (!$past) {
183
		return false;
184
	}
185
186
	return sql_countsel('spip_auteurs',
187
		"statut NOT IN ('0minirezo','1comite', '5poubelle')
188
	                    AND (statut<>'nouveau' OR prefs NOT IN ('0minirezo','1comite', '5poubelle'))");
189
}
190
191
/**
192
 * Lister les status d'article visibles dans l'espace prive
193
 * en fonction du statut de l'auteur
194
 *
195
 * Pour l'extensibilie de SPIP, on se repose sur autoriser('voir','article')
196
 * en testant un à un les status présents en base
197
 *
198
 * On mémorise en static pour éviter de refaire plusieurs fois.
199
 *
200
 * @param string $statut_auteur
201
 * @return array
202
 */
203
function statuts_articles_visibles($statut_auteur) {
204
	static $auth = array();
205
	if (!isset($auth[$statut_auteur])) {
206
		$auth[$statut_auteur] = array();
207
		$statuts = array_map('reset', sql_allfetsel('distinct statut', 'spip_articles'));
208
		foreach ($statuts as $s) {
209
			if (autoriser('voir', 'article', 0, array('statut' => $statut_auteur), array('statut' => $s))) {
210
				$auth[$statut_auteur][] = $s;
211
			}
212
		}
213
	}
214
215
	return $auth[$statut_auteur];
216
}
217
218
/**
219
 * Traduire le statut technique de l'auteur en langage compréhensible
220
 *
221
 * Si $statut=='nouveau' et que le statut en attente est fourni,
222
 * le prendre en compte en affichant que l'auteur est en attente
223
 *
224
 * @param string $statut
225
 * @param string $attente
226
 * @return string
227
 */
228
function traduire_statut_auteur($statut, $attente = "") {
229
	$plus = "";
230
	if ($statut == 'nouveau') {
231
		if ($attente) {
232
			$statut = $attente;
233
			$plus = " (" . _T('info_statut_auteur_a_confirmer') . ")";
234
		} else {
235
			return _T('info_statut_auteur_a_confirmer');
236
		}
237
	}
238
239
	$recom = array(
240
		"info_administrateurs" => _T('item_administrateur_2'),
241
		"info_redacteurs" => _T('intem_redacteur'),
242
		"info_visiteurs" => _T('item_visiteur'),
243
		'5poubelle' => _T('texte_statut_poubelle'), // bouh
244
	);
245
	if (isset($recom[$statut])) {
246
		return $recom[$statut] . $plus;
247
	}
248
249
	// retrouver directement par le statut sinon
250
	if ($t = array_search($statut, $GLOBALS['liste_des_statuts'])) {
251
		if (isset($recom[$t])) {
252
			return $recom[$t] . $plus;
253
		}
254
255
		return _T($t) . $plus;
256
	}
257
258
	// si on a pas reussi a le traduire, retournons la chaine telle quelle
259
	// c'est toujours plus informatif que rien du tout
260
	return $statut;
261
}
262
263
/**
264
 * Afficher la mention des autres auteurs ayant modifié un objet
265
 *
266
 * @param int $id_objet
267
 * @param string $objet
268
 * @return string
269
 */
270
function afficher_qui_edite($id_objet, $objet) {
271
	static $qui = array();
272
	if (isset($qui[$objet][$id_objet])) {
273
		return $qui[$objet][$id_objet];
274
	}
275
276
	if ($GLOBALS['meta']['articles_modif'] == 'non') {
277
		return $qui[$objet][$id_objet] = '';
278
	}
279
280
	include_spip('inc/drapeau_edition');
281
	$modif = mention_qui_edite($id_objet, $objet);
282
	if (!$modif) {
283
		return $qui[$objet][$id_objet] = '';
284
	}
285
286
	include_spip('base/objets');
287
	$infos = lister_tables_objets_sql(table_objet_sql($objet));
288
	if (isset($infos['texte_signale_edition'])) {
289
		return $qui[$objet][$id_objet] = _T($infos['texte_signale_edition'], $modif);
290
	}
291
292
	return $qui[$objet][$id_objet] = _T('info_qui_edite', $modif);
293
}
294
295
/**
296
 * Lister les statuts des auteurs
297
 *
298
 * @param string $quoi
299
 *   - redacteurs : retourne les statuts des auteurs au moins redacteur,
300
 *     tels que defini par AUTEURS_MIN_REDAC
301
 *   - visiteurs : retourne les statuts des autres auteurs, cad les visiteurs
302
 *     et autres statuts perso
303
 *   - tous : retourne tous les statuts connus
304
 * @param bool $en_base
305
 *   si true, ne retourne strictement que les status existants en base
306
 *   dans tous les cas, les statuts existants en base sont inclus
307
 * @return array
308
 */
309
function auteurs_lister_statuts($quoi = 'tous', $en_base = true) {
310
	if (!defined('AUTEURS_MIN_REDAC')) {
311
		define('AUTEURS_MIN_REDAC', "0minirezo,1comite,5poubelle");
312
	}
313
314
	switch ($quoi) {
315
		case "redacteurs":
316
			$statut = AUTEURS_MIN_REDAC;
317
			$statut = explode(',', $statut);
318 View Code Duplication
			if ($en_base) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
319
				$check = array_map('reset', sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)));
320
				$retire = array_diff($statut, $check);
321
				$statut = array_diff($statut, $retire);
322
			}
323
324
			return array_unique($statut);
325
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
326
		case "visiteurs":
327
			$statut = array();
328
			$exclus = AUTEURS_MIN_REDAC;
329
			$exclus = explode(',', $exclus);
330
			if (!$en_base) {
331
				// prendre aussi les statuts de la table des status qui ne sont pas dans le define
332
				$statut = array_diff(array_values($GLOBALS['liste_des_statuts']), $exclus);
333
			}
334
			$s_complement = array_map('reset',
335
				sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $exclus, 'NOT')));
336
337
			return array_unique(array_merge($statut, $s_complement));
338
			break;
0 ignored issues
show
Unused Code introduced by
break is not strictly necessary here and could be removed.

The break statement is not necessary if it is preceded for example by a return statement:

switch ($x) {
    case 1:
        return 'foo';
        break; // This break is not necessary and can be left off.
}

If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive.

Loading history...
339
		default:
340
		case "tous":
0 ignored issues
show
Unused Code introduced by
case 'tous': $statut...ue($statut); break; does not seem to be reachable.

This check looks for unreachable code. It uses sophisticated control flow analysis techniques to find statements which will never be executed.

Unreachable code is most often the result of return, die or exit statements that have been added for debug purposes.

function fx() {
    try {
        doSomething();
        return true;
    }
    catch (\Exception $e) {
        return false;
    }

    return false;
}

In the above example, the last return false will never be executed, because a return statement has already been met in every possible execution path.

Loading history...
341
			$statut = array_values($GLOBALS['liste_des_statuts']);
342
			$s_complement = array_map('reset',
343
				sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut, 'NOT')));
344
			$statut = array_merge($statut, $s_complement);
345 View Code Duplication
			if ($en_base) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
346
				$check = array_map('reset', sql_allfetsel('DISTINCT statut', 'spip_auteurs', sql_in('statut', $statut)));
347
				$retire = array_diff($statut, $check);
348
				$statut = array_diff($statut, $retire);
349
			}
350
351
			return array_unique($statut);
352
			break;
353
	}
354
355
	// on arrive jamais ici
356
	return array_values($GLOBALS['liste_des_statuts']);
357
}
358
359
/**
360
 * Déterminer la rubrique pour la création d'un objet heuristique
361
 *
362
 * Rubrique courante si possible,
363
 * - sinon rubrique administrée pour les admin restreint
364
 * - sinon première rubrique de premier niveau autorisée que l'on trouve
365
 *
366
 * @param int $id_rubrique Identifiant de rubrique (si connu)
367
 * @param string $objet Objet en cours de création
368
 * @return int             Identifiant de la rubrique dans laquelle créer l'objet
369
 */
370
function trouver_rubrique_creer_objet($id_rubrique, $objet) {
371
372
	if (!$id_rubrique and defined('_CHOIX_RUBRIQUE_PAR_DEFAUT') and _CHOIX_RUBRIQUE_PAR_DEFAUT) {
373
		$in = !count($GLOBALS['connect_id_rubrique'])
374
			? ''
375
			: (" AND " . sql_in('id_rubrique', $GLOBALS['connect_id_rubrique']));
376
377
		// on tente d'abord l'ecriture a la racine dans le cas des rubriques uniquement
378
		if ($objet == 'rubrique') {
379
			$id_rubrique = 0;
380
		} else {
381
			$id_rubrique = sql_getfetsel('id_rubrique', 'spip_rubriques', "id_parent=0$in", '', "id_rubrique DESC", 1);
382
		}
383
384
		if (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique)) {
385
			// manque de chance, la rubrique n'est pas autorisee, on cherche un des secteurs autorises
386
			$res = sql_select("id_rubrique", "spip_rubriques", "id_parent=0");
387
			while (!autoriser("creer{$objet}dans", 'rubrique', $id_rubrique) && $row_rub = sql_fetch($res)) {
388
				$id_rubrique = $row_rub['id_rubrique'];
389
			}
390
		}
391
	}
392
393
	return $id_rubrique;
394
}
395
396
/**
397
 * Afficher le lien de redirection d'un article virtuel si il y a lieu
398
 * (rien si l'article n'est pas redirige)
399
 *
400
 * @param string $virtuel
401
 * @return string
402
 */
403
function lien_article_virtuel($virtuel) {
404
	include_spip('inc/lien');
405
	if (!$virtuel = virtuel_redirige($virtuel)) {
406
		return '';
407
	}
408
409
	return propre("[->" . $virtuel . "]");
410
}
411
412
413
/**
414
 * Filtre pour générer un lien vers un flux RSS privé
415
 *
416
 * Le RSS est protegé par un hash de faible sécurité
417
 *
418
 * @example
419
 *     - `[(#VAL{a_suivre}|bouton_spip_rss)]`
420
 *     - `[(#VAL{signatures}|bouton_spip_rss{#ARRAY{id_article,#ID_ARTICLE}})]`
421
 *
422
 * @filtre
423
 * @uses param_low_sec()
424
 * @param string $op
425
 * @param array $args
426
 * @param string $lang
427
 * @param string $title
428
 * @return string
429
 *     Code HTML du lien
430
 */
431
function bouton_spip_rss($op, $args = array(), $lang = '', $title = 'RSS') {
432
	include_spip('inc/acces');
433
	$clic = http_img_pack('feed.png', 'RSS', '', $title);
434
	$args = param_low_sec($op, $args, $lang, 'rss');
435
	$url = generer_url_public('rss', $args);
436
437
	return "<a style='float: " . $GLOBALS['spip_lang_right'] . ";' href='$url'>$clic</a>";
438
}
439
440
441
/**
442
 * Vérifier la présence d'alertes pour les auteur
443
 *
444
 * @param int $id_auteur
445
 * @return string
0 ignored issues
show
Documentation introduced by
Should the return type not be string|null?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
446
 */
447
function alertes_auteur($id_auteur) {
448
449
	$alertes = array();
450
451
	if (isset($GLOBALS['meta']['message_crash_tables'])
452
		and autoriser('detruire', null, null, $id_auteur)
453
	) {
454
		include_spip('genie/maintenance');
455
		if ($msg = message_crash_tables()) {
456
			$alertes[] = $msg;
457
		}
458
	}
459
460
	if (isset($GLOBALS['meta']['message_crash_plugins'])
461
		and $GLOBALS['meta']['message_crash_plugins']
462
		and autoriser('configurer', '_plugins', null, $id_auteur)
463
		and is_array($msg = unserialize($GLOBALS['meta']['message_crash_plugins']))
464
	) {
465
		$msg = implode(', ', array_map('joli_repertoire', array_keys($msg)));
466
		$alertes[] = _T('plugins_erreur', array('plugins' => $msg));
467
	}
468
469
	$a = isset($GLOBALS['meta']['message_alertes_auteurs']) ? $GLOBALS['meta']['message_alertes_auteurs'] : '';
470
	if ($a
471
		and is_array($a = unserialize($a))
472
		and count($a)
473
	) {
474
		$update = false;
475
		if (isset($a[$GLOBALS['visiteur_session']['statut']])) {
476
			$alertes = array_merge($alertes, $a[$GLOBALS['visiteur_session']['statut']]);
477
			unset($a[$GLOBALS['visiteur_session']['statut']]);
478
			$update = true;
479
		}
480
		if (isset($a[''])) {
481
			$alertes = array_merge($alertes, $a['']);
482
			unset($a['']);
483
			$update = true;
484
		}
485
		if ($update) {
486
			ecrire_meta("message_alertes_auteurs", serialize($a));
487
		}
488
	}
489
490
	if (isset($GLOBALS['meta']['plugin_erreur_activation'])
491
		and autoriser('configurer', '_plugins', null, $id_auteur)
492
	) {
493
		include_spip('inc/plugin');
494
		$alertes[] = plugin_donne_erreurs();
495
	}
496
497
	$alertes = pipeline(
498
		'alertes_auteur',
499
		array(
500
			'args' => array(
501
				'id_auteur' => $id_auteur,
502
				'exec' => _request('exec'),
503
			),
504
			'data' => $alertes
505
		)
506
	);
507
508
	if ($alertes = array_filter($alertes)) {
509
		return "<div class='wrap-messages-alertes'><div class='messages-alertes'>" .
510
		join(' | ', $alertes)
511
		. "</div></div>";
512
	}
513
}
514
515
/**
516
 * Filtre pour afficher les rubriques enfants d'une rubrique
517
 *
518
 * @param int $id_rubrique
519
 * @return string
520
 */
521
function filtre_afficher_enfant_rub_dist($id_rubrique) {
522
	include_spip('inc/presenter_enfants');
523
524
	return afficher_enfant_rub(intval($id_rubrique));
525
}
526
527
/**
528
 * Afficher un petit "i" pour lien vers autre page
529
 *
530
 * @param string $lien
531
 *    URL du lien desire
532
 * @param string $titre
533
 *    Titre au survol de l'icone pointant le lien
534
 * @param string $titre_lien
535
 *    Si present, ajoutera en plus apres l'icone
536
 *    un lien simple, vers la meme URL,
537
 *    avec le titre indique
538
 *
539
 * @return string
540
 */
541
function afficher_plus_info($lien, $titre = "+", $titre_lien = "") {
542
	$titre = attribut_html($titre);
543
	$icone = "\n<a href='$lien' title='$titre' class='plus_info'>" .
544
		http_img_pack("information-16.png", $titre) . "</a>";
545
546
	if (!$titre_lien) {
547
		return $icone;
548
	} else {
549
		return $icone . "\n<a href='$lien'>$titre_lien</a>";
550
	}
551
}
552
553
/**
554
 * Lister les id objet_source associés à l'objet id_objet
555
 * via la table de lien objet_lien
556
 *
557
 * Utilisé pour les listes de #FORMULAIRE_EDITER_LIENS
558
 *
559
 * @param string $objet_source
560
 * @param string $objet
561
 * @param int $id_objet
562
 * @param string $objet_lien
563
 * @return array
564
 */
565
function lister_objets_lies($objet_source, $objet, $id_objet, $objet_lien) {
566
	include_spip('action/editer_liens');
567
	$l = array();
568
	// quand $objet == $objet_lien == $objet_source on reste sur le cas par defaut de $objet_lien == $objet_source
569 View Code Duplication
	if ($objet_lien == $objet and $objet_lien !== $objet_source) {
0 ignored issues
show
Duplication introduced by
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
570
		$res = objet_trouver_liens(array($objet => $id_objet), array($objet_source => '*'));
571
	} else {
572
		$res = objet_trouver_liens(array($objet_source => '*'), array($objet => $id_objet));
573
	}
574
	while ($row = array_shift($res)) {
575
		$l[] = $row[$objet_source];
576
	}
577
578
	return $l;
579
}
580