customiser.plugin.php 1.9 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. //Fonction executée lors de l'activation du plugin
  3. function customiser_install($id){
  4. if($id != 'fr.idleman.customiser') return;
  5. Entity::install(__DIR__);
  6. }
  7. //Fonction executée lors de la désactivation du plugin
  8. function customiser_uninstall($id){
  9. if($id != 'fr.idleman.customiser') return;
  10. Entity::uninstall(__DIR__);
  11. }
  12. //Déclaration des sections de droits du plugin
  13. function customiser_section(&$sections){
  14. $sections['customiser'] = "Gestion des droits sur le plugin customiser";
  15. }
  16. //Cette fonction comprends toutes les actions
  17. //du plugin qui ne nécessitent pas de vue html
  18. function customiser_action(){
  19. require_once(__DIR__.SLASH.'action.php');
  20. }
  21. //Déclaration du menu de réglages
  22. function customiser_menu_setting(&$settingMenu){
  23. global $_, $myUser;
  24. if(!$myUser->can('customiser','configure')) return;
  25. $settingMenu[]= array(
  26. 'sort' =>1,
  27. 'url' => 'setting.php?section=global.customiser',
  28. 'icon' => 'fas fa-angle-right',
  29. 'label' => 'Thème'
  30. );
  31. }
  32. //Déclaration des pages de réglages
  33. function customiser_content_setting(){
  34. global $_;
  35. if(file_exists(__DIR__.SLASH.'setting.'.$_['section'].'.php'))
  36. require_once(__DIR__.SLASH.'setting.'.$_['section'].'.php');
  37. }
  38. global $conf;
  39. if(!empty($conf->get('core_theme'))){
  40. Plugin::addCss(str_replace('plugin/customiser','',$conf->get('core_theme')),true);
  41. }
  42. //Déclation des assets
  43. if(file_exists(__DIR__.SLASH.'css'.SLASH.'theme.css'))
  44. Plugin::addCss("/css/theme.css?v=".filemtime(__DIR__.SLASH.'css'.SLASH.'theme.css'));
  45. Plugin::addCss("/css/main.css");
  46. Plugin::addJs("/js/main.js");
  47. //Mapping hook / fonctions
  48. Plugin::addHook("install", "customiser_install");
  49. Plugin::addHook("uninstall", "customiser_uninstall");
  50. Plugin::addHook("section", "customiser_section");
  51. Plugin::addHook("action", "customiser_action");
  52. Plugin::addHook("menu_setting", "customiser_menu_setting");
  53. Plugin::addHook("content_setting", "customiser_content_setting");
  54. ?>