dokeos-library
[ class tree: dokeos-library ] [ index: dokeos-library ] [ all elements ]

Source for file debug.lib.inc.php

Documentation is available at debug.lib.inc.php

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

Documentation generated on Thu, 12 Jun 2008 13:18:36 -0500 by phpDocumentor 1.4.1