[SPIP] ~v3.0.20-->v3.0.25
[lhc/web/clavette_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 if (!defined('_ECRIRE_INC_VERSION')) return;
14
15 /**
16 * Interfaces des tables mots et groupes de mots pour le compilateur
17 *
18 * @param array $interfaces
19 * @return array
20 */
21 function mots_declarer_tables_interfaces($interfaces){
22
23 $interfaces['table_des_tables']['mots']='mots';
24 $interfaces['table_des_tables']['groupes_mots']='groupes_mots';
25
26 $interfaces['exceptions_des_jointures']['titre_mot'] = array('spip_mots', 'titre');
27 $interfaces['exceptions_des_jointures']['type_mot'] = array('spip_mots', 'type');
28 $interfaces['exceptions_des_jointures']['id_mot_syndic'] = array('spip_mots_liens', 'id_mot');
29 $interfaces['exceptions_des_jointures']['titre_mot_syndic'] = array('spip_mots', 'titre');
30 $interfaces['exceptions_des_jointures']['type_mot_syndic'] = array('spip_mots', 'type');
31 $interfaces['exceptions_des_jointures']['spip_articles']['id_groupe'] = array('spip_mots', 'id_groupe');
32 $interfaces['exceptions_des_jointures']['spip_rubriques']['id_groupe'] = array('spip_mots', 'id_groupe');
33
34 return $interfaces;
35 }
36
37
38 /**
39 * Table auxilaire spip_mots_xx
40 *
41 * @param array $tables_auxiliaires
42 * @return array
43 */
44 function mots_declarer_tables_auxiliaires($tables_auxiliaires){
45
46 $spip_mots_liens = array(
47 "id_mot" => "bigint(21) DEFAULT '0' NOT NULL",
48 "id_objet" => "bigint(21) DEFAULT '0' NOT NULL",
49 "objet" => "VARCHAR (25) DEFAULT '' NOT NULL");
50
51 $spip_mots_liens_key = array(
52 "PRIMARY KEY" => "id_mot,id_objet,objet",
53 "KEY id_mot" => "id_mot",
54 "KEY id_objet" => "id_objet",
55 "KEY objet" => "objet",
56 );
57
58 $tables_auxiliaires['spip_mots_liens'] =
59 array('field' => &$spip_mots_liens, 'key' => &$spip_mots_liens_key);
60
61 return $tables_auxiliaires;
62 }
63
64
65 /**
66 * Declarer les objets mots et les jointures mots pour tous les objets
67 *
68 * @param array $tables
69 * @return array
70 */
71 function mots_declarer_tables_objets_sql($tables){
72 $tables['spip_mots'] = array(
73 'type' => 'mot',
74 'type_surnoms' => array('mot-cle'), // pour les icones...
75 'texte_retour' => 'icone_retour',
76 'texte_objets' => 'public:mots_clefs',
77 'texte_objet' => 'public:mots_clef',
78 'texte_modifier' => 'mots:icone_modifier_mot',
79 'texte_ajouter' => 'titre_ajouter_un_mot', // # A deplacer
80 'texte_creer' => 'titre_ajouter_un_mot',
81 'texte_logo_objet' => 'mots:logo_mot_cle',
82 'texte_creer_associer' => 'mots:creer_et_associer_un_mot',
83 'info_aucun_objet'=> 'mots:info_aucun_mot_cle',
84 'info_1_objet' => 'info_1_mot_cle',
85 'info_nb_objets' => 'info_nb_mots_cles',
86 'titre' => "titre, '' AS lang",
87 'date' => 'date',
88 'principale' => 'oui',
89 'field'=> array(
90 "id_mot" => "bigint(21) NOT NULL",
91 "titre" => "text DEFAULT '' NOT NULL",
92 "descriptif" => "text DEFAULT '' NOT NULL",
93 "texte" => "longtext DEFAULT '' NOT NULL",
94 "id_groupe" => "bigint(21) DEFAULT 0 NOT NULL",
95 "type" => "text DEFAULT '' NOT NULL",
96 "maj" => "TIMESTAMP"
97 ),
98 'key' => array(
99 "PRIMARY KEY" => "id_mot",
100 "KEY id_groupe" => "id_groupe"
101 ),
102 'rechercher_champs' => array(
103 'titre' => 8, 'texte' => 1, 'descriptif' => 5
104 ),
105 'tables_jointures' => array(
106 #'mots_liens' // declare generiquement ci dessous
107 ),
108 'champs_versionnes' => array('titre', 'descriptif', 'texte','id_groupe'),
109 );
110
111 $tables['spip_groupes_mots'] = array(
112 'table_objet_surnoms' => array('groupemot','groupe_mots' /*hum*/,'groupe_mot' /* hum*/,'groupe' /*hum (EXPOSE)*/),
113 'type'=>'groupe_mots',
114 'type_surnoms' => array('groupes_mot','groupemot','groupe_mot'),
115 'texte_retour' => 'icone_retour',
116 'texte_objets' => 'mots:titre_groupes_mots',
117 'texte_objet' => 'mots:titre_groupe_mots',
118 'texte_modifier' => 'mots:icone_modif_groupe_mots',
119 'texte_creer' => 'mots:icone_creation_groupe_mots',
120 'texte_logo_objet' => 'mots:logo_groupe',
121 'info_aucun_objet'=> 'mots:info_aucun_groupemots',
122 'info_1_objet' => 'mots:info_1_groupemots',
123 'info_nb_objets' => 'mots:info_nb_groupemots',
124 'titre' => "titre, '' AS lang",
125 'date' => 'date',
126 'principale' => 'oui',
127 'page' => '', // pas de page publique pour les groupes
128 'field'=> array(
129 "id_groupe" => "bigint(21) NOT NULL",
130 "titre" => "text DEFAULT '' NOT NULL",
131 "descriptif" => "text DEFAULT '' NOT NULL",
132 "texte" => "longtext DEFAULT '' NOT NULL",
133 "unseul" => "varchar(3) DEFAULT '' NOT NULL",
134 "obligatoire" => "varchar(3) DEFAULT '' NOT NULL",
135 "tables_liees" => "text DEFAULT '' NOT NULL",
136 "minirezo" => "varchar(3) DEFAULT '' NOT NULL",
137 "comite" => "varchar(3) DEFAULT '' NOT NULL",
138 "forum" => "varchar(3) DEFAULT '' NOT NULL",
139 "maj" => "TIMESTAMP"
140 ),
141 'key' => array(
142 "PRIMARY KEY" => "id_groupe"
143 ),
144 'rechercher_champs' => array(
145 'titre' => 8, 'texte' => 1, 'descriptif' => 5
146 ),
147 'tables_jointures' => array(
148 'mots'
149 ),
150 'champs_versionnes' => array('titre', 'descriptif', 'texte','un_seul','obligatoire','tables_liees','minirezo','forum','comite'),
151 );
152
153 // jointures sur les mots pour tous les objets
154 $tables[]['tables_jointures'][]= 'mots_liens';
155 $tables[]['tables_jointures'][]= 'mots';
156
157 // cas particulier des auteurs et mots : declarer explicitement mots_liens comme jointure privilegiee
158 // cf https://core.spip.net/issues/2329
159 $tables['spip_auteurs']['tables_jointures'][]= 'mots_liens';
160 $tables['spip_auteurs']['tables_jointures'][]= 'mots';
161 $tables['spip_mots']['tables_jointures'][]= 'mots_liens';
162 $tables['spip_mots']['tables_jointures'][]= 'mots';
163
164 // recherche jointe sur les mots pour tous les objets
165 $tables[]['rechercher_jointures']['mot'] = array('titre' => 3);
166 // versionner les jointures pour tous les objets
167 $tables[]['champs_versionnes'][] = 'jointure_mots';
168
169 return $tables;
170 }
171 ?>