471733c675afeb25a6275abfc6504a8e6b1ceaa5
[ptitvelo/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-2013 *
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
114 'type'=>'groupe_mots',
115 'type_surnoms' => array('groupes_mot','groupemot','groupe_mot'),
116
117 'texte_retour' => 'icone_retour',
118 'texte_objets' => 'mots:titre_groupes_mots',
119 'texte_objet' => 'mots:titre_groupe_mots',
120 'texte_modifier' => 'mots:icone_modif_groupe_mots',
121 'texte_creer' => 'mots:icone_creation_groupe_mots',
122 'texte_logo_objet' => 'mots:logo_groupe',
123 'info_aucun_objet'=> 'mots:info_aucun_groupemots',
124 'info_1_objet' => 'mots:info_1_groupemots',
125 'info_nb_objets' => 'mots:info_nb_groupemots',
126 'titre' => "titre, '' AS lang",
127 'date' => 'date',
128 'principale' => 'oui',
129 'page' => '', // pas de page publique pour les groupes
130 'field'=> array(
131 "id_groupe" => "bigint(21) NOT NULL",
132 "titre" => "text DEFAULT '' NOT NULL",
133 "descriptif" => "text DEFAULT '' NOT NULL",
134 "texte" => "longtext DEFAULT '' NOT NULL",
135 "unseul" => "varchar(3) DEFAULT '' NOT NULL",
136 "obligatoire" => "varchar(3) DEFAULT '' NOT NULL",
137 "tables_liees" => "text DEFAULT '' NOT NULL",
138 "minirezo" => "varchar(3) DEFAULT '' NOT NULL",
139 "comite" => "varchar(3) DEFAULT '' NOT NULL",
140 "forum" => "varchar(3) DEFAULT '' NOT NULL",
141 "maj" => "TIMESTAMP"
142 ),
143 'key' => array(
144 "PRIMARY KEY" => "id_groupe"
145 ),
146 'rechercher_champs' => array(
147 'titre' => 8, 'texte' => 1, 'descriptif' => 5
148 ),
149 'tables_jointures' => array(
150 'mots'
151 ),
152 'champs_versionnes' => array('titre', 'descriptif', 'texte','un_seul','obligatoire','tables_liees','minirezo','forum','comite'),
153 );
154
155 // jointures sur les mots pour tous les objets
156 $tables[]['tables_jointures'][]= 'mots_liens';
157 $tables[]['tables_jointures'][]= 'mots';
158
159 // cas particulier des auteurs et mots : declarer explicitement mots_liens comme jointure privilegiee
160 // cf http://core.spip.org/issues/2329
161 $tables['spip_auteurs']['tables_jointures'][]= 'mots_liens';
162 $tables['spip_auteurs']['tables_jointures'][]= 'mots';
163 $tables['spip_mots']['tables_jointures'][]= 'mots_liens';
164 $tables['spip_mots']['tables_jointures'][]= 'mots';
165
166
167 // recherche jointe sur les mots pour tous les objets
168 $tables[]['rechercher_jointures']['mot'] = array('titre' => 3);
169 // versionner les jointures pour tous les objets
170 $tables[]['champs_versionnes'][] = 'jointure_mots';
171
172 return $tables;
173 }
174 ?>