- removed obsolete autoloader and get_temp_dir() functions - indenting/bracing style mostly PSR1-style.
78 lines
1.6 KiB
PHP
78 lines
1.6 KiB
PHP
<?php
|
|
/**
|
|
* The OSInet Zoo.
|
|
*
|
|
* Miscellaneous functions of dubious value, mostly used in PHP-GTK code < 2008.
|
|
*
|
|
* WARNING: including this files turns on output buffering. Useful in PHP-GTK
|
|
* apps, possibly troublesome elsewhere.
|
|
*
|
|
* @copyright (c) 2007 OSI
|
|
* @author Frédéric G. MARAND
|
|
* @license Licensed under the CeCILL 2.0
|
|
* @link http://drupal.org/project/offload
|
|
*/
|
|
|
|
/**
|
|
* Interface used by function providing non-standard comparisons.
|
|
*/
|
|
interface Comparable_Interface {
|
|
/**
|
|
* Compare the current instance
|
|
*
|
|
* @param Comparable_Interface $other
|
|
*
|
|
* @return int
|
|
*/
|
|
public function cmp(Comparable_Interface $other);
|
|
}
|
|
|
|
/**
|
|
* Echo message depending on global $_debug_active value.
|
|
*
|
|
* @param mixed $msg
|
|
*/
|
|
function _debug($msg) {
|
|
global $_debug_active ;
|
|
|
|
if ($_debug_active)
|
|
echo $msg;
|
|
}
|
|
|
|
/**
|
|
* Convert encoding to IBM850 for PHP-GTK apps on Windows.
|
|
*
|
|
* @link http://blog.riff.org/2006_11_19_console_encoding_in_php_gtk_apps
|
|
*
|
|
* @param string $s
|
|
*
|
|
* @return string
|
|
*/
|
|
function output_encoder($s) {
|
|
return iconv('UTF-8', 'IBM850', $s);
|
|
}
|
|
|
|
/**
|
|
* Automatically find the glade file for a PHP-GTK class file.
|
|
*/
|
|
function load_glade() {
|
|
return new GladeXML(basename(__FILE__, 'php') . 'glade');
|
|
}
|
|
|
|
/**
|
|
* Returns the name of the invoking function/method. If it's a method, it is
|
|
* prefixed by the class name.
|
|
*
|
|
* @return string
|
|
*/
|
|
function func_name($level = 1) {
|
|
$trace = debug_backtrace();
|
|
$func = $trace[$level]['function'];
|
|
if (isset($trace[$level]['class'])) {
|
|
$func = $trace[$level]['class'] . '::' . $func;
|
|
}
|
|
return $func;
|
|
}
|
|
|
|
// Activate the OB handler:
|
|
ob_start("output_encoder", 2);
|