1 | <?php |
---|
2 | /** |
---|
3 | * Plugin Collections (ou albums) |
---|
4 | * (c) 2012-2013 kent1 (http://www.kent1.info - kent1@arscenic.info) |
---|
5 | * Licence GNU/GPL |
---|
6 | * |
---|
7 | * Déclarations relatives à la base de données |
---|
8 | * |
---|
9 | * @package SPIP\Collections\Pipelines |
---|
10 | */ |
---|
11 | |
---|
12 | if (!defined('_ECRIRE_INC_VERSION')) return; |
---|
13 | |
---|
14 | |
---|
15 | /** |
---|
16 | * Déclaration des alias de tables et filtres automatiques de champs |
---|
17 | * |
---|
18 | * @param array $interfaces Le tableau des tables |
---|
19 | * @return array Le tableau $interfaces complété |
---|
20 | */ |
---|
21 | function collections_declarer_tables_interfaces($interfaces) { |
---|
22 | |
---|
23 | $interfaces['table_des_tables']['collections'] = 'collections'; |
---|
24 | |
---|
25 | return $interfaces; |
---|
26 | } |
---|
27 | |
---|
28 | |
---|
29 | /** |
---|
30 | * Déclaration de la table principale spip_collections correspondant |
---|
31 | * à l'objet éditorial "collection" |
---|
32 | * |
---|
33 | * @param array $tables |
---|
34 | * Le tableau de déclaration des tables |
---|
35 | * @return array $tables |
---|
36 | * Le tableau de déclaration des tables complétées |
---|
37 | */ |
---|
38 | function collections_declarer_tables_objets_sql($tables) { |
---|
39 | |
---|
40 | $tables['spip_collections'] = array( |
---|
41 | 'type' => 'collection', |
---|
42 | 'principale' => "oui", |
---|
43 | 'field'=> array( |
---|
44 | "id_collection" => "bigint(21) NOT NULL", |
---|
45 | "id_admin" => "bigint(21) NOT NULL", |
---|
46 | "titre" => "text NOT NULL", |
---|
47 | "descriptif" => "text NOT NULL", |
---|
48 | "genre" => "varchar(25) NOT NULL DEFAULT 'mixed'", # photo, musique, video, mixed |
---|
49 | "date" => "datetime NOT NULL DEFAULT '0000-00-00 00:00:00'", |
---|
50 | "type_collection" => "varchar(25) NOT NULL DEFAULT 'perso'", |
---|
51 | "statut" => "varchar(20) DEFAULT '0' NOT NULL", |
---|
52 | "lang" => "VARCHAR(10) NOT NULL DEFAULT ''", |
---|
53 | "langue_choisie" => "VARCHAR(3) DEFAULT 'non'", |
---|
54 | "id_trad" => "bigint(21) NOT NULL DEFAULT 0", |
---|
55 | "maj" => "TIMESTAMP" |
---|
56 | ), |
---|
57 | 'key' => array( |
---|
58 | "PRIMARY KEY" => "id_collection", |
---|
59 | "KEY lang" => "lang", |
---|
60 | "KEY id_trad" => "id_trad", |
---|
61 | "KEY statut" => "statut", |
---|
62 | ), |
---|
63 | 'titre' => "titre AS titre, lang AS lang", |
---|
64 | 'date' => "date", |
---|
65 | 'champs_editables' => array('titre', 'descriptif', 'date', 'type_collection','genre'), |
---|
66 | 'champs_versionnes' => array('titre', 'descriptif', 'type_collection','genre'), |
---|
67 | 'rechercher_champs' => array('titre' => 8, 'descriptif' => 2), |
---|
68 | 'tables_jointures' => array( |
---|
69 | #'spip_collections_liens' |
---|
70 | ), |
---|
71 | 'statut_textes_instituer' => array( |
---|
72 | 'publie' => 'collection:texte_statut_publie', |
---|
73 | 'prepa' => 'texte_statut_en_cours_redaction', |
---|
74 | 'poubelle' => 'texte_statut_poubelle', |
---|
75 | ), |
---|
76 | 'statut'=> array( |
---|
77 | array( |
---|
78 | 'champ' => 'statut', |
---|
79 | 'publie' => 'publie', |
---|
80 | 'previsu' => 'publie,prepa', |
---|
81 | 'post_date' => 'date', |
---|
82 | 'exception' => array('statut','tout') |
---|
83 | ) |
---|
84 | ), |
---|
85 | 'texte_changer_statut' => 'collection:texte_changer_statut_collection' |
---|
86 | ); |
---|
87 | |
---|
88 | // jointures sur les collections pour tous les objets |
---|
89 | $tables[]['tables_jointures'][]= 'collections_liens'; |
---|
90 | $tables[]['tables_jointures'][]= 'collections'; |
---|
91 | |
---|
92 | // cas particulier des auteurs et mots : declarer explicitement auteurs_liens comme jointure privilegiee |
---|
93 | // cf https://core.spip.net/issues/2329 |
---|
94 | $tables['spip_collections']['tables_jointures'][]= 'auteurs_liens'; |
---|
95 | $tables['spip_collections']['tables_jointures'][]= 'auteurs'; |
---|
96 | $tables['spip_collections']['tables_jointures'][]= 'collections_liens'; |
---|
97 | $tables['spip_collections']['tables_jointures'][]= 'collections'; |
---|
98 | return $tables; |
---|
99 | } |
---|
100 | |
---|
101 | |
---|
102 | /** |
---|
103 | * Déclaration de la table secondaire spip_collections_liens |
---|
104 | * permettant de lier les medias aux collections |
---|
105 | * |
---|
106 | * @param array $tables |
---|
107 | * Tableau des tables secondaires |
---|
108 | * @return array $tables |
---|
109 | * Tableau des tables secondaires complété |
---|
110 | */ |
---|
111 | function collections_declarer_tables_auxiliaires($tables) { |
---|
112 | |
---|
113 | $tables['spip_collections_liens'] = array( |
---|
114 | 'field' => array( |
---|
115 | "id_collection" => "bigint(21) DEFAULT '0' NOT NULL", |
---|
116 | "id_objet" => "bigint(21) DEFAULT '0' NOT NULL", |
---|
117 | "objet" => "VARCHAR(25) DEFAULT '' NOT NULL", |
---|
118 | "id_auteur" => "bigint(21) DEFAULT '0' NOT NULL", |
---|
119 | "rang" => "bigint(21) DEFAULT '0' NOT NULL", |
---|
120 | "vu" => "VARCHAR(6) DEFAULT 'non' NOT NULL" |
---|
121 | ), |
---|
122 | 'key' => array( |
---|
123 | "PRIMARY KEY" => "id_collection,id_objet,objet,rang", |
---|
124 | "KEY id_collection" => "id_collection" |
---|
125 | ) |
---|
126 | ); |
---|
127 | |
---|
128 | return $tables; |
---|
129 | } |
---|
130 | |
---|
131 | |
---|
132 | ?> |
---|