[SPIP] ~spip v3.2.0-->v3.2.1
[lhc/web/www.git] / www / plugins-dist / mots / base / mots.php
1 <?php
2
3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
5 * *
6 * Copyright (c) 2001-2016 *
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 * Déclarations relatives à la base de données
15 *
16 * @package SPIP\Mots\Pipelines
17 **/
18 if (!defined('_ECRIRE_INC_VERSION')) {
19 return;
20 }
21
22 /**
23 * Déclarer les interfaces des tables mots et groupes de mots pour le compilateur
24 *
25 * @pipeline declarer_tables_interfaces
26 * @param array $interfaces
27 * Déclarations d'interface pour le compilateur
28 * @return array
29 * Déclarations d'interface pour le compilateur
30 */
31 function mots_declarer_tables_interfaces($interfaces) {
32
33 $interfaces['table_des_tables']['mots'] = 'mots';
34 $interfaces['table_des_tables']['groupes_mots'] = 'groupes_mots';
35
36 $interfaces['exceptions_des_tables']['mots']['titre_mot'] = 'titre';
37 $interfaces['table_des_traitements']['TYPE']['mots'] = _TRAITEMENT_TYPO_SANS_NUMERO;
38
39 $interfaces['exceptions_des_jointures']['titre_mot'] = array('spip_mots', 'titre');
40 $interfaces['exceptions_des_jointures']['type_mot'] = array('spip_mots', 'type');
41 $interfaces['exceptions_des_jointures']['id_mot_syndic'] = array('spip_mots_liens', 'id_mot');
42 $interfaces['exceptions_des_jointures']['titre_mot_syndic'] = array('spip_mots', 'titre');
43 $interfaces['exceptions_des_jointures']['type_mot_syndic'] = array('spip_mots', 'type');
44 $interfaces['exceptions_des_jointures']['spip_articles']['id_groupe'] = array('spip_mots', 'id_groupe');
45 $interfaces['exceptions_des_jointures']['spip_rubriques']['id_groupe'] = array('spip_mots', 'id_groupe');
46 $interfaces['exceptions_des_jointures']['spip_syndic']['id_groupe'] = array('spip_mots', 'id_groupe');
47
48 return $interfaces;
49 }
50
51
52 /**
53 * Déclarer les tables auxiliaires des mots
54 *
55 * @pipeline declarer_tables_auxiliaires
56 * @param array $tables_auxiliaires
57 * Description des tables
58 * @return array
59 * Description complétée des tables
60 */
61 function mots_declarer_tables_auxiliaires($tables_auxiliaires) {
62
63 $spip_mots_liens = array(
64 'id_mot' => "bigint(21) DEFAULT '0' NOT NULL",
65 'id_objet' => "bigint(21) DEFAULT '0' NOT NULL",
66 'objet' => "VARCHAR (25) DEFAULT '' NOT NULL"
67 );
68
69 $spip_mots_liens_key = array(
70 'PRIMARY KEY' => 'id_mot,id_objet,objet',
71 'KEY id_mot' => 'id_mot',
72 'KEY id_objet' => 'id_objet',
73 'KEY objet' => 'objet',
74 );
75
76 $tables_auxiliaires['spip_mots_liens'] =
77 array('field' => &$spip_mots_liens, 'key' => &$spip_mots_liens_key);
78
79 return $tables_auxiliaires;
80 }
81
82
83 /**
84 * Déclarer les objets éditoriaux des mots et groupes de mots
85 *
86 * @pipeline declarer_tables_objets_sql
87 * @param array $tables
88 * Description des tables
89 * @return array
90 * Description complétée des tables
91 */
92 function mots_declarer_tables_objets_sql($tables) {
93 $tables['spip_mots'] = array(
94 'type' => 'mot',
95 'type_surnoms' => array('mot-cle'), // pour les icones...
96 'texte_retour' => 'icone_retour',
97 'texte_objets' => 'public:mots_clefs',
98 'texte_objet' => 'public:mots_clef',
99 'texte_modifier' => 'mots:icone_modifier_mot',
100 'texte_ajouter' => 'titre_ajouter_un_mot', // # A deplacer
101 'texte_creer' => 'titre_ajouter_un_mot',
102 'texte_logo_objet' => 'mots:logo_mot_cle',
103 'texte_creer_associer' => 'mots:creer_et_associer_un_mot',
104 'info_aucun_objet' => 'mots:info_aucun_mot_cle',
105 'info_1_objet' => 'info_1_mot_cle',
106 'info_nb_objets' => 'info_nb_mots_cles',
107 'titre' => "titre, '' AS lang",
108 'date' => 'date',
109 'principale' => 'oui',
110 'field' => array(
111 'id_mot' => 'bigint(21) NOT NULL',
112 'titre' => "text DEFAULT '' NOT NULL",
113 'descriptif' => "text DEFAULT '' NOT NULL",
114 'texte' => "longtext DEFAULT '' NOT NULL",
115 'id_groupe' => 'bigint(21) DEFAULT 0 NOT NULL',
116 'type' => "text DEFAULT '' NOT NULL",
117 'maj' => 'TIMESTAMP'
118 ),
119 'key' => array(
120 'PRIMARY KEY' => 'id_mot',
121 'KEY id_groupe' => 'id_groupe'
122 ),
123 'rechercher_champs' => array(
124 'titre' => 8,
125 'texte' => 1,
126 'descriptif' => 5
127 ),
128 'tables_jointures' => array(#'mots_liens' // declare generiquement ci dessous
129 ),
130 'champs_versionnes' => array('titre', 'descriptif', 'texte', 'id_groupe'),
131 );
132
133 $tables['spip_groupes_mots'] = array(
134 'table_objet_surnoms' => array(
135 'groupemot',
136 'groupe_mots'
137 /*hum*/,
138 'groupe_mot'
139 /* hum*/,
140 'groupe'
141 /*hum (EXPOSE)*/
142 ),
143 'type' => 'groupe_mots',
144 'type_surnoms' => array('groupes_mot', 'groupemot', 'groupe_mot'),
145 'texte_retour' => 'icone_retour',
146 'texte_objets' => 'mots:titre_groupes_mots',
147 'texte_objet' => 'mots:titre_groupe_mots',
148 'texte_modifier' => 'mots:icone_modif_groupe_mots',
149 'texte_creer' => 'mots:icone_creation_groupe_mots',
150 'texte_logo_objet' => 'mots:logo_groupe',
151 'info_aucun_objet' => 'mots:info_aucun_groupemots',
152 'info_1_objet' => 'mots:info_1_groupemots',
153 'info_nb_objets' => 'mots:info_nb_groupemots',
154 'titre' => "titre, '' AS lang",
155 'date' => 'date',
156 'principale' => 'oui',
157 'page' => '', // pas de page publique pour les groupes
158 'field' => array(
159 'id_groupe' => 'bigint(21) NOT NULL',
160 'titre' => "text DEFAULT '' NOT NULL",
161 'descriptif' => "text DEFAULT '' NOT NULL",
162 'texte' => "longtext DEFAULT '' NOT NULL",
163 'unseul' => "varchar(3) DEFAULT '' NOT NULL",
164 'obligatoire' => "varchar(3) DEFAULT '' NOT NULL",
165 'tables_liees' => "text DEFAULT '' NOT NULL",
166 'minirezo' => "varchar(3) DEFAULT '' NOT NULL",
167 'comite' => "varchar(3) DEFAULT '' NOT NULL",
168 'forum' => "varchar(3) DEFAULT '' NOT NULL",
169 'maj' => 'TIMESTAMP'
170 ),
171 'key' => array(
172 'PRIMARY KEY' => 'id_groupe'
173 ),
174 'rechercher_champs' => array(
175 'titre' => 8,
176 'texte' => 1,
177 'descriptif' => 5
178 ),
179 'tables_jointures' => array(
180 'mots'
181 ),
182 'champs_versionnes' => array(
183 'titre',
184 'descriptif',
185 'texte',
186 'un_seul',
187 'obligatoire',
188 'tables_liees',
189 'minirezo',
190 'forum',
191 'comite'
192 ),
193 );
194
195 // jointures sur les mots pour tous les objets
196 $tables[]['tables_jointures'][] = 'mots_liens';
197 $tables[]['tables_jointures'][] = 'mots';
198
199 // cas particulier des auteurs et mots : declarer explicitement mots_liens comme jointure privilegiee
200 // cf https://core.spip.net/issues/2329
201 $tables['spip_auteurs']['tables_jointures'][] = 'mots_liens';
202 $tables['spip_auteurs']['tables_jointures'][] = 'mots';
203 $tables['spip_mots']['tables_jointures'][] = 'mots_liens';
204 $tables['spip_mots']['tables_jointures'][] = 'mots';
205
206
207 // recherche jointe sur les mots pour tous les objets
208 $tables[]['rechercher_jointures']['mot'] = array('titre' => 3);
209 // versionner les jointures pour tous les objets
210 $tables[]['champs_versionnes'][] = 'jointure_mots';
211
212 return $tables;
213 }