1
0

misc.php 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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. /**
  34. * Old school autoloader.
  35. */
  36. /*
  37. function __autoload($name)
  38. {
  39. _debug("Autoloading $name\n");
  40. require_once("$name.php");
  41. }
  42. */
  43. function get_temp_dir()
  44. {
  45. return 'e:/src/OsinetOffice/tmp';
  46. }
  47. /**
  48. * @link http://blog.riff.org/2006_11_19_console_encoding_in_php_gtk_apps
  49. *
  50. * @param string $s
  51. * @return string
  52. */
  53. function output_encoder($s)
  54. {
  55. return iconv('UTF-8', 'IBM850', $s);
  56. }
  57. // Activate the OB handler:
  58. ob_start("output_encoder", 2);
  59. /**
  60. * automatically find the glade file for a class file
  61. *
  62. */
  63. function load_glade()
  64. {
  65. return new GladeXML(basename($_SERVER['PHP_SELF'], 'php') . 'glade');
  66. }
  67. /**
  68. * returns the name of the invoking function/method
  69. * if it's a method, it is prefixed by the class name
  70. *
  71. * @return string
  72. */
  73. function func_name($level = 1)
  74. {
  75. $trace = debug_backtrace();
  76. $func = $trace[$level]['function'];
  77. if (isset($trace[$level]['class']))
  78. $func = $trace[$level]['class'] . '::' . $func;
  79. return $func;
  80. }