misc.php 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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.3 2007-06-10 16:30:30 marand Exp $
  9. * @link http://drupal.org/project/offload
  10. * @since Not applicable yet
  11. * @package default
  12. */
  13. interface Comparable_Interface
  14. {
  15. /**
  16. * Compare the current instance
  17. *
  18. * @param Comparable_Interface $other
  19. * @return int
  20. */
  21. public function cmp(Comparable_Interface $other);
  22. }
  23. function _debug($msg)
  24. {
  25. global $_debug_active ;
  26. if ($_debug_active)
  27. echo $msg;
  28. }
  29. function __autoload($name)
  30. {
  31. _debug("Autoloading $name\n");
  32. require_once("$name.php");
  33. }
  34. function get_temp_dir()
  35. {
  36. return 'e:/src/OsinetOffice/tmp';
  37. }
  38. /**
  39. * @link http://blog.riff.org/2006_11_19_console_encoding_in_php_gtk_apps
  40. *
  41. * @param string $s
  42. * @return string
  43. */
  44. function output_encoder($s)
  45. {
  46. return iconv('UTF-8', 'IBM850', $s);
  47. }
  48. // Activate the OB handler:
  49. ob_start("output_encoder", 2);
  50. /**
  51. * automatically find the glade file for a class file
  52. *
  53. */
  54. function load_glade()
  55. {
  56. return new GladeXML(basename($_SERVER['PHP_SELF'], 'php') . 'glade');
  57. }
  58. /**
  59. * returns the name of the invoking function/method
  60. * if it's a method, it is prefixed by the class name
  61. *
  62. * @return string
  63. */
  64. function func_name()
  65. {
  66. $trace = debug_backtrace();
  67. $func = $trace[1]['function'];
  68. if (isset($trace[1]['class']))
  69. $func = $trace[1]['class'] . '::' . $func;
  70. return $func;
  71. }