From 25951d82d63608479f0a07ede062a2f8f1ce6bac Mon Sep 17 00:00:00 2001 From: Damien Regad Date: Mon, 30 Jun 2014 01:18:57 +0200 Subject: [PATCH] Restore helper_alternate_class() function This is a temporary measure to improve backwards compatibility of 1.3, the function will be removed again in the next release. Fixes #17522 (see also issue #17437) --- core/helper_api.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/core/helper_api.php b/core/helper_api.php index 493a59be27..97f315d881 100644 --- a/core/helper_api.php +++ b/core/helper_api.php @@ -76,6 +76,28 @@ function helper_alternate_colors( $p_index, $p_odd_color, $p_even_color ) { } } +/** + * alternate classes for table rows + * If no index is given, continue alternating based on the last index given + * @param int $p_index + * @param string $p_odd_class default: row-1 + * @param string $p_even_class default: row-2 + * @return string + */ +function helper_alternate_class( $p_index = null, $p_odd_class = 'row-1', $p_even_class = 'row-2' ) { + static $t_index = 1; + + if( null !== $p_index ) { + $t_index = $p_index; + } + + if( 1 == $t_index++ % 2 ) { + return "class=\"$p_odd_class\""; + } else { + return "class=\"$p_even_class\""; + } +} + /** * Transpose a bidimensional array *