<?php
// $Id: block_refresh.php,v 1.7 2006/09/29 12:48:54 ohwada Exp $

// 2006-09-20 K.OHWADA
// small change

// 2006-07-10 K.OHWADA
// use happy_linux module
// support podcast

// 2006-06-04 K.OHWADA
// merge api/block.php

//=========================================================
// RSS Center Module
// 2006-01-01 K.OHWADA
//=========================================================

// --- block function begin ---
if( !function_exists( 'b_rssc_show_refresh' ) ) 
{

$RSSC_DIRNAME = basename( dirname( dirname( __FILE__ ) ) );

// system files
include_once XOOPS_ROOT_PATH.'/class/snoopy.php';

// happy_linux files
include_once XOOPS_ROOT_PATH.'/modules/happy_linux/include/functions.php';
include_once XOOPS_ROOT_PATH.'/modules/happy_linux/include/multibyte.php';
include_once XOOPS_ROOT_PATH.'/modules/happy_linux/class/system.php';
include_once XOOPS_ROOT_PATH.'/modules/happy_linux/class/error.php';
include_once XOOPS_ROOT_PATH.'/modules/happy_linux/class/strings.php';
include_once XOOPS_ROOT_PATH.'/modules/happy_linux/class/highlight.php';
include_once XOOPS_ROOT_PATH.'/modules/happy_linux/class/post.php';
include_once XOOPS_ROOT_PATH.'/modules/happy_linux/class/remote_file.php';
include_once XOOPS_ROOT_PATH.'/modules/happy_linux/class/convert_encoding.php';
include_once XOOPS_ROOT_PATH.'/modules/happy_linux/class/basic_handler.php';
include_once XOOPS_ROOT_PATH.'/modules/happy_linux/class/object.php';
include_once XOOPS_ROOT_PATH.'/modules/happy_linux/class/object_handler.php';

// rssc files
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/include/rssc_constant.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/include/rssc_get_handler.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/class/rssc_config_basic_handler.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/class/rssc_link_basic_handler.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/class/rssc_feed_basic_handler.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/class/rssc_black_basic_handler.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/class/rssc_white_basic_handler.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/class/rssc_xml_utility.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/class/rssc_xml_object.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/class/rssc_parse_handler.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/class/rssc_refresh_handler.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/class/rssc_view_param.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/class/rssc_view_handler.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/class/magpie/rssc_magpie_parse.php';
include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/class/magpie/rssc_magpie_cache.php';

//global $xoopsConfig;
//$XOOPS_LANGUAGE = $xoopsConfig['language'];
//if ( file_exists(XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/language/'.$XOOPS_LANGUAGE.'/main.php') ) 
//{
//	include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/language/'.$XOOPS_LANGUAGE.'/main.php';
//}
//else
//{
//	include_once XOOPS_ROOT_PATH.'/modules/'.$RSSC_DIRNAME.'/language/english/main.php';
//}

//---------------------------------------------------------
// show headline after refresh
// $options
// [0] module directory name (rssc)
//---------------------------------------------------------
function b_rssc_show_refresh( $options )
{
	$DIRNAME = empty( $options[0] ) ? basename( dirname( dirname( __FILE__ ) ) ) : $options[0] ;

	$headline_handler =& rssc_get_handler('headline',      $DIRNAME);
	$view_handler     =& rssc_get_handler('view',         $DIRNAME);
	$conf_handler     =& rssc_get_handler('config_basic', $DIRNAME);

	$conf_data =& $conf_handler->get_conf();

	$link_limit  = $conf_data['block_headline_links_perpage'];
	$limit       = $conf_data['block_headline_feeds_perlink'];
	$max_title   = $conf_data['block_headline_max_title'];
	$max_summary = $conf_data['block_headline_max_summary'];
	$max_content = $conf_data['block_headline_max_content'];
	$num_content = $conf_data['block_headline_num_content'];
	$order       = $conf_data['block_headline_order'];
	$link_start  = 0;

	$headline_handler->refresh_headline($link_limit, $link_start);

	$view_handler->setFlagSanitize( true );	// sanitize
	$view_handler->setFeedStart(     0 );
	$view_handler->set_title_html(   false );
	$view_handler->set_content_html( true );
	$view_handler->set_max_title(   $max_title );
	$view_handler->set_max_summary( $max_summary );
	$view_handler->set_max_content( $max_content );
	$view_handler->setFeedLimit(    $limit );
	$view_handler->setFeedOrder(    $order );

	$block = array();
	$block['lang_more'] = _BL_RSSC_MORE;
	$block['dirname']   = $DIRNAME;
	$block['links']     =& $view_handler->getHeadlineLinksFeeds($link_limit, $link_start);

// podcast
	$block['lang_podcast'] = _BL_RSSC_PODCAST;
	$block['unit_kb']      =  BL_RSSC_UNIT_KB;
	$block['num_content']  = $num_content;

	return $block;
}

// --- block function begin ---
}

?>