[SPIP][PLUGINS] v3.0-->v3.2
[lhc/web/www.git] / www / ecrire / balise / info_.php
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 génériques pour les balises `#INFO_XXXX`
15 *
16 * @package SPIP\Core\Compilateur\Balises
17 **/
18
19 if (!defined('_ECRIRE_INC_VERSION')) {
20 return;
21 }
22
23 /**
24 * Compile la balise dynamique `#INFO_xx` qui génère n'importe quelle
25 * information pour un objet
26 *
27 * Signature : `#INFO_n{objet,id_objet}` où n est une colonne sur la table
28 * SQL de l'objet.
29 *
30 * @balise
31 * @link http://www.spip.net/5544
32 * @uses generer_info_entite()
33 * @example
34 * ```
35 * #INFO_TITRE{article, #ENV{id_article}}
36 * ```
37 * @param Champ $p
38 * Pile au niveau de la balise
39 * @return Champ
40 * Pile complétée par le code à générer
41 */
42 function balise_INFO__dist($p) {
43 $info = $p->nom_champ;
44 $type_objet = interprete_argument_balise(1, $p);
45 $id_objet = interprete_argument_balise(2, $p);
46 if ($info === 'INFO_' or !$type_objet or !$id_objet) {
47 $msg = _T('zbug_balise_sans_argument', array('balise' => ' INFO_'));
48 erreur_squelette($msg, $p);
49 $p->interdire_scripts = true;
50
51 return $p;
52 } else {
53 $info_sql = strtolower(substr($info, 5));
54 $code = "generer_info_entite($id_objet, $type_objet, '$info_sql'" . ($p->etoile ? "," . _q($p->etoile) : "") . ")";
55 $p->code = champ_sql($info, $p, $code);
56 $p->interdire_scripts = true;
57
58 return $p;
59 }
60 }