3 /***************************************************************************\
4 * SPIP, Systeme de publication pour l'internet *
6 * Copyright (c) 2001-2016 *
7 * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
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 \***************************************************************************/
14 * Déclarations relatives à la base de données
16 * @package SPIP\Mots\Pipelines
18 if (!defined('_ECRIRE_INC_VERSION')) {
23 * Déclarer les interfaces des tables mots et groupes de mots pour le compilateur
25 * @pipeline declarer_tables_interfaces
26 * @param array $interfaces
27 * Déclarations d'interface pour le compilateur
29 * Déclarations d'interface pour le compilateur
31 function mots_declarer_tables_interfaces($interfaces) {
33 $interfaces['table_des_tables']['mots'] = 'mots';
34 $interfaces['table_des_tables']['groupes_mots'] = 'groupes_mots';
36 $interfaces['exceptions_des_tables']['mots']['titre_mot'] = 'titre';
37 $interfaces['table_des_traitements']['TYPE']['mots'] = _TRAITEMENT_TYPO_SANS_NUMERO
;
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');
53 * Déclarer les tables auxiliaires des mots
55 * @pipeline declarer_tables_auxiliaires
56 * @param array $tables_auxiliaires
57 * Description des tables
59 * Description complétée des tables
61 function mots_declarer_tables_auxiliaires($tables_auxiliaires) {
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"
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',
76 $tables_auxiliaires['spip_mots_liens'] =
77 array('field' => &$spip_mots_liens, 'key' => &$spip_mots_liens_key);
79 return $tables_auxiliaires;
84 * Déclarer les objets éditoriaux des mots et groupes de mots
86 * @pipeline declarer_tables_objets_sql
87 * @param array $tables
88 * Description des tables
90 * Description complétée des tables
92 function mots_declarer_tables_objets_sql($tables) {
93 $tables['spip_mots'] = array(
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",
109 'principale' => 'oui',
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",
120 'PRIMARY KEY' => 'id_mot',
121 'KEY id_groupe' => 'id_groupe'
123 'parent' => array('type' => 'groupe_mot', 'champ' => 'id_groupe'),
124 'rechercher_champs' => array(
129 'tables_jointures' => array(#'mots_liens' // declare generiquement ci dessous
131 'champs_versionnes' => array('titre', 'descriptif', 'texte', 'id_groupe'),
134 $tables['spip_groupes_mots'] = array(
135 'table_objet_surnoms' => array(
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",
157 'principale' => 'oui',
158 'page' => '', // pas de page publique pour les groupes
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",
173 'PRIMARY KEY' => 'id_groupe'
175 'rechercher_champs' => array(
180 'tables_jointures' => array(
183 'champs_versionnes' => array(
196 // jointures sur les mots pour tous les objets
197 $tables[]['tables_jointures'][] = 'mots_liens';
198 $tables[]['tables_jointures'][] = 'mots';
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';
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';