misc.php 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. <?php
  2. /**
  3. * The Zoo
  4. *
  5. * @copyright (c) 2007 OSI
  6. * @author Frédéric G. MARAND
  7. * @license Licensed under the CeCILL 2.0
  8. * @version CVS: $Id: misc.php,v 1.4 2007-06-10 19:39:54 marand Exp $
  9. * @link http://drupal.org/project/offload
  10. * @since Not applicable yet
  11. * @package default
  12. */
  13. /**
  14. * Interface used by function providing non-standard comparisons
  15. * @package default
  16. */
  17. interface Comparable_Interface
  18. {
  19. /**
  20. * Compare the current instance
  21. *
  22. * @param Comparable_Interface $other
  23. * @return int
  24. */
  25. public function cmp(Comparable_Interface $other);
  26. }
  27. function _debug($msg)
  28. {
  29. global $_debug_active ;
  30. if ($_debug_active)
  31. echo $msg;
  32. }
  33. function __autoload($name)
  34. {
  35. _debug("Autoloading $name\n");
  36. require_once("$name.php");
  37. }
  38. function get_temp_dir()
  39. {
  40. return 'e:/src/OsinetOffice/tmp';
  41. }
  42. /**
  43. * @link http://blog.riff.org/2006_11_19_console_encoding_in_php_gtk_apps
  44. *
  45. * @param string $s
  46. * @return string
  47. */
  48. function output_encoder($s)
  49. {
  50. return iconv('UTF-8', 'IBM850', $s);
  51. }
  52. // Activate the OB handler:
  53. ob_start("output_encoder", 2);
  54. /**
  55. * automatically find the glade file for a class file
  56. *
  57. */
  58. function load_glade()
  59. {
  60. return new GladeXML(basename($_SERVER['PHP_SELF'], 'php') . 'glade');
  61. }
  62. /**
  63. * returns the name of the invoking function/method
  64. * if it's a method, it is prefixed by the class name
  65. *
  66. * @return string
  67. */
  68. function func_name()
  69. {
  70. $trace = debug_backtrace();
  71. $func = $trace[1]['function'];
  72. if (isset($trace[1]['class']))
  73. $func = $trace[1]['class'] . '::' . $func;
  74. return $func;
  75. }