<?php
function archives_block($options)
{
	$mydirname = empty( $options[0] ) ? 'xpress' : $options[0] ;
	$this_template = empty( $options[1] ) ? 'db:'.$mydirname.'_archives_block.html' : trim( $options[1] );
	$type = empty( $options[2] ) ? false : true ;
	$limit = empty( $options[3] ) ? '10' : $options[3] ;
	$show_post_count = empty( $options[4] ) ? false : true ;		
	$drop_down = empty( $options[5] ) ? false : true ;	
	
	if ($type) {
		$type_name = 'monthly';
	} else {
		$type_name = 'weekly';
	}			

	$drop_down_list = '<form id="archiveform" action="">';
	$drop_down_list .= '<select name="archive_chrono" onchange="window.location = (document.forms.archiveform.archive_chrono[document.forms.archiveform.archive_chrono.selectedIndex].value);">';
	$drop_down_list .= "<option value=''>";
	if ($type) {
		$drop_down_list .= __('Select Monthly', 'xpress');
	} else {
		$drop_down_list .= __('Select Weekly', 'xpress');
	}
	$drop_down_list .=  '</option>';
	ob_start();
		get_archives($type_name,$limit,'option','','',$show_post_count);
		$drop_down_list .= ob_get_contents();
	ob_end_clean();
	$drop_down_list .= '</select>';
	$drop_down_list .= '</form>';				

	ob_start();
		get_archives($type_name,$limit,'custom','','|',$show_post_count);
		$output = ob_get_contents();
	ob_end_clean();
	$output = preg_replace('/\|$/', '' ,$output); // "|" at the end of line is deleted. 
	$archives = explode('|',$output);
	$item_no = 0;
	foreach ($archives as $archive){
		$row_data = array(
			'archive'		=> $archive
		);
		$block['contents']['item'.$item_no] = $row_data;
		$item_no++;
	}
	$block['data_count'] = $item_no;
	$block['config']['is_archive_doropdown'] = $drop_down;
	$block['archive_dropdown'] = $drop_down_list;
	return $block ;	
}

?>