1 | <?php |
---|
2 | |
---|
3 | /***************************************************************************\ |
---|
4 | * SPIP, Systeme de publication pour l'internet * |
---|
5 | * * |
---|
6 | * Copyright (c) 2001-2015 * |
---|
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 | /** |
---|
14 | * Déclarations relatives à la base de données |
---|
15 | * |
---|
16 | * @package SPIP\Revisions\Pipelines |
---|
17 | **/ |
---|
18 | |
---|
19 | if (!defined('_ECRIRE_INC_VERSION')) { |
---|
20 | return; |
---|
21 | } |
---|
22 | |
---|
23 | /** |
---|
24 | * Déclarer les interfaces des tables versions pour le compilateur |
---|
25 | * |
---|
26 | * @pipeline declarer_tables_interfaces |
---|
27 | * @param array $interface |
---|
28 | * Déclarations d'interface pour le compilateur |
---|
29 | * @return array |
---|
30 | * Déclarations d'interface pour le compilateur |
---|
31 | */ |
---|
32 | function revisions_declarer_tables_interfaces($interface) { |
---|
33 | |
---|
34 | $interface['table_des_tables']['versions'] = 'versions'; |
---|
35 | |
---|
36 | return $interface; |
---|
37 | } |
---|
38 | |
---|
39 | /** |
---|
40 | * Déclaration des jointures génériques |
---|
41 | * |
---|
42 | * @pipeline declarer_tables_objets_sql |
---|
43 | * @param array $tables |
---|
44 | * Description des tables |
---|
45 | * @return array |
---|
46 | * Description complétée des tables |
---|
47 | */ |
---|
48 | function revisions_declarer_tables_objets_sql($tables) { |
---|
49 | |
---|
50 | // jointures sur les mots pour tous les objets |
---|
51 | $tables[]['tables_jointures'][] = 'versions'; |
---|
52 | |
---|
53 | return $tables; |
---|
54 | } |
---|
55 | |
---|
56 | |
---|
57 | /** |
---|
58 | * Déclarer les tables versions et fragments |
---|
59 | * |
---|
60 | * @pipeline declarer_tables_auxiliaires |
---|
61 | * @param array $tables_auxiliaires |
---|
62 | * Description des tables |
---|
63 | * @return array |
---|
64 | * Description complétée des tables |
---|
65 | */ |
---|
66 | function revisions_declarer_tables_auxiliaires($tables_auxiliaires) { |
---|
67 | |
---|
68 | $spip_versions = array( |
---|
69 | "id_version" => "bigint(21) DEFAULT 0 NOT NULL", |
---|
70 | "id_objet" => "bigint(21) DEFAULT 0 NOT NULL", |
---|
71 | "objet" => "VARCHAR (25) DEFAULT '' NOT NULL", |
---|
72 | "date" => "datetime DEFAULT '0000-00-00 00:00:00' NOT NULL", |
---|
73 | "id_auteur" => "VARCHAR(23) DEFAULT '' NOT NULL", # stocke aussi IP(v6) |
---|
74 | "titre_version" => "text DEFAULT '' NOT NULL", |
---|
75 | "permanent" => "char(3) DEFAULT '' NOT NULL", |
---|
76 | "champs" => "text DEFAULT '' NOT NULL" |
---|
77 | ); |
---|
78 | |
---|
79 | $spip_versions_key = array( |
---|
80 | "PRIMARY KEY" => "id_version, id_objet, objet", |
---|
81 | "KEY id_version" => "id_version", |
---|
82 | "KEY id_objet" => "id_objet", |
---|
83 | "KEY objet" => "objet" |
---|
84 | ); |
---|
85 | |
---|
86 | $spip_versions_fragments = array( |
---|
87 | "id_fragment" => "int unsigned DEFAULT '0' NOT NULL", |
---|
88 | "version_min" => "int unsigned DEFAULT '0' NOT NULL", |
---|
89 | "version_max" => "int unsigned DEFAULT '0' NOT NULL", |
---|
90 | "id_objet" => "bigint(21) NOT NULL", |
---|
91 | "objet" => "VARCHAR (25) DEFAULT '' NOT NULL", |
---|
92 | "compress" => "tinyint NOT NULL", |
---|
93 | "fragment" => "longblob" # ici c'est VRAIMENT un blob (on y stocke du gzip) |
---|
94 | ); |
---|
95 | |
---|
96 | $spip_versions_fragments_key = array( |
---|
97 | "PRIMARY KEY" => "id_objet, objet, id_fragment, version_min" |
---|
98 | ); |
---|
99 | |
---|
100 | |
---|
101 | $tables_auxiliaires['spip_versions'] = array( |
---|
102 | 'field' => &$spip_versions, |
---|
103 | 'key' => &$spip_versions_key |
---|
104 | ); |
---|
105 | |
---|
106 | $tables_auxiliaires['spip_versions_fragments'] = array( |
---|
107 | 'field' => &$spip_versions_fragments, |
---|
108 | 'key' => &$spip_versions_fragments_key |
---|
109 | ); |
---|
110 | |
---|
111 | return $tables_auxiliaires; |
---|
112 | } |
---|