gamuform/base/gamuform.php

120 lines
3.2 KiB
PHP

<?php
/**
* Déclarations relatives à la base de données
*
* @plugin GamuForm
* @copyright 2020
* @author tofulm
* @licence GNU/GPL
* @package SPIP\Gamuform\Pipelines
*/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
/**
* Déclaration des alias de tables et filtres automatiques de champs
*
* @pipeline declarer_tables_interfaces
* @param array $interfaces
* Déclarations d'interface pour le compilateur
* @return array
* Déclarations d'interface pour le compilateur
*/
function gamuform_declarer_tables_interfaces($interfaces) {
$interfaces['table_des_tables']['gamuforms'] = 'gamuforms';
return $interfaces;
}
/**
* Déclaration des objets éditoriaux
*
* @pipeline declarer_tables_objets_sql
* @param array $tables
* Description des tables
* @return array
* Description complétée des tables
*/
function gamuform_declarer_tables_objets_sql($tables) {
$tables['spip_gamuforms'] = array(
'type' => 'gamuform',
'principale' => 'oui',
'field'=> array(
'id_gamuform' => 'bigint(21) NOT NULL',
'objet' => 'VARCHAR(25) DEFAULT "" NOT NULL',
'titre' => 'varchar(255) NOT NULL DEFAULT ""',
'label' => 'varchar(255) NOT NULL DEFAULT ""',
'type' => 'varchar(255) NOT NULL DEFAULT ""',
'class_container' => 'varchar(255) NOT NULL DEFAULT ""',
'class' => 'varchar(255) NOT NULL DEFAULT ""',
'choix' => "text NOT NULL",
'defaut' => 'varchar(255) NOT NULL DEFAULT ""',
'statut' => 'varchar(20) DEFAULT "0" NOT NULL',
'date' => 'datetime NOT NULL DEFAULT "0000-00-00 00:00:00"',
'rang' => 'tinyint(4) NOT NULL',
'maj' => 'TIMESTAMP'
),
'key' => array(
'PRIMARY KEY' => 'id_gamuform',
'KEY objet' => 'objet',
'KEY statut' => 'statut',
),
'titre' => 'titre AS titre, "" AS lang',
'date' => 'date',
//'champs_editables' => array('titre'),
//'champs_versionnes' => array('titre'),
//'rechercher_champs' => array(),
'tables_jointures' => array('spip_gamuforms_valeurs'),
'statut_textes_instituer' => array(
'prepa' => 'texte_statut_en_cours_redaction',
'publie' => 'texte_statut_publie',
'poubelle' => 'texte_statut_poubelle',
),
'statut'=> array(
array(
'champ' => 'statut',
'publie' => 'publie',
'exception' => array('statut','tout')
)
),
'texte_changer_statut' => 'gamuform:texte_changer_statut_gamuform',
);
return $tables;
}
/**
* Déclaration des tables secondaires (liaisons)
*
* @pipeline declarer_tables_auxiliaires
* @param array $tables
* Description des tables
* @return array
* Description complétée des tables
*/
function gamuform_declarer_tables_auxiliaires($tables) {
$tables['spip_gamuforms_valeurs'] = array(
'field' => array(
'id_gamuform' => 'bigint(21) DEFAULT "0" NOT NULL',
'id_objet' => 'bigint(21) DEFAULT "0" NOT NULL',
'objet' => 'VARCHAR(25) DEFAULT "" NOT NULL',
'valeur' => "text NOT NULL",
),
'key' => array(
'PRIMARY KEY' => 'id_gamuform,id_objet,objet',
'KEY id_gamuform' => 'id_gamuform',
)
);
return $tables;
}