1 | <?php |
---|
2 | |
---|
3 | /** |
---|
4 | * Déclarations relatives à la base de données |
---|
5 | * |
---|
6 | * @plugin produits |
---|
7 | * @copyright 2014 |
---|
8 | * @author Les Développements Durables, http://www.ldd.fr |
---|
9 | * @licence GNU/GPL |
---|
10 | * @package SPIP\Produits\Pipelines |
---|
11 | */ |
---|
12 | if (!defined('_ECRIRE_INC_VERSION')) { |
---|
13 | return; |
---|
14 | } |
---|
15 | |
---|
16 | /** |
---|
17 | * Déclaration des alias de tables et filtres automatiques de champs |
---|
18 | * |
---|
19 | * @pipeline declarer_tables_interfaces |
---|
20 | * @param array $interfaces |
---|
21 | * Déclarations d'interface pour le compilateur |
---|
22 | * @return array |
---|
23 | * Déclarations d'interface pour le compilateur |
---|
24 | */ |
---|
25 | function produits_declarer_tables_interfaces($interfaces) { |
---|
26 | |
---|
27 | $interfaces['table_des_tables']['produits'] = 'produits'; |
---|
28 | |
---|
29 | // Champs date sur les tables |
---|
30 | $interfaces['table_date']['produits'] = 'date'; |
---|
31 | |
---|
32 | // Déclaration du titre |
---|
33 | $interfaces['table_titre']['produits'] = 'titre, "" as lang'; |
---|
34 | |
---|
35 | // pour pouvoir faire une boucle par id_groupe de mot clé |
---|
36 | $interfaces['exceptions_des_jointures']['spip_produits']['id_groupe'] = array('spip_mots', 'id_groupe'); |
---|
37 | |
---|
38 | return $interfaces; |
---|
39 | } |
---|
40 | |
---|
41 | /** |
---|
42 | * Déclaration des objets éditoriaux |
---|
43 | * |
---|
44 | * @pipeline declarer_tables_objets_sql |
---|
45 | * @param array $tables |
---|
46 | * Description des tables |
---|
47 | * @return array |
---|
48 | * Description complétée des tables |
---|
49 | */ |
---|
50 | function produits_declarer_tables_objets_sql($tables) { |
---|
51 | |
---|
52 | $tables['spip_produits'] = array( |
---|
53 | 'type' => 'produit', |
---|
54 | 'principale' => 'oui', |
---|
55 | 'field' => array( |
---|
56 | 'id_produit' => 'bigint(21) NOT NULL', |
---|
57 | 'id_rubrique' => 'bigint(21) NOT NULL DEFAULT 0', |
---|
58 | 'id_secteur' => 'bigint(21) NOT NULL DEFAULT 0', |
---|
59 | 'titre' => 'text NOT NULL', |
---|
60 | 'reference' => "tinytext NOT NULL DEFAULT ''", |
---|
61 | 'descriptif' => "text NOT NULL DEFAULT ''", |
---|
62 | 'texte' => 'longtext NOT NULL', |
---|
63 | 'prix_ht' => 'decimal(20,6) NOT NULL DEFAULT 0', |
---|
64 | 'taxe' => 'decimal(4,4) DEFAULT NULL', |
---|
65 | 'statut' => "varchar(20) DEFAULT '0' NOT NULL", |
---|
66 | 'lang' => "VARCHAR(10) NOT NULL DEFAULT ''", |
---|
67 | 'date' => "datetime NOT NULL DEFAULT '0000-00-00 00:00:00'", |
---|
68 | 'date_com' => "datetime NOT NULL DEFAULT '0000-00-00 00:00:00'", |
---|
69 | 'langue_choisie' => "VARCHAR(3) DEFAULT 'non'", |
---|
70 | 'id_trad' => 'bigint(21) NOT NULL DEFAULT 0', |
---|
71 | 'immateriel' => 'tinyint(1) NOT NULL DEFAULT 0', |
---|
72 | 'poids' => 'bigint(21) NOT NULL DEFAULT 0', // poids en g |
---|
73 | 'largeur' => 'bigint(21) NOT NULL DEFAULT 0', // largeur en cm |
---|
74 | 'longueur' => 'bigint(21) NOT NULL DEFAULT 0', // longueur en cm |
---|
75 | 'hauteur' => 'bigint(21) NOT NULL DEFAULT 0', // hauteur en cm |
---|
76 | 'maj' => 'TIMESTAMP' |
---|
77 | ), |
---|
78 | 'key' => array( |
---|
79 | 'PRIMARY KEY' => 'id_produit', |
---|
80 | 'KEY id_rubrique' => 'id_rubrique', |
---|
81 | 'KEY id_secteur' => 'id_secteur', |
---|
82 | 'KEY lang' => 'lang', |
---|
83 | 'KEY id_trad' => 'id_trad', |
---|
84 | 'KEY statut' => 'statut', |
---|
85 | ), |
---|
86 | 'titre' => 'titre AS titre, lang AS lang', |
---|
87 | 'date' => 'date', |
---|
88 | 'champs_editables' => array('titre', 'reference', 'prix_ht', 'taxe', 'descriptif', 'texte', 'immateriel', 'poids', 'largeur', 'longueur', 'hauteur'), |
---|
89 | 'champs_versionnes' => array('titre', 'reference', 'prix_ht', 'taxe', 'descriptif', 'texte'), |
---|
90 | 'rechercher_champs' => array('titre' => 4, 'reference' => 4, 'descriptif' => 2, 'texte' => 1), |
---|
91 | 'statut_textes_instituer' => array( |
---|
92 | 'prepa' => 'texte_statut_en_cours_redaction', |
---|
93 | 'prop' => 'texte_statut_propose_evaluation', |
---|
94 | 'publie' => 'texte_statut_publie', |
---|
95 | 'refuse' => 'texte_statut_refuse', |
---|
96 | 'poubelle' => 'texte_statut_poubelle', |
---|
97 | ), |
---|
98 | 'statut' => array( |
---|
99 | array( |
---|
100 | 'champ' => 'statut', |
---|
101 | 'publie' => 'publie', |
---|
102 | 'previsu' => 'publie,prop,prepa', |
---|
103 | 'post_date' => 'date', |
---|
104 | 'exception' => array('statut', 'tout') |
---|
105 | ) |
---|
106 | ), |
---|
107 | 'texte_changer_statut' => 'produits:produit_statut', |
---|
108 | 'join' => array( |
---|
109 | 'id_produit' => 'id_produit', |
---|
110 | 'id_rubrique' => 'id_rubrique' |
---|
111 | ), |
---|
112 | 'tables_jointures' => array( |
---|
113 | 'profondeur' => 'rubriques', |
---|
114 | #'id_auteur' => 'auteurs_liens' // declaration generique plus bas |
---|
115 | ), |
---|
116 | ); |
---|
117 | |
---|
118 | return $tables; |
---|
119 | } |
---|