<?php

/**
 * Plugin CIBLOC
 * @copyright 2018 MTECT
 * @author Christophe IMBERTI (cf. CPI art L121-1)
 * @license GNU/GPLv3
 */

function cibloc_declarer_tables_principales(
	$tables_principales
) {

	// table des objets
	$spip_cibloc_objets = [
		'type' => "varchar(10) DEFAULT '' NOT NULL",
		'id' => "varchar(50) DEFAULT '' NOT NULL",
		'nom' => "text DEFAULT '' NOT NULL",
		'statut' => "varchar(10) DEFAULT 'active' NOT NULL",
		'preremplir' => "text DEFAULT '' NOT NULL",
		'couleur' => "varchar(12) DEFAULT '' NOT NULL",
		'bordure' => "varchar(12) DEFAULT '' NOT NULL",
		'couleur_bordure' => "varchar(12) DEFAULT '' NOT NULL",
		'alignement' => "varchar(10) DEFAULT '' NOT NULL",
		'couleur_bouton' => "varchar(12) DEFAULT '' NOT NULL",
		'couleur_bouton_survol' => "varchar(12) DEFAULT '' NOT NULL",
		'taille_texte' => "varchar(10) DEFAULT '' NOT NULL",
		'padding_top' => "varchar(10) DEFAULT '' NOT NULL",
		'padding_bottom' => "varchar(10) DEFAULT '' NOT NULL",
		'padding_right' => "varchar(10) DEFAULT '' NOT NULL",
		'padding_left' => "varchar(10) DEFAULT '' NOT NULL",
		'code_html_ouvrant' => "text DEFAULT '' NOT NULL",
		'code_html_fermant' => "text DEFAULT '' NOT NULL",
		'paragrapher' => "varchar(3) DEFAULT 'oui' NOT NULL",
		'source' => "varchar(10) DEFAULT '' NOT NULL",
		'options' => "text DEFAULT '' NOT NULL",
		'rang' => "int(4) DEFAULT '0' NOT NULL",
	];

	$spip_cibloc_objets_key = [
		'PRIMARY KEY' => 'type,id',
		'KEY id' => 'id',
		'KEY type' => 'type',
	];

	$tables_principales['spip_cibloc_objets'] = [
		'field' => &$spip_cibloc_objets,
		'key' => &$spip_cibloc_objets_key,
	];

	// table de config
	$spip_cibloc_config = [
		'nom' => 'varchar(255) NOT NULL',
		'valeur' => "text DEFAULT ''",
	];

	$spip_cibloc_config_key = [
		'PRIMARY KEY' => 'nom',
	];

	$tables_principales['spip_cibloc_config'] = [
		'field' => &$spip_cibloc_config,
		'key' => &$spip_cibloc_config_key];

	return $tables_principales;
}

function cibloc_declarer_tables_interfaces($interface) {

	$interface['table_des_tables']['cibloc_objets'] = 'cibloc_objets';
	$interface['table_des_tables']['cibloc_config'] = 'cibloc_config';

	return $interface;
}
