debug.lib.inc.php 2.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. <?php
  2. /* For licensing terms, see /license.txt */
  3. /**
  4. * This is the debug library for Chamilo.
  5. * Include/require it in your code to use its functionality.
  6. *
  7. * debug functions
  8. *
  9. * @package chamilo.library
  10. */
  11. /**
  12. * This function displays the contend of a variable, array or object in a nicely formatted way.
  13. * @param $variable a variable, array or object
  14. * @return html code;
  15. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  16. * @version November 2006
  17. */
  18. function debug($variable)
  19. {
  20. echo '<pre>';
  21. print_r($variable);
  22. echo '</pre>';
  23. }
  24. /**
  25. * This function displays all the information of the dokeos $_course array
  26. * This array stores all the information of the current course if the user is in a course.
  27. * This is why this array is used to check weither the user is currently is in the course.
  28. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  29. * @version November 2006
  30. */
  31. function debug_course()
  32. {
  33. global $_course;
  34. debug($_course);
  35. }
  36. /**
  37. * This function displays all the information of the dokeos $_user array
  38. * This array stores all the information of the current user.
  39. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  40. * @version November 2006
  41. */
  42. function debug_user()
  43. {
  44. global $_user;
  45. debug($_user);
  46. }
  47. /**
  48. * This function displays an overview of the different path constants that can be used with the api_get_path function
  49. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  50. * @version November 2006
  51. */
  52. function debug_paths()
  53. {
  54. echo 'WEB_PATH :'.api_get_path(WEB_PATH).'<br />';
  55. echo 'SYS_PATH :'.api_get_path(SYS_PATH).'<br />';
  56. echo 'REL_PATH :'.api_get_path(REL_PATH).'<br />';
  57. echo 'WEB_COURSE_PATH :'.api_get_path(WEB_COURSE_PATH).'<br />';
  58. echo 'SYS_COURSE_PATH :'.api_get_path(SYS_COURSE_PATH).'<br />';
  59. echo 'REL_COURSE_PATH :'.api_get_path(REL_COURSE_PATH).'<br />';
  60. echo 'REL_CLARO_PATH :'.api_get_path(REL_CODE_PATH).'<br />';
  61. echo 'WEB_CODE_PATH :'.api_get_path(WEB_CODE_PATH).'<br />';
  62. echo 'SYS_CODE_PATH :'.api_get_path(SYS_CODE_PATH).'<br />';
  63. echo 'SYS_LANG_PATH :'.api_get_path(SYS_LANG_PATH).'<br />';
  64. echo 'WEB_IMG_PATH :'.api_get_path(WEB_IMG_PATH).'<br />';
  65. echo 'GARBAGE_PATH :'.api_get_path(GARBAGE_PATH).'<br />';
  66. echo 'PLUGIN_PATH :'.api_get_path(PLUGIN_PATH).'<br />';
  67. echo 'SYS_ARCHIVE_PATH :'.api_get_path(SYS_ARCHIVE_PATH).'<br />';
  68. echo 'INCLUDE_PATH :'.api_get_path(INCLUDE_PATH).'<br />';
  69. echo 'LIBRARY_PATH :'.api_get_path(LIBRARY_PATH).'<br />';
  70. echo 'CONFIGURATION_PATH :'.api_get_path(CONFIGURATION_PATH).'<br />';
  71. }
  72. function printVar($var, $varName = "@")
  73. {
  74. GLOBAL $DEBUG;
  75. if ($DEBUG)
  76. {
  77. echo "<blockquote>\n";
  78. echo "<b>[$varName]</b>";
  79. echo "<hr noshade size=\"1\" style=\"color:blue\">";
  80. echo "<pre style=\"color:red\">\n";
  81. var_dump($var);
  82. echo "</pre>\n";
  83. echo "<hr noshade size=\"1\" style=\"color:blue\">";
  84. echo "</blockquote>\n";
  85. }
  86. else
  87. {
  88. echo "<!-- DEBUG is OFF -->";
  89. echo "DEBUG is OFF";
  90. }
  91. }
  92. ?>