debug.lib.inc.php 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  1. <?php
  2. /*
  3. ==============================================================================
  4. Dokeos - elearning and course management software
  5. Copyright (c) 2004 Dokeos S.A.
  6. Copyright (c) 2003 Ghent University (UGent)
  7. Copyright (c) 2001 Universite catholique de Louvain (UCL)
  8. For a full list of contributors, see "credits.txt".
  9. The full license can be read in "license.txt".
  10. This program is free software; you can redistribute it and/or
  11. modify it under the terms of the GNU General Public License
  12. as published by the Free Software Foundation; either version 2
  13. of the License, or (at your option) any later version.
  14. See the GNU General Public License for more details.
  15. Contact: Dokeos, 181 rue Royale, B-1000 Brussels, Belgium, info@dokeos.com
  16. ==============================================================================
  17. */
  18. /**
  19. ==============================================================================
  20. * This is the debug library for Dokeos.
  21. * Include/require it in your code to use its functionality.
  22. *
  23. * debug functions
  24. *
  25. * @package dokeos.library
  26. ==============================================================================
  27. */
  28. /**
  29. * This function displays the contend of a variable, array or object in a nicely formatted way.
  30. * @param $variable a variable, array or object
  31. * @return html code;
  32. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  33. * @version November 2006
  34. */
  35. function debug($variable)
  36. {
  37. echo '<pre>';
  38. print_r($variable);
  39. echo '</pre>';
  40. }
  41. /**
  42. * This function displays all the information of the dokeos $_course array
  43. * This array stores all the information of the current course if the user is in a course.
  44. * This is why this array is used to check weither the user is currently is in the course.
  45. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  46. * @version November 2006
  47. */
  48. function debug_course()
  49. {
  50. global $_course;
  51. debug($_course);
  52. }
  53. /**
  54. * This function displays all the information of the dokeos $_user array
  55. * This array stores all the information of the current user.
  56. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  57. * @version November 2006
  58. */
  59. function debug_user()
  60. {
  61. global $_user;
  62. debug($_user);
  63. }
  64. /**
  65. * This function displays an overview of the different path constants that can be used with the api_get_path function
  66. * @author Patrick Cool <patrick.cool@UGent.be>, Ghent University
  67. * @version November 2006
  68. */
  69. function debug_paths()
  70. {
  71. echo 'WEB_PATH :'.api_get_path(WEB_PATH).'<br />';
  72. echo 'SYS_PATH :'.api_get_path(SYS_PATH).'<br />';
  73. echo 'REL_PATH :'.api_get_path(REL_PATH).'<br />';
  74. echo 'WEB_COURSE_PATH :'.api_get_path(WEB_COURSE_PATH).'<br />';
  75. echo 'SYS_COURSE_PATH :'.api_get_path(SYS_COURSE_PATH).'<br />';
  76. echo 'REL_COURSE_PATH :'.api_get_path(REL_COURSE_PATH).'<br />';
  77. echo 'REL_CLARO_PATH :'.api_get_path(REL_CODE_PATH).'<br />';
  78. echo 'WEB_CODE_PATH :'.api_get_path(WEB_CODE_PATH).'<br />';
  79. echo 'SYS_CODE_PATH :'.api_get_path(SYS_CODE_PATH).'<br />';
  80. echo 'SYS_LANG_PATH :'.api_get_path(SYS_LANG_PATH).'<br />';
  81. echo 'WEB_IMG_PATH :'.api_get_path(WEB_IMG_PATH).'<br />';
  82. echo 'GARBAGE_PATH :'.api_get_path(GARBAGE_PATH).'<br />';
  83. echo 'PLUGIN_PATH :'.api_get_path(PLUGIN_PATH).'<br />';
  84. echo 'SYS_ARCHIVE_PATH :'.api_get_path(SYS_ARCHIVE_PATH).'<br />';
  85. echo 'INCLUDE_PATH :'.api_get_path(INCLUDE_PATH).'<br />';
  86. echo 'LIBRARY_PATH :'.api_get_path(LIBRARY_PATH).'<br />';
  87. echo 'CONFIGURATION_PATH :'.api_get_path(CONFIGURATION_PATH).'<br />';
  88. }
  89. function printVar($var, $varName = "@")
  90. {
  91. GLOBAL $DEBUG;
  92. if ($DEBUG)
  93. {
  94. echo "<blockquote>\n";
  95. echo "<b>[$varName]</b>";
  96. echo "<hr noshade size=\"1\" style=\"color:blue\">";
  97. echo "<pre style=\"color:red\">\n";
  98. var_dump($var);
  99. echo "</pre>\n";
  100. echo "<hr noshade size=\"1\" style=\"color:blue\">";
  101. echo "</blockquote>\n";
  102. }
  103. else
  104. {
  105. echo "<!-- DEBUG is OFF -->";
  106. echo "DEBUG is OFF";
  107. }
  108. }
  109. ?>