4ea4773120490442286e3cf79a69e97855e884f7
[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 'parent' => array('type' => 'groupe_mot', 'champ' => 'id_groupe'),
124 'rechercher_champs' => array(
125 'titre' => 8,
126 'texte' => 1,
127 'descriptif' => 5
128 ),
129 'tables_jointures' => array(#'mots_liens' // declare generiquement ci dessous
130 ),
131 'champs_versionnes' => array('titre', 'descriptif', 'texte', 'id_groupe'),
132 );
133
134 $tables['spip_groupes_mots'] = array(
135 'table_objet_surnoms' => array(
136 'groupemot',
137 'groupe_mots'
138 /*hum*/,
139 'groupe_mot'
140 /* hum*/,
141 'groupe'
142 /*hum (EXPOSE)*/
143 ),
144 'type' => 'groupe_mots',
145 'type_surnoms' => array('groupes_mot', 'groupemot', 'groupe_mot'),
146 'texte_retour' => 'icone_retour',
147 'texte_objets' => 'mots:titre_groupes_mots',
148 'texte_objet' => 'mots:titre_groupe_mots',
149 'texte_modifier' => 'mots:icone_modif_groupe_mots',
150 'texte_creer' => 'mots:icone_creation_groupe_mots',
151 'texte_logo_objet' => 'mots:logo_groupe',
152 'info_aucun_objet' => 'mots:info_aucun_groupemots',
153 'info_1_objet' => 'mots:info_1_groupemots',
154 'info_nb_objets' => 'mots:info_nb_groupemots',
155 'titre' => "titre, '' AS lang",
156 'date' => 'date',
157 'principale' => 'oui',
158 'page' => '', // pas de page publique pour les groupes
159 'field' => array(
160 'id_groupe' => 'bigint(21) NOT NULL',
161 'titre' => "text DEFAULT '' NOT NULL",
162 'descriptif' => "text DEFAULT '' NOT NULL",
163 'texte' => "longtext DEFAULT '' NOT NULL",
164 'unseul' => "varchar(3) DEFAULT '' NOT NULL",
165 'obligatoire' => "varchar(3) DEFAULT '' NOT NULL",
166 'tables_liees' => "text DEFAULT '' NOT NULL",
167 'minirezo' => "varchar(3) DEFAULT '' NOT NULL",
168 'comite' => "varchar(3) DEFAULT '' NOT NULL",
169 'forum' => "varchar(3) DEFAULT '' NOT NULL",
170 'maj' => 'TIMESTAMP'
171 ),
172 'key' => array(
173 'PRIMARY KEY' => 'id_groupe'
174 ),
175 'rechercher_champs' => array(
176 'titre' => 8,
177 'texte' => 1,
178 'descriptif' => 5
179 ),
180 'tables_jointures' => array(
181 'mots'
182 ),
183 'champs_versionnes' => array(
184 'titre',
185 'descriptif',
186 'texte',
187 'un_seul',
188 'obligatoire',
189 'tables_liees',
190 'minirezo',
191 'forum',
192 'comite'
193 ),
194 );
195
196 // jointures sur les mots pour tous les objets
197 $tables[]['tables_jointures'][] = 'mots_liens';
198 $tables[]['tables_jointures'][] = 'mots';
199
200 // cas particulier des auteurs et mots : declarer explicitement mots_liens comme jointure privilegiee
201 // cf https://core.spip.net/issues/2329
202 $tables['spip_auteurs']['tables_jointures'][] = 'mots_liens';
203 $tables['spip_auteurs']['tables_jointures'][] = 'mots';
204 $tables['spip_mots']['tables_jointures'][] = 'mots_liens';
205 $tables['spip_mots']['tables_jointures'][] = 'mots';
206
207
208 // recherche jointe sur les mots pour tous les objets
209 $tables[]['rechercher_jointures']['mot'] = array('titre' => 3);
210 // versionner les jointures pour tous les objets
211 $tables[]['champs_versionnes'][] = 'jointure_mots';
212
213 return $tables;
214 }