hackpoint.plugin.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123
  1. <?php
  2. //Déclaration d'un item de menu dans le menu principal
  3. function hackpoint_menu(&$menuItems){
  4. global $_,$myUser;
  5. if(!$myUser->can('hackpoint','read')) return;
  6. $menuItems[] = array(
  7. 'sort'=>3,
  8. 'url'=>'index.php?module=hackpoint',
  9. 'label'=>'Hackpoint',
  10. 'icon'=> 'fas fa-wrench',
  11. 'color'=> '#3498db'
  12. );
  13. $menuItems[] = array(
  14. 'sort'=>3,
  15. 'url'=>'index.php?module=hackpoint&page=list.part',
  16. 'label'=>'Composants',
  17. 'icon'=> 'fas fa-microchip',
  18. 'color'=> '#3498db'
  19. );
  20. }
  21. //Cette fonction va generer une page quand on clique sur hackpoint dans menu
  22. function hackpoint_page(){
  23. global $_,$myUser;
  24. if(!isset($_['module']) || $_['module'] !='hackpoint') return;
  25. $page = !isset($_['page']) ? 'list.sketch' : $_['page'];
  26. $file = __DIR__.SLASH.'page.'.$page.'.php';
  27. if(!file_exists($file)) throw new Exception("Page ".$page." inexistante");
  28. require_once($file);
  29. }
  30. //Fonction executée lors de l'activation du plugin
  31. function hackpoint_install($id){
  32. if($id != 'fr.idleman.hackpoint') return;
  33. Entity::install(__DIR__);
  34. }
  35. //Fonction executée lors de la désactivation du plugin
  36. function hackpoint_uninstall($id){
  37. if($id != 'fr.idleman.hackpoint') return;
  38. Entity::uninstall(__DIR__);
  39. }
  40. //Déclaration des sections de droits du plugin
  41. function hackpoint_section(&$sections){
  42. $sections['hackpoint'] = "Gestion des droits sur le plugin hackpoint";
  43. // $sections['part'] = "Gestion des droits sur l'entité part";
  44. }
  45. //cette fonction comprends toutes les actions du plugin qui ne nécessitent pas de vue html
  46. function hackpoint_action(){
  47. require_once(__DIR__.SLASH.'action.php');
  48. }
  49. //Déclaration du menu de réglages
  50. function hackpoint_menu_setting(&$settingMenu){
  51. global $_, $myUser;
  52. if(!$myUser->can('hackpoint','configure')) return;
  53. $settingMenu[]= array(
  54. 'sort' =>1,
  55. 'url' => 'setting.php?section=global.hackpoint',
  56. 'icon' => 'fas fa-angle-right',
  57. 'label' => 'hackpoint Général'
  58. );
  59. }
  60. //Déclaration des pages de réglages
  61. function hackpoint_content_setting(){
  62. global $_;
  63. if(file_exists(__DIR__.SLASH.'setting.'.$_['section'].'.php'))
  64. require_once(__DIR__.SLASH.'setting.'.$_['section'].'.php');
  65. }
  66. //Déclaration des settings de base
  67. //Types possibles : text,select ( + "values"=> array('1'=>'Val 1'),password,checkbox. Un simple string définit une catégorie.
  68. Configuration::setting('hackpoint',array(
  69. "Général",
  70. 'hackpoint_enable' => array("label"=>"Activer","type"=>"checkbox"),
  71. ));
  72. function hackpoint_manage_types(&$types){
  73. $types = array_merge($types,glob(__DIR__.SLASH.'types'.SLASH.'*.class.php'));
  74. }
  75. //Déclation des assets
  76. Plugin::addCss("/css/main.css?v=1");
  77. Plugin::addCss("/css/codemirror.css?v=1");
  78. Plugin::addCss("/css/codemirror-monokai.css?v=1");
  79. Plugin::addCss("/css/component.css?v=1",true);
  80. Plugin::addJs("/js/main.js?v=1");
  81. Plugin::addJs("/js/codemirror.js?v=1");
  82. Plugin::addJs("/js/component.js?v=2",true);
  83. foreach(glob(__DIR__.SLASH.'js'.SLASH.'codemirror-mode'.SLASH.'*.js') as $file){
  84. Plugin::addJs("/js/codemirror-mode/".basename($file));
  85. }
  86. //Mapping hook / fonctions
  87. Plugin::addHook("install", "hackpoint_install");
  88. Plugin::addHook("uninstall", "hackpoint_uninstall");
  89. Plugin::addHook("section", "hackpoint_section");
  90. Plugin::addHook("menu_main", "hackpoint_menu");
  91. Plugin::addHook("page", "hackpoint_page");
  92. Plugin::addHook("action", "hackpoint_action");
  93. Plugin::addHook("menu_setting", "hackpoint_menu_setting");
  94. Plugin::addHook("content_setting", "hackpoint_content_setting");
  95. Plugin::addHook("hackpoint_resource_type", "hackpoint_manage_types");
  96. ?>