class SimpleCategoriesFormat extends Format { /** * function category_and_list * Formatting function (should be in Format class?) * Turns an array of category names into an HTML-linked list with commas and an "and". * @param array $array An array of category names * @param string $between Text to put between each element * @param string $between_last Text to put between the next to last element and the last element * @return string HTML links with specified separators. **/ public static function category_and_list( $array, $between = ', ', $between_last = NULL ) { if ( ! is_array( $array ) ) { $array = array ( $array ); } if ( $between_last === NULL ) { $between_last = _t(' and '); } $array = array_map('SimpleCategoriesFormat::link_cat', $array, array_keys($array)); $last = array_pop($array); $out = implode($between, $array); $out .= ($out == '') ? $last : $between_last . $last; return $out; } public static function link_cat( $a, $b ) { return " $b) ) . "\\" rel=\\"category\\">" . $a . ""; } }