blog-types-pages plugin release

Hi all,
I've created simple plugins to add more pages to blogs-directory plugin pages based on blog-types plugin configuration...

eg .
http://example.com/blogs/student
http://example.com/blogs/general
...

heres the code:

<?php
/*
Plugin Name: blog types pages
Description: Create Blog Types page list
Author: Arnold Yonata
Version: 0.001
*/

/*  Copyright 2010 Arnold Yonata

    This program is free software; you can redistribute it and/or modify
    it under the terms of the GNU General Public License as published by
    the Free Software Foundation; either version 2 of the License, or
    (at your option) any later version.

    This program is distributed in the hope that it will be useful,
    but WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU General Public License for more details.

    You should have received a copy of the GNU General Public License
    along with this program; if not, write to the Free Software
    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA

*/

/**
 * this pluggin using blog-types and blogs-directory plugin from wpmudev
 */
$blog_types = array();
if (file_exists(ABSPATH . 'wp-content/blog-types-config.php')) {
	include_once(ABSPATH . 'wp-content/blog-types-config.php');
} else {
	die('Blog Types configuration file not found.');
}

if ($current_blog->domain . $current_blog->path == $current_site->domain . $current_site->path){
	add_filter('the_content', 'blog_type_pages_output', 25);
	add_filter('the_title', 'blogs_types_pages_title_output', 99, 3);
}

/**
 * this function was rip off from blogs_directory_output
 */
function blog_type_pages_output($content){
	global $wpdb, $current_site, $post, $blogs_directory_base;
	if ( $post->post_name == $blogs_directory_base ) {
		$blogs_directory_sort_by = get_site_option('blogs_directory_sort_by', 'alphabetically');
		$blogs_directory_per_page = get_site_option('blogs_directory_per_page', '10');
		$blogs_directory_background_color = get_site_option('blogs_directory_background_color', '#F2F2EA');
		$blogs_directory_alternate_background_color = get_site_option('blogs_directory_alternate_background_color', '#FFFFFF');
		$blogs_directory_border_color = get_site_option('blogs_directory_border_color', '#CFD0CB');
		$blogs_directory = blogs_types_pages_url_parse();

		if ( $content == __('Invalid page.') && $blogs_directory['page_type'] == 'blogtype' ) {
			$content ="";
			$search_form_content = blogs_directory_search_form_output('','');
			$navigation_content = blogs_types_pages_landing_navigation_output('', $blogs_directory_per_page, $blogs_directory['page'], $blogs_directory['phrase']);
			$content .= $search_form_content;
			$content .= '';
			$content .= $navigation_content;
			$content .= '<div style="float:left; width:100%">';
			$content .= '<table border="0" border="0" cellpadding="2px" cellspacing="2px" width="100%" bgcolor="">';
				$content .= '<tr>';
					$content .= '<td style="background-color:' . $blogs_directory_background_color . '; border-bottom-style:solid; border-bottom-color:' . $blogs_directory_border_color . '; border-bottom-width:1px; font-size:12px;" width="10%"> </td>';
					$content .= '<td style="background-color:' . $blogs_directory_background_color . '; border-bottom-style:solid; border-bottom-color:' . $blogs_directory_border_color . '; border-bottom-width:1px; font-size:12px;" width="90%"><center><strong>' .  __('Blogs') . '</strong></center></td>';
				$content .= '</tr>';
				//=================================//
				$avatar_default = get_option('avatar_default');
				$tic_toc = 'toc';
				//=================================//
				if ($blogs_directory['page'] == 1){
					$start = 0;
				} else {
					$math = $blogs_directory['page'] - 1;
					$math = $blogs_directory_per_page * $math;
					$start = $math;
				}

				$query = "SELECT wb.* FROM " . $wpdb->base_prefix . "blogs wb LEFT JOIN " .$wpdb->base_prefix. "blog_types wbt ON wb.blog_id = wbt.blog_id WHERE wb.spam != 1 AND wb.deleted != 1 AND wb.blog_id != 1 AND wbt.blog_types = ".$wpdb->prepare("%s", '|'.$blogs_directory['phrase'].'|');
				if ( $blogs_directory_sort_by == 'alphabetically' ) {
					if (VHOST == 'yes') {
						$query .= " ORDER BY wb.domain ASC";
					} else {
						$query .= " ORDER BY wb.path ASC";
					}
				} else if ( $blogs_directory_sort_by == 'latest' ) {
					$query .= " ORDER BY wb.blog_id DESC";
				} else {
					$query .= " ORDER BY wb.last_updated DESC";
				}
				$query .= " LIMIT " . intval( $start ) . ", " . intval( $blogs_directory_per_page );
				$blogs = $wpdb->get_results( $query, ARRAY_A );
				if ( count($blogs) > 0 ) {
					//=================================//
					foreach ($blogs as $blog){
						//=============================//
						$blog_title = get_blog_option( $blog['blog_id'], 'blogname', $blog['domain'] . $blog['path'] );
						if ($tic_toc == 'toc'){
							$tic_toc = 'tic';
						} else {
							$tic_toc = 'toc';
						}
						if ($tic_toc == 'tic'){
							$bg_color = $blogs_directory_alternate_background_color;
						} else {
							$bg_color = $blogs_directory_background_color;
						}
						//=============================//
						$content .= '<tr>';
							if ( function_exists('get_blog_avatar') ) {
								$content .= '<td style="background-color:' . $bg_color . '; padding-top:10px;" valign="top" width="10%"><center><a href="http://' . $blog['domain'] . $blog['path'] . '">' . get_blog_avatar($blog['blog_id'], 32, $avatar_default) . '</a></center></td>';
							} else {
								$content .= '<td style="background-color:' . $bg_color . '; padding-top:10px;" valign="top" width="10%"></td>';
							}
							$content .= '<td style="background-color:' . $bg_color . ';" width="90%">';
							$content .= '<a href="http://' . $blog['domain'] . $blog['path'] . '">' . $blog_title . '</a>';
							$content .= '</td>';
						$content .= '</tr>';
					}
					//=================================//
				}
			$content .= '</table>';
			$content .= '</div>';
			//$content .= $navigation_content;

		}
	}
	return $content;
}

