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 'rechercher_champs' => array(
128 'tables_jointures' => array(#'mots_liens' // declare generiquement ci dessous
130 'champs_versionnes' => array('titre', 'descriptif', 'texte', 'id_groupe'),
133 $tables['spip_groupes_mots'] = array(
134 'table_objet_surnoms' => array(
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",
156 'principale' => 'oui',
157 'page' => '', // pas de page publique pour les groupes
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",
172 'PRIMARY KEY' => 'id_groupe'
174 'rechercher_champs' => array(
179 'tables_jointures' => array(
182 'champs_versionnes' => array(
195 // jointures sur les mots pour tous les objets
196 $tables[]['tables_jointures'][] = 'mots_liens';
197 $tables[]['tables_jointures'][] = 'mots';
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';
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';