modele.plugin.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. //Cette fonction va generer un nouveau element dans le menu
  3. function test_plugin_menu(&$menuItems){
  4. global $_;
  5. $menuItems[] = array(
  6. 'sort'=>10,
  7. 'url'=>'index.php?module=modele',
  8. 'label'=>'Modele',
  9. 'icon'=>'codepen'
  10. );
  11. }
  12. //Cette fonction va generer une page quand on clique sur Modele dans menu
  13. function test_plugin_page(){
  14. global $_;
  15. if(!isset($_['module']) || $_['module']!='modele') return;
  16. ?>
  17. <h3>Mon plugin</h3>
  18. <h5>Plugins d'exemple</h5>
  19. <?php
  20. }
  21. function test_plugin_install($id){
  22. if($id != 'fr.idleman.modele') return;
  23. // en cas d'erreur : throw new Exception('Mon erreur');
  24. }
  25. function test_plugin_uninstall($id){
  26. if($id != 'fr.idleman.modele') return;
  27. // en cas d'erreur : throw new Exception('Mon erreur');
  28. }
  29. function test_plugin_section(&$sections){
  30. $sections['modele'] = 'Gestion du plugin Modèle';
  31. }
  32. //cette fonction comprends toutes les actions du plugin qui ne nécessitent pas de vue html
  33. function test_plugin_action(){
  34. require_once('action.php');
  35. }
  36. Plugin::addCss("/main.css");
  37. Plugin::addJs("/main.js");
  38. Plugin::addHook("install", "test_plugin_install");
  39. Plugin::addHook("uninstall", "test_plugin_uninstall");
  40. Plugin::addHook("section", "test_plugin_section");
  41. Plugin::addHook("menu_main", "test_plugin_menu");
  42. Plugin::addHook("page", "test_plugin_page");
  43. Plugin::addHook("action", "test_plugin_action");
  44. ?>