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/init_ste.php | 8 ++++++++ ratatoeskr/sys/utils.php | 42 ++++++++++++++++++++++++++++++++++++++++++ session_doctor.php | 19 +++++++++++++++++++ 3 files changed, 69 insertions(+) create mode 100644 session_doctor.php diff --git a/ratatoeskr/sys/init_ste.php b/ratatoeskr/sys/init_ste.php index 567a32b..f13eeb8 100644 --- a/ratatoeskr/sys/init_ste.php +++ b/ratatoeskr/sys/init_ste.php @@ -42,5 +42,13 @@ $ste->register_tag( return ucwords($sub($ste)); } ); +$ste->register_tag( + "loremipsum", + function($ste, $params, $sub) + { + $repeats = empty($params["repeat"]) ? 1 : $params["repeat"] + 0; + return implode("\n\n", array_repeat("

Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

\n\n

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat.

\n\n

Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat. Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis at vero eros et accumsan et iusto odio dignissim qui blandit praesent luptatum zzril delenit augue duis dolore te feugait nulla facilisi.

\n\n

Nam liber tempor cum soluta nobis eleifend option congue nihil imperdiet doming id quod mazim placerat facer possim assum. Lorem ipsum dolor sit amet, consectetuer adipiscing elit, sed diam nonummy nibh euismod tincidunt ut laoreet dolore magna aliquam erat volutpat. Ut wisi enim ad minim veniam, quis nostrud exerci tation ullamcorper suscipit lobortis nisl ut aliquip ex ea commodo consequat.

\n\n

Duis autem vel eum iriure dolor in hendrerit in vulputate velit esse molestie consequat, vel illum dolore eu feugiat nulla facilisis.

\n\n

At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, At accusam aliquyam diam diam dolore dolores duo eirmod eos erat, et nonumy sed tempor et et invidunt justo labore Stet clita ea et gubergren, kasd magna no rebum. sanctus sea sed takimata ut vero voluptua. est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat.

\n\n

Consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

", $repeats)); + } +); ?> 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. diff --git a/session_doctor.php b/session_doctor.php new file mode 100644 index 0000000..25ac7aa --- /dev/null +++ b/session_doctor.php @@ -0,0 +1,19 @@ + + + + session_doctor.php + + + +

session_doctor

+
+ + + + + -- cgit v1.2.3-70-g09d2