/_plugins_/mots_partout/2.0/mots_partout_choses.php

https://bitbucket.org/pombredanne/spip-zone-treemap · PHP · 293 lines · 202 code · 26 blank · 65 comment · 6 complexity · 2546c9ab21ec66e1b611dec45f255e2b MD5 · raw file

  1. <?php
  2. /***************************************************************************\
  3. * SPIP, Systeme de publication pour l'internet *
  4. * Plugin Mots-Partout *
  5. * *
  6. * Copyright (c) 2006-2008 *
  7. * Pierre ANDREWS, Yoann Nogues, Emmanuel Saint-James *
  8. * *
  9. * Ce programme est un logiciel libre distribue sous licence GNU/GPL. *
  10. * Pour plus de details voir le fichier COPYING.txt ou l'aide en ligne. *
  11. * This program is free software; you can redistribute it and/or modify *
  12. * it under the terms of the GNU General Public License as published by *
  13. * the Free Software Foundation. *
  14. \***************************************************************************/
  15. if (!defined("_ECRIRE_INC_VERSION")) return;
  16. // 2 petits utilitaires
  17. //force a un tableau de int
  18. if(!function_exists('secureIntArray')){
  19. function secureIntArray($array) {
  20. $to_return = Array();
  21. if(is_array($array)) {
  22. foreach($array as $id) {
  23. $to_return[] = intval($id);
  24. }
  25. }
  26. return $to_return;
  27. }
  28. }
  29. // transfert la variable POST d'un tableau (19 => 'avec', 20=>'voir') en 4 tableaux avec=(19) voir=(20)
  30. if(!function_exists("splitArrayIds")){
  31. function splitArrayIds($array) {
  32. $voir = Array();
  33. $cacher = Array();
  34. $ajouter = Array();
  35. $enlever = Array();
  36. if(is_array($array)) {
  37. foreach($array as $id_mot => $action) {
  38. $id_mot = intval($id_mot);
  39. if($id_mot > 0) {
  40. switch(addslashes($action)) {
  41. case 'avec':
  42. $ajouter[] = $id_mot;
  43. case 'voir':
  44. $voir[] = $id_mot;
  45. break;
  46. case 'sans':
  47. $enlever[] = $id_mot;
  48. break;
  49. case 'cacher':
  50. $cacher[] = $id_mot;
  51. break;
  52. }
  53. }
  54. }
  55. }
  56. return array($voir, $cacher, $ajouter, $enlever);
  57. }
  58. }
  59. global $tables_principales;
  60. $tables_principales['spip_mots_documents']['field'] = array(
  61. "id_mot" => "BIGINT (21) DEFAULT '0' NOT NULL",
  62. "id_document" => "BIGINT (21) DEFAULT '0' NOT NULL");
  63. $tables_principales['spip_mots_documents']['key'] = array(
  64. "KEY id_mot" => "id_mot",
  65. "KEY id_document" => "id_document");
  66. global $tables_relations;
  67. $tables_relations['mots']['id_document'] = 'mots_documents';
  68. $tables_relations['documents']['id_mot'] = 'mots_documents';
  69. global $choses_possibles,$statuts_possibles;
  70. $statuts_possibles[]='publie';
  71. $statuts_possibles[]='propose';
  72. $statuts_possibles[]='technique';
  73. $statuts_possibles[]='poubelle';
  74. $choses_possibles['articles'] = array(
  75. 'titre_chose' => 'public:articles',
  76. 'id_chose' => 'id_article',
  77. 'table_principale' => 'spip_articles',
  78. 'table_auth' => 'spip_auteurs_articles',
  79. 'tables_limite' => array(
  80. 'articles' => array(
  81. 'table' => 'spip_articles',
  82. 'nom_id' => 'id_article'),
  83. 'rubriques' => array(
  84. 'table' => 'spip_articles',
  85. 'nom_id' => 'id_rubrique'),
  86. 'documents' => array(
  87. 'table' => 'spip_documents_articles',
  88. 'nom_id' => 'id_document'),
  89. 'auteurs' => array(
  90. 'table' => 'spip_auteurs_articles',
  91. 'nom_id' => 'id_auteur')
  92. )
  93. );
  94. $choses_possibles['breves'] = array(
  95. 'titre_chose' => 'breves',
  96. 'id_chose' => 'id_breve',
  97. 'table_principale' => 'spip_breves',
  98. 'url_base' => 'breves_voir',
  99. 'tables_limite' => array(
  100. 'breves' => array(
  101. 'table' => 'spip_breves',
  102. 'nom_id' => 'id_breve'),
  103. 'rubriques' => array(
  104. 'table' => 'spip_breves',
  105. 'nom_id' => 'id_rubrique')
  106. )
  107. );
  108. $choses_possibles['rubriques'] = array(
  109. 'titre_chose' => 'rubriques',
  110. 'id_chose' => 'id_rubrique',
  111. 'table_principale' => 'spip_rubriques',
  112. 'url_base' => 'naviguer',
  113. 'table_auth' => 'spip_auteurs_rubriques',
  114. 'tables_limite' => array(
  115. 'rubriques' => array(
  116. 'table' => 'spip_rubriques',
  117. 'nom_id' => 'id_rubrique'),
  118. 'secteurs' => array(
  119. 'table' => 'spip_rubriques',
  120. 'nom_id' => 'id_secteur'),
  121. 'parents' => array(
  122. 'table' => 'spip_rubriques',
  123. 'nom_id' => 'id_parent'),
  124. 'documents' => array(
  125. 'table' => 'spip_documents_rubriques',
  126. 'nom_id' => 'id_document'),
  127. 'auteurs' => array(
  128. 'table' => 'spip_auteurs_articles',
  129. 'nom_id' => 'id_auteur')
  130. )
  131. );
  132. $choses_possibles['syndic'] = array(
  133. 'titre_chose' => 'syndic',
  134. 'id_chose' => 'id_syndic',
  135. //exception : objet (voir inc/mot.php)
  136. 'objet' => 'syndic',
  137. 'table_principale' => 'spip_syndic',
  138. 'tables_limite' => array(
  139. 'rubrique' => array(
  140. 'table' => 'spip_syndic',
  141. 'nom_id' => 'id_rubriques'),
  142. 'secteur' => array(
  143. 'table' => 'spip_syndic',
  144. 'nom_id' => 'id_secteur')
  145. )
  146. );
  147. $choses_possibles['syndic_articles'] = array(
  148. 'titre_chose' => 'Items RSS',
  149. 'id_chose' => 'id_syndic_article',
  150. 'table_principale' => 'spip_syndic_articles',
  151. 'tables_limite' => array(
  152. 'sites' => array(
  153. 'table' => 'spip_syndic',
  154. 'nom_id' => 'id_syndic'),
  155. )
  156. );
  157. /*$choses_possibles['forum'] = array(
  158. 'titre_chose' => 'forum',
  159. 'id_chose' => 'id_forum',
  160. 'table_principale' => 'spip_forum',
  161. 'tables_limite' => array(
  162. 'forum' => array(
  163. 'table' => 'spip_forum',
  164. 'nom_id' => 'id_forum'),
  165. 'parent' => array(
  166. 'table' => 'spip_forum',
  167. 'nom_id' => 'id_parent'),
  168. 'thread' => array(
  169. 'table' => 'spip_forum',
  170. 'nom_id' => 'id_thread'),
  171. 'articles' => array(
  172. 'table' => 'spip_articles',
  173. 'nom_id' => 'id_article'),
  174. 'breves' => array(
  175. 'table' => 'spip_breves',
  176. 'nom_id' => 'id_breve'),
  177. 'rubriques' => array(
  178. 'table' => 'spip_rubriques',
  179. 'nom_id' => 'id_rubrique'),
  180. 'auteurs' => array(
  181. 'table' => 'spip_forum',
  182. 'nom_id' => 'id_auteur')
  183. )
  184. );
  185. */
  186. $choses_possibles['documents'] = array(
  187. 'titre_chose' => 'info_documents',
  188. 'id_chose' => 'id_document',
  189. 'table_principale' => 'spip_documents',
  190. 'tables_limite' => array(
  191. 'articles' => array(
  192. 'table' => 'spip_documents_articles',
  193. 'nom_id' => 'id_article'),
  194. 'rubriques' => array(
  195. 'table' => 'spip_documents_rubriques',
  196. 'nom_id' => 'id_rubrique'),
  197. 'documents' => array(
  198. 'table' => 'spip_documents',
  199. 'nom_id' => 'id_document')
  200. )
  201. );
  202. $choses_possibles['messages'] = array(
  203. 'titre_chose' => 'Messages',
  204. 'id_chose' => 'id_message',
  205. 'table_principale' => 'spip_messages',
  206. 'table_auth' => 'spip_auteurs_messages',
  207. 'tables_limite' => array(
  208. 'messages' => array(
  209. 'table' => 'spip_messages',
  210. 'nom_id' => 'id_message'),
  211. 'auteurs' => array(
  212. 'table' => 'spip_auteurs_messages',
  213. 'nom_id' => 'id_auteur')
  214. )
  215. );
  216. $choses_possibles['evenements'] = array(
  217. 'titre_chose' => 'Evenements',
  218. 'id_chose' => 'id_evenement',
  219. 'table_principale' => 'spip_evenements',
  220. 'tables_limite' => array(
  221. 'article' => array(
  222. 'table' => 'spip_articles',
  223. 'nom_id' => 'id_article')
  224. )
  225. );
  226. $choses_possibles['auteurs'] = array(
  227. 'titre_chose' => 'auteurs',
  228. 'id_chose' => 'id_auteur',
  229. 'table_principale' => 'spip_auteurs',
  230. 'tables_limite' => array(
  231. 'auteurs' => array(
  232. 'table' => 'spip_auteurs',
  233. 'nom_id' => 'id_auteur'),
  234. 'articles' => array(
  235. 'table' => 'spip_auteurs_articles',
  236. 'nom_id' => 'id_auteur')
  237. )
  238. );
  239. $choses_possibles['groupes_mots'] = array(
  240. 'titre_chose' => 'groupes_mots',
  241. 'id_chose' => 'id_groupe',
  242. 'table_principale' => 'spip_groupes_mots',
  243. 'tables_limite' => array(
  244. 'mots' => array(
  245. 'table' => 'spip_mots',
  246. 'nom_id' => 'id_mot'),
  247. )
  248. );
  249. //=============================MOTS=========================================
  250. /*
  251. on ne peut pas vraiment mettre de mots sur les mots comme c'est fait maintenant :(
  252. $choses_possibles['mots'] = array(
  253. 'titre_chose' => 'mots',
  254. 'id_chose' => 'id_mot2',
  255. 'table_principale' => 'spip_mots',
  256. 'tables_limite' => array(
  257. 'rubriques' => array(
  258. 'table' => 'spip_rubriques',
  259. 'nom_id' => 'id_rubrique'),
  260. 'articles' => array(
  261. 'table' => 'spip_articles',
  262. 'nom_id' => 'id_article')
  263. )
  264. );
  265. */