<?php
// $Id: admin_form_black_white.php,v 1.5 2006/09/15 14:18:58 ohwada Exp $

// 2006-09-10 K.OHWADA
// use XoopsGTicket

// 2006-07-18 K.OHWADA
// BUG 4145: 'blong link' jump always 'rssc' directory

// 2006-07-10 K.OHWADA
// this is new file
// move from admin_form_class
// use happy_linux_form
// change class name admin_form to admin_form_base
// change make_xxx to build_xxx

//=========================================================
// RSS Center Module
// 2006-07-10 K.OHWADA
//=========================================================
class admin_form_black_white extends happy_linux_form
{
// class instance
	var $_feed_handler;

// black & white
	var $_id_name;
	var $_form_title_add;
	var $_form_title_mod;

//---------------------------------------------------------
// constructor
//---------------------------------------------------------
function admin_form_black_white()
{
	$this->happy_linux_form();

// class instance
	$this->_feed_handler =& rssc_get_handler('feed', RSSC_DIRNAME);
}

function &getInstance()
{
	static $instance;
	if (!isset($instance)) 
	{
		$instance = new admin_form_black_whitee();
	}

	return $instance;
}

//---------------------------------------------------------
// show black & white
//---------------------------------------------------------
function _show_black_white(&$obj, $extra=null, $mode=0)
{
	switch ($mode) 
	{
		case HAPPY_LINUX_MODE_MOD:
		case HAPPY_LINUX_MODE_MOD_PREVIEW:
			$mode       = HAPPY_LINUX_MODE_MOD;
			$form_title = $this->_form_title_mod;
			$op         = 'mod_table';
			$button_val = _MODIFY;
			break;

		case HAPPY_LINUX_MODE_ADD:
		case HAPPY_LINUX_MODE_ADD_PREVIEW:
		default:
			$form_title = $this->_form_title_add;
			$op         = 'add_bulk';
			$button_val = _ADD;
			break;
	}

	$this->set_obj($obj);

	if ( ($this->_id_name == 'bid') && ($mode == 1) )
	{
		$url = $obj->get('url');
		$total_feed = $this->_feed_handler->get_count_by_link( $url );

// bug: 'blong link' jump always 'rssc' directory
		$url_feed   = 'feed_list.php?link='.$url;

		printf(_AM_RSSC_THERE_ARE_MATCH, $total_feed);
		echo "<br /><br />\n";
		echo $this->build_html_a_href_name($url_feed, _AM_RSSC_FEED_MATCH_LINK);
		echo "<br /><br />\n";
	}

// form start
	echo $this->build_form_begin();
	echo $this->build_token();
	echo $this->build_html_input_hidden('op', $op);

	if ( $mode == HAPPY_LINUX_MODE_MOD )
	{
		echo $this->build_html_input_hidden($this->_id_name, $obj->get($this->_id_name) );
	}

	echo $this->build_form_table_begin();
	echo $this->build_form_table_title($form_title);

	if ( $mode == HAPPY_LINUX_MODE_MOD )
	{
		echo $this->build_form_table_line('id', $obj->get($this->_id_name) );
	}

	echo $this->build_obj_table_text(_RSSC_LINK_ID, 'lid');
	echo $this->build_obj_table_text(_RSSC_USER_ID, 'uid');
	echo $this->build_obj_table_text(_RSSC_MOD_ID,  'mid');
	echo $this->build_obj_table_text('p1', 'p1');
	echo $this->build_obj_table_text('p2', 'p2');
	echo $this->build_obj_table_text('p3', 'p3');

	echo $this->build_obj_table_text(_RSSC_SITE_TITLE, 'title');

	if ( $mode == HAPPY_LINUX_MODE_MOD )
	{
		$ele_url = $this->build_edit_url_with_visit('url', $obj->get('url') );
		echo $this->build_form_table_line(_RSSC_SITE_LINK, $ele_url);
	}
	else
	{
		$ele_url = $this->build_edit_textarea_urllist('urllist', $obj->get('url') );
		echo $this->build_form_table_line(_RSSC_SITE_LINK, $ele_url);
	}

	echo $this->build_obj_table_textarea(_AM_RSSC_BLACK_MEMO, 'memo');

	$ele_submit = $this->build_html_input_submit('submit', $button_val);
	echo $this->build_form_table_line('', $ele_submit, 'foot', 'foot');

	if ( $mode == HAPPY_LINUX_MODE_MOD )
	{
		$ele_del    = $this->build_html_input_submit('del_table', _DELETE);
		$ele_cancel = $this->build_html_input_button_cancel('cancel', _CANCEL);
		echo $this->build_form_table_line('', $ele_del.'  '.$ele_cancel, 'foot', 'foot');
	}

	echo $this->build_form_table_end();
	echo $this->build_form_end();
// --- form end ---

}

// --- class end ---
}

?>