File "mots.php"
Full path: /home/argothem/www/v4_old/plugins-dist/mots/base/mots.php
File size: 7.18 KB
MIME-type: text/x-php
Charset: utf-8
<?php
/***************************************************************************\
* SPIP, Système de publication pour l'internet *
* *
* Copyright © avec tendresse depuis 2001 *
* Arnaud Martin, Antoine Pitrou, Philippe Rivière, Emmanuel Saint-James *
* *
* Ce programme est un logiciel libre distribué sous licence GNU/GPL. *
* Pour plus de détails voir le fichier COPYING.txt ou l'aide en ligne. *
\***************************************************************************/
/**
* Déclarations relatives à la base de données
*
* @package SPIP\Mots\Pipelines
**/
if (!defined('_ECRIRE_INC_VERSION')) {
return;
}
/**
* Déclarer les interfaces des tables mots et groupes de mots pour le compilateur
*
* @pipeline declarer_tables_interfaces
* @param array $interfaces
* Déclarations d'interface pour le compilateur
* @return array
* Déclarations d'interface pour le compilateur
*/
function mots_declarer_tables_interfaces($interfaces) {
$interfaces['table_des_tables']['mots'] = 'mots';
$interfaces['table_des_tables']['groupes_mots'] = 'groupes_mots';
$interfaces['exceptions_des_tables']['mots']['titre_mot'] = 'titre';
$interfaces['table_des_traitements']['TYPE']['mots'] = _TRAITEMENT_TYPO_SANS_NUMERO;
$interfaces['exceptions_des_jointures']['titre_mot'] = ['spip_mots', 'titre'];
$interfaces['exceptions_des_jointures']['type_mot'] = ['spip_mots', 'type'];
$interfaces['exceptions_des_jointures']['id_mot_syndic'] = ['spip_mots_liens', 'id_mot'];
$interfaces['exceptions_des_jointures']['titre_mot_syndic'] = ['spip_mots', 'titre'];
$interfaces['exceptions_des_jointures']['type_mot_syndic'] = ['spip_mots', 'type'];
$interfaces['exceptions_des_jointures']['spip_articles']['id_groupe'] = ['spip_mots', 'id_groupe'];
$interfaces['exceptions_des_jointures']['spip_rubriques']['id_groupe'] = ['spip_mots', 'id_groupe'];
$interfaces['exceptions_des_jointures']['spip_syndic']['id_groupe'] = ['spip_mots', 'id_groupe'];
return $interfaces;
}
/**
* Déclarer les tables auxiliaires des mots
*
* @pipeline declarer_tables_auxiliaires
* @param array $tables_auxiliaires
* Description des tables
* @return array
* Description complétée des tables
*/
function mots_declarer_tables_auxiliaires($tables_auxiliaires) {
$spip_mots_liens = [
'id_mot' => "bigint(21) DEFAULT '0' NOT NULL",
'id_objet' => "bigint(21) DEFAULT '0' NOT NULL",
'objet' => "VARCHAR (25) DEFAULT '' NOT NULL"
];
$spip_mots_liens_key = [
'PRIMARY KEY' => 'id_mot,id_objet,objet',
'KEY id_mot' => 'id_mot',
'KEY id_objet' => 'id_objet',
'KEY objet' => 'objet',
];
$tables_auxiliaires['spip_mots_liens'] =
['field' => &$spip_mots_liens, 'key' => &$spip_mots_liens_key];
return $tables_auxiliaires;
}
/**
* Déclarer les objets éditoriaux des mots et groupes de mots
*
* @pipeline declarer_tables_objets_sql
* @param array $tables
* Description des tables
* @return array
* Description complétée des tables
*/
function mots_declarer_tables_objets_sql($tables) {
$tables['spip_mots'] = [
'type' => 'mot',
'type_surnoms' => ['mot-cle'], // pour les icones...
'texte_retour' => 'icone_retour',
'texte_objets' => 'public:mots_clefs',
'texte_objet' => 'public:mots_clef',
'texte_modifier' => 'mots:icone_modifier_mot',
'texte_ajouter' => 'titre_ajouter_un_mot', // # A deplacer
'texte_creer' => 'titre_ajouter_un_mot',
'texte_logo_objet' => 'mots:logo_mot_cle',
'texte_creer_associer' => 'mots:creer_et_associer_un_mot',
'info_aucun_objet' => 'mots:info_aucun_mot_cle',
'info_1_objet' => 'info_1_mot_cle',
'info_nb_objets' => 'info_nb_mots_cles',
'titre' => "titre, '' AS lang",
'date' => 'date',
'principale' => 'oui',
'field' => [
'id_mot' => 'bigint(21) NOT NULL',
'titre' => "text DEFAULT '' NOT NULL",
'descriptif' => "text DEFAULT '' NOT NULL",
'texte' => "longtext DEFAULT '' NOT NULL",
'id_groupe' => 'bigint(21) DEFAULT 0 NOT NULL',
'type' => "text DEFAULT '' NOT NULL",
'maj' => 'TIMESTAMP'
],
'key' => [
'PRIMARY KEY' => 'id_mot',
'KEY id_groupe' => 'id_groupe'
],
'parent' => ['type' => 'groupe_mot', 'champ' => 'id_groupe'],
'rechercher_champs' => [
'titre' => 8,
'texte' => 1,
'descriptif' => 5
],
'tables_jointures' => [#'mots_liens' // declare generiquement ci dessous
],
'champs_editables' => [
'titre',
'descriptif',
'texte',
'id_groupe',
],
'champs_versionnes' => [
'titre',
'descriptif',
'texte',
'id_groupe'
],
];
$tables['spip_groupes_mots'] = [
'table_objet_surnoms' => [
'groupemot',
'groupe_mots'
/*hum*/,
'groupe_mot'
/* hum*/,
'groupe'
/*hum (EXPOSE)*/
],
'type' => 'groupe_mots',
'type_surnoms' => ['groupes_mot', 'groupemot', 'groupe_mot'],
'texte_retour' => 'icone_retour',
'texte_objets' => 'mots:titre_groupes_mots',
'texte_objet' => 'mots:titre_groupe_mots',
'texte_modifier' => 'mots:icone_modif_groupe_mots',
'texte_creer' => 'mots:icone_creation_groupe_mots',
'texte_logo_objet' => 'mots:logo_groupe',
'info_aucun_objet' => 'mots:info_aucun_groupemots',
'info_1_objet' => 'mots:info_1_groupemots',
'info_nb_objets' => 'mots:info_nb_groupemots',
'titre' => "titre, '' AS lang",
'principale' => 'oui',
'page' => '', // pas de page publique pour les groupes
'field' => [
'id_groupe' => 'bigint(21) NOT NULL',
'titre' => "text DEFAULT '' NOT NULL",
'descriptif' => "text DEFAULT '' NOT NULL",
'texte' => "longtext DEFAULT '' NOT NULL",
'unseul' => "varchar(3) DEFAULT '' NOT NULL",
'obligatoire' => "varchar(3) DEFAULT '' NOT NULL",
'tables_liees' => "text DEFAULT '' NOT NULL",
'minirezo' => "varchar(3) DEFAULT '' NOT NULL",
'comite' => "varchar(3) DEFAULT '' NOT NULL",
'forum' => "varchar(3) DEFAULT '' NOT NULL",
'maj' => 'TIMESTAMP'
],
'key' => [
'PRIMARY KEY' => 'id_groupe'
],
'rechercher_champs' => [
'titre' => 8,
'texte' => 1,
'descriptif' => 5
],
'tables_jointures' => [
'mots'
],
'champs_editables' => [
'titre',
'descriptif',
'texte',
'tables_liees',
'obligatoire',
'unseul',
'comite',
'forum',
'minirezo',
],
'champs_versionnes' => [
'titre',
'descriptif',
'texte',
'unseul',
'obligatoire',
'tables_liees',
'minirezo',
'forum',
'comite',
],
];
// jointures sur les mots pour tous les objets
$tables[]['tables_jointures'][] = 'mots_liens';
$tables[]['tables_jointures'][] = 'mots';
// cas particulier des auteurs et mots : declarer explicitement mots_liens comme jointure privilegiee
// cf https://core.spip.net/issues/2329
$tables['spip_auteurs']['tables_jointures'][] = 'mots_liens';
$tables['spip_auteurs']['tables_jointures'][] = 'mots';
$tables['spip_mots']['tables_jointures'][] = 'mots_liens';
$tables['spip_mots']['tables_jointures'][] = 'mots';
// recherche jointe sur les mots pour tous les objets
$tables[]['rechercher_jointures']['mot'] = ['titre' => 3];
// versionner les jointures pour tous les objets
$tables[]['champs_versionnes'][] = 'jointure_mots';
return $tables;
}