Pastoid

The page you are looking at now is at this URL: http://pastoid.com/byx

This paste was last updated on January 6, 2010 at 9:35 am.

Pasted Coderaw

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 "<a href=\\"" . URL::get("display_entries_by_category", array( "category_slug" => $b) ) . "\\" rel=\\"category\\">" . $a . "</a>";
        }
 
}

Toggle wordwrap

Referring DomainHits
Unknown Referer 127
pastoid.com 8
Is this paste spam?
<Hide