debug.plugin.php 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  1. <?php
  2. /*
  3. @name Debug
  4. @author Valentin CARRUESCO <idleman@idleman.fr>
  5. @link Http://blog.idleman.fr
  6. @licence Cc -by-nc-sa
  7. @version 1.1
  8. @description Permet le debug pour tester les communications entre client(s) et serveur
  9. */
  10. //cette fonction comprends toutes les actions du plugin qui ne nécessitent pas de vue html
  11. function debug_plugin_action(){
  12. global $_,$conf,$myUser;
  13. //Action de réponse à la commande vocale "Yana, commande de test"
  14. switch($_['action']){
  15. case 'plugin_debug_send':
  16. require_once('Debug.class.php');
  17. try{
  18. $debugs = Debug::loadAll();
  19. $debug = $debugs[$_['debug']];
  20. $t = $debug->execute;
  21. $t();
  22. }catch(Exception $e){
  23. echo $e->getMessage();
  24. }
  25. break;
  26. }
  27. }
  28. function debug_plugin_setting_page(){
  29. global $_,$myUser,$conf;
  30. if(isset($_['section']) && $_['section']=='debug' ){
  31. require_once('Debug.class.php');
  32. try {
  33. if(!$myUser) throw new Exception('Vous devez être connecté pour effectuer cette action');
  34. ?>
  35. <div class="form-inline">
  36. <select id="debug_selector">
  37. <?php foreach(Debug::loadAll() as $uid=>$debug): ?>
  38. <option value="<?php echo $uid; ?>"><?php echo $debug->label; ?></option>
  39. <?php endforeach; ?>
  40. </select><button onclick="debug_plugin_send(this);">Envoyer</button>
  41. </div>
  42. <textarea id="debug_monitor" class="debug_monitor"></textarea>
  43. <?php
  44. } catch (Exception $e) {
  45. Functions::htmlAlert('error',$e->getMessage());
  46. }
  47. }
  48. }
  49. function debug_plugin_setting_menu(){
  50. global $_;
  51. echo '<li '.(isset($_['section']) && $_['section']=='debug'?'class="active"':'').'><a href="setting.php?section=debug"><i class="fa fa-angle-right"></i> Debug</a></li>';
  52. }
  53. /*
  54. function debug_plugin_listen($command,$text,$confidence){
  55. //echo 'diction de la commande : '.$command;
  56. }
  57. */
  58. Plugin::addCss("/css/main.css");
  59. Plugin::addJs("/js/main.js");
  60. //Lie debug_plugin_setting_page a la zone réglages
  61. Plugin::addHook("setting_bloc", "debug_plugin_setting_page");
  62. //Lie debug_plugin_setting_menu au menu de réglages
  63. Plugin::addHook("setting_menu", "debug_plugin_setting_menu");
  64. //Lie debug_plugin_action a la page d'action qui perme d'effecuer des actionx ajax ou ne demdnant pas de retour visuels
  65. Plugin::addHook("action_post_case", "debug_plugin_action");
  66. //Lie debug_plugin_vocal_command a la gestion de commandes vocales proposées par yana
  67. //Plugin::addHook("vocal_command", "debug_plugin_vocal_command");
  68. //Plugin::addHook("listen", "debug_plugin_listen");
  69. ?>