From afe436b25dd935aa2ae3a327027ea04b3c82e5ac Mon Sep 17 00:00:00 2001 From: Kevin Chabowski Date: Wed, 5 Oct 2011 14:30:43 +0200 Subject: More functions for utils.php and some testing tools. * Added ste:loremipsum for Layout tests. * Added session_doctor.php to inspect the current user session. --- ratatoeskr/sys/utils.php | 42 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) (limited to 'ratatoeskr/sys/utils.php') diff --git a/ratatoeskr/sys/utils.php b/ratatoeskr/sys/utils.php index bdb472c..5e5d8c3 100644 --- a/ratatoeskr/sys/utils.php +++ b/ratatoeskr/sys/utils.php @@ -100,6 +100,33 @@ function array_filter_keys($input, $callback) return $input; } +/* + * Function: array_kvpairs_to_assoc + * Convert array of key-value pairs to an associative array. + * + * Parameters: + * $input - Array of key-value pairs + * + * Returns: + * An associative array. + */ +function array_kvpairs_to_assoc($input) +{ + $rv = array(); + foreach($input as $kvpair) + $rv[$kvpair[0]] = $kvpair[1]; + return $rv; +} + +/* + * Function: intcmp + * Compare integers (equavilent to strcmp) + */ +function intcmp($a, $b) +{ + return ($a == $b) ? 0 : (($a < $b) ? -1 : 1); +} + /* * Function: ucount * @@ -157,6 +184,21 @@ function strleft($s1, $s2) { return substr($s1, 0, strpos($s1, $s2)); } +/* + * Function: htmlesc + * Escape HTML (shorter than htmlentities($text, ENT_QUOTES, "UTF-8")) + * + * Parameters: + * $text - Input text. + * + * Returns: + * HTML + */ +function htmlesc($text) +{ + return htmlentities($text, ENT_QUOTES, "UTF-8"); +} + /* * Constant: SITE_BASE_PATH * The Base path of this ratatoeskr site. -- cgit v1.2.3-54-g00ecf