mots.php 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  1. <?php
  2. /***************************************************************************\
  3. * SPIP, Systeme de publication pour l'internet *
  4. * *
  5. * Copyright (c) 2001-2014 *
  6. * Arnaud Martin, Antoine Pitrou, Philippe Riviere, Emmanuel Saint-James *
  7. * *
  8. * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
  9. * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
  10. \***************************************************************************/
  11. if (!defined('_ECRIRE_INC_VERSION')) return;
  12. /**
  13. * Interfaces des tables mots et groupes de mots pour le compilateur
  14. *
  15. * @param array $interfaces
  16. * @return array
  17. */
  18. function mots_declarer_tables_interfaces($interfaces){
  19. $interfaces['table_des_tables']['mots']='mots';
  20. $interfaces['table_des_tables']['groupes_mots']='groupes_mots';
  21. $interfaces['exceptions_des_jointures']['titre_mot'] = array('spip_mots', 'titre');
  22. $interfaces['exceptions_des_jointures']['type_mot'] = array('spip_mots', 'type');
  23. $interfaces['exceptions_des_jointures']['id_mot_syndic'] = array('spip_mots_liens', 'id_mot');
  24. $interfaces['exceptions_des_jointures']['titre_mot_syndic'] = array('spip_mots', 'titre');
  25. $interfaces['exceptions_des_jointures']['type_mot_syndic'] = array('spip_mots', 'type');
  26. $interfaces['exceptions_des_jointures']['spip_articles']['id_groupe'] = array('spip_mots', 'id_groupe');
  27. $interfaces['exceptions_des_jointures']['spip_rubriques']['id_groupe'] = array('spip_mots', 'id_groupe');
  28. return $interfaces;
  29. }
  30. /**
  31. * Table auxilaire spip_mots_xx
  32. *
  33. * @param array $tables_auxiliaires
  34. * @return array
  35. */
  36. function mots_declarer_tables_auxiliaires($tables_auxiliaires){
  37. $spip_mots_liens = array(
  38. "id_mot" => "bigint(21) DEFAULT '0' NOT NULL",
  39. "id_objet" => "bigint(21) DEFAULT '0' NOT NULL",
  40. "objet" => "VARCHAR (25) DEFAULT '' NOT NULL");
  41. $spip_mots_liens_key = array(
  42. "PRIMARY KEY" => "id_mot,id_objet,objet",
  43. "KEY id_mot" => "id_mot",
  44. "KEY id_objet" => "id_objet",
  45. "KEY objet" => "objet",
  46. );
  47. $tables_auxiliaires['spip_mots_liens'] =
  48. array('field' => &$spip_mots_liens, 'key' => &$spip_mots_liens_key);
  49. return $tables_auxiliaires;
  50. }
  51. /**
  52. * Declarer les objets mots et les jointures mots pour tous les objets
  53. *
  54. * @param array $tables
  55. * @return array
  56. */
  57. function mots_declarer_tables_objets_sql($tables){
  58. $tables['spip_mots'] = array(
  59. 'type' => 'mot',
  60. 'type_surnoms' => array('mot-cle'), // pour les icones...
  61. 'texte_retour' => 'icone_retour',
  62. 'texte_objets' => 'public:mots_clefs',
  63. 'texte_objet' => 'public:mots_clef',
  64. 'texte_modifier' => 'mots:icone_modifier_mot',
  65. 'texte_ajouter' => 'titre_ajouter_un_mot', // # A deplacer
  66. 'texte_creer' => 'titre_ajouter_un_mot',
  67. 'texte_logo_objet' => 'mots:logo_mot_cle',
  68. 'texte_creer_associer' => 'mots:creer_et_associer_un_mot',
  69. 'info_aucun_objet'=> 'mots:info_aucun_mot_cle',
  70. 'info_1_objet' => 'info_1_mot_cle',
  71. 'info_nb_objets' => 'info_nb_mots_cles',
  72. 'titre' => "titre, '' AS lang",
  73. 'date' => 'date',
  74. 'principale' => 'oui',
  75. 'field'=> array(
  76. "id_mot" => "bigint(21) NOT NULL",
  77. "titre" => "text DEFAULT '' NOT NULL",
  78. "descriptif" => "text DEFAULT '' NOT NULL",
  79. "texte" => "longtext DEFAULT '' NOT NULL",
  80. "id_groupe" => "bigint(21) DEFAULT 0 NOT NULL",
  81. "type" => "text DEFAULT '' NOT NULL",
  82. "maj" => "TIMESTAMP"
  83. ),
  84. 'key' => array(
  85. "PRIMARY KEY" => "id_mot",
  86. "KEY id_groupe" => "id_groupe"
  87. ),
  88. 'rechercher_champs' => array(
  89. 'titre' => 8, 'texte' => 1, 'descriptif' => 5
  90. ),
  91. 'tables_jointures' => array(
  92. #'mots_liens' // declare generiquement ci dessous
  93. ),
  94. 'champs_versionnes' => array('titre', 'descriptif', 'texte','id_groupe'),
  95. );
  96. $tables['spip_groupes_mots'] = array(
  97. 'table_objet_surnoms' => array('groupemot','groupe_mots' /*hum*/,'groupe_mot' /* hum*/,'groupe' /*hum (EXPOSE)*/),
  98. 'type'=>'groupe_mots',
  99. 'type_surnoms' => array('groupes_mot','groupemot','groupe_mot'),
  100. 'texte_retour' => 'icone_retour',
  101. 'texte_objets' => 'mots:titre_groupes_mots',
  102. 'texte_objet' => 'mots:titre_groupe_mots',
  103. 'texte_modifier' => 'mots:icone_modif_groupe_mots',
  104. 'texte_creer' => 'mots:icone_creation_groupe_mots',
  105. 'texte_logo_objet' => 'mots:logo_groupe',
  106. 'info_aucun_objet'=> 'mots:info_aucun_groupemots',
  107. 'info_1_objet' => 'mots:info_1_groupemots',
  108. 'info_nb_objets' => 'mots:info_nb_groupemots',
  109. 'titre' => "titre, '' AS lang",
  110. 'date' => 'date',
  111. 'principale' => 'oui',
  112. 'page' => '', // pas de page publique pour les groupes
  113. 'field'=> array(
  114. "id_groupe" => "bigint(21) NOT NULL",
  115. "titre" => "text DEFAULT '' NOT NULL",
  116. "descriptif" => "text DEFAULT '' NOT NULL",
  117. "texte" => "longtext DEFAULT '' NOT NULL",
  118. "unseul" => "varchar(3) DEFAULT '' NOT NULL",
  119. "obligatoire" => "varchar(3) DEFAULT '' NOT NULL",
  120. "tables_liees" => "text DEFAULT '' NOT NULL",
  121. "minirezo" => "varchar(3) DEFAULT '' NOT NULL",
  122. "comite" => "varchar(3) DEFAULT '' NOT NULL",
  123. "forum" => "varchar(3) DEFAULT '' NOT NULL",
  124. "maj" => "TIMESTAMP"
  125. ),
  126. 'key' => array(
  127. "PRIMARY KEY" => "id_groupe"
  128. ),
  129. 'rechercher_champs' => array(
  130. 'titre' => 8, 'texte' => 1, 'descriptif' => 5
  131. ),
  132. 'tables_jointures' => array(
  133. 'mots'
  134. ),
  135. 'champs_versionnes' => array('titre', 'descriptif', 'texte','un_seul','obligatoire','tables_liees','minirezo','forum','comite'),
  136. );
  137. // jointures sur les mots pour tous les objets
  138. $tables[]['tables_jointures'][]= 'mots_liens';
  139. $tables[]['tables_jointures'][]= 'mots';
  140. // cas particulier des auteurs et mots : declarer explicitement mots_liens comme jointure privilegiee
  141. // cf https://core.spip.net/issues/2329
  142. $tables['spip_auteurs']['tables_jointures'][]= 'mots_liens';
  143. $tables['spip_auteurs']['tables_jointures'][]= 'mots';
  144. $tables['spip_mots']['tables_jointures'][]= 'mots_liens';
  145. $tables['spip_mots']['tables_jointures'][]= 'mots';
  146. // recherche jointe sur les mots pour tous les objets
  147. $tables[]['rechercher_jointures']['mot'] = array('titre' => 3);
  148. // versionner les jointures pour tous les objets
  149. $tables[]['champs_versionnes'][] = 'jointure_mots';
  150. return $tables;
  151. }
  152. ?>