function blogs_types_pages_url_parse(){
	global $wpdb, $current_site, $blogs_directory_base, $blog_types;
	$blogs_directory_url = $_SERVER['REQUEST_URI'];
	if ( $current_site->path != '/' ) {
		$blogs_directory_url = str_replace('/' . $current_site->path . '/', '', $blogs_directory_url);
		$blogs_directory_url = str_replace($current_site->path . '/', '', $blogs_directory_url);
		$blogs_directory_url = str_replace($current_site->path, '', $blogs_directory_url);
	}
	$blogs_directory_url = ltrim($blogs_directory_url, "/");
	$blogs_directory_url = rtrim($blogs_directory_url, "/");
	$blogs_directory_url = ltrim($blogs_directory_url, $blogs_directory_base);
	$blogs_directory_url = ltrim($blogs_directory_url, "/");

	list($blogs_directory_1, $blogs_directory_2, $blogs_directory_3, $blogs_directory_4) = explode("/", $blogs_directory_url);

	$page_type = '';
	$page_subtype = '';
	$page = '';
	$blog = '';

	foreach($blog_types as $blog_type){
		$blog_nicename[] = $blog_type['nicename'];
	}

	if ( in_array($blogs_directory_1, $blog_nicename)  ) {
		$page_type = 'blogtype';
		$phrase = $blogs_directory_1;
		$page = ((int)$blogs_directory_2== 0)?1:(int)$blogs_directory_2;
	}

	$blogs_directory['page_type'] = $page_type;
	$blogs_directory['page'] = $page;
	$blogs_directory['phrase'] = $phrase;

	return $blogs_directory;
}

function blogs_types_pages_landing_navigation_output($content, $per_page, $page, $phrase){
	global $wpdb, $current_site, $blogs_directory_base;

	$blog_count = $wpdb->get_var("SELECT count(*) FROM " . $wpdb->base_prefix . "blogs wb LEFT JOIN " .$wpdb->base_prefix. "blog_types wbt ON wb.blog_id = wbt.blog_id WHERE wb.spam != 1 AND wb.deleted != 1 AND wb.blog_id != 1 AND wbt.blog_types = ".$wpdb->prepare("%s", '|'.$phrase.'|'));
	//generate page div
	//============================================================================//
	$total_pages = blogs_directory_roundup($blog_count / $per_page, 0);
	$content .= '<table border="0" border="0" cellpadding="2px" cellspacing="2px" width="100%" bgcolor="">';
	$content .= '<tr>';
	$showing_low = ($page * $per_page) - ($per_page - 1);
	if ($total_pages == $page){
		//last page...
		//$showing_high = $blog_count - (($total_pages - 1) * $per_page);
		$showing_high = $blog_count;
	} else {
		$showing_high = $page * $per_page;
	}

    $content .= '<td style="font-size:12px; text-align:left;" width="50%">';
	if ($blog_count > $per_page){
	//============================================================================//
		if ($page == '' || $page == '1'){
			//$content .= __('Previous');
		} else {
		$previous_page = $page - 1;
		$content .= '<a>domain . $current_site->path . $blogs_directory_base . '/' . $phrase . '/' . $previous_page . '/">« ' . __('Previous') . '</a>';
		}
	//============================================================================//
	}
	$content .= '</td>';
    $content .= '<td style="font-size:12px; text-align:right;" width="50%">';
	if ($blog_count > $per_page){
	//============================================================================//
		if ($page == $total_pages){
			//$content .= __('Next');
		} else {
			if ($total_pages == 1){
				//$content .= __('Next');
			} else {
				$next_page = $page + 1;
			$content .= '<a>domain . $current_site->path . $blogs_directory_base . '/' . $phrase . '/' . $next_page . '/">' . __('Next') . ' »</a>';
			}
		}
	//============================================================================//
	}
    $content .= '</td>';
	$content .= '</tr>';
    $content .= '</table>';
	return $content;
}

function blogs_types_pages_title_output($title, $post_ID = '') {
	global $wpdb, $current_site, $post, $blogs_directory_base, $blog_types;
	foreach($blog_types as $blog_type){
		$blog_name[$blog_type['nicename']] = $blog_type['name'];
	}
	if ( $post->post_name == $blogs_directory_base && $post_ID == $post->ID) {
		$blogs_directory = blogs_types_pages_url_parse();
		if ( $blogs_directory['page_type'] == 'blogtype' ) {
			$path = $current_site->domain . $current_site->path . $blogs_directory_base;
			$title = '<a href="http://' .$path. '/">' . __('Blogs') . '</a>';
			$path .= '/'.urlencode($blogs_directory['phrase']);
			$title .=  ' » <a href="http://'.$path.'">' . $blog_name[$blogs_directory['phrase']] . '</a>';
			if($blogs_directory['page'] > 1 ) {
				$path .= '/'.urlencode($blogs_directory['page']);
				$title .=  ' » <a href="http://'.$path.'">' . $blogs_directory['page'] . '</a>';
			}
		}
	}
	return  $title;
}

?>