<html>
<head>
<meta http-equiv="Content-Language" content="zh-cn">
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">


<?php

define( 'ROOT' , dirname(__FILE__) . '/../../../../' );
include_once( ROOT . 'lib/db.function.php' );
include_once( ROOT . 'lib/core.function.php' );
include_once( ROOT . 'lib/biz.function.php' );
include_once( ROOT . 'meta/ui.meta.php' );

//print_r( $_REQUEST );

$list = get_last_list();
$modules = get_active_modules();
$sees = get_see_list();

if( !empty( $_REQUEST['Lid'] ) )
	$type_now = $_REQUEST['Lid'];
else
	$type_now = intval($_REQUEST['type']);

foreach( $modules as $module )
{
	if( $module['id'] == intval( $_REQUEST['Mid'] ) )
		$mhtml[] = '<option value="' . $module['id'] . '" selected>' . $module['dy_module_name'] . '</option>'; 
	else
		$mhtml[] = '<option value="' . $module['id'] . '" >' . $module['dy_module_name'] . '</option>'; 
}


foreach( $list as $key=>$item )
{
	if( $item['id'] == $type_now )
		$ohtml[] = '<option value="' . $item['id'] . '" selected>' . $item['name'] . '</option>';
	else
		$ohtml[] = '<option value="' . $item['id'] . '">' . $item['name'] . '</option>';
}

foreach( $sees as $key=>$item )
{
	if( $key == intval( $_REQUEST['Sid'] ) )
		$shtml[] = '<option value="' . $key . '" selected>' . $item . '</option>';
	else
		$shtml[] = '<option value="' . $key . '">' . $item . '</option>';
}

//header( "Location : ../../../../?a=login" );
?>
<script>
var oEditor = window.parent.InnerDialogLoaded() ;
var FCKLang = oEditor.FCKLang ;
var FCKwulists = oEditor.FCKwulists ;

window.onload = function ()
{
	// First of all, translate the dialog box texts
	oEditor.FCKLanguageManager.TranslatePage( document ) ;
	
	LoadSelected() ;
	
	<?php if( $type_now > 0 )  : ?>
	// Show the "Ok" button.
	window.parent.SetOkButton( true ) ;	
	<?php endif; ?>
}

var eSelected = oEditor.FCKSelection.GetSelectedElement() ;
function LoadSelected()
{
	if ( !eSelected )
		return ;

	if ( eSelected.tagName == 'DIV' && eSelected._fckwulist )
	{
		//document.getElementById('list_type').value = eSelected._fckwulist  ;
		<?php if( $_REQUEST['a'] != 'set' ) :?>		
		location = '?a=set&' + eSelected._fckwulist;
		<?php endif; ?>
		
		


	}
	else
		eSelected == null ;
}

function Ok()
{
	var sVaule = 'Lid=' +  document.getElementById('list_type').value ;
	
	<?php if( $list[$type_now]['module_on'] ) : ?>
	sVaule = sVaule + '&Mid=' + document.getElementById('module_id').value;
	<?php endif; ?>

	<?php if( $list[$type_now]['template_on'] ) : ?>
	sVaule = sVaule + '&Tid=' + document.getElementById('tpl_id').value;
	<?php endif; ?>

	<?php if( $list[$type_now]['all_on'] ) : ?>
	sVaule = sVaule + '&All=' + document.getElementById('item_all').value;
	<?php endif; ?>

	<?php if( $list[$type_now]['row_on'] ) : ?>
	sVaule = sVaule + '&Row=' + document.getElementById('item_row').value;
	<?php endif; ?>

	<?php if( $list[$type_now]['see_on'] ) : ?>
	sVaule = sVaule + '&Sid=' + document.getElementById('see_id').value;
	<?php endif; ?>

	<?php if( $list[$type_now]['tag_on'] ) : ?>
	sVaule = sVaule + '&Tag=' + document.getElementById('riki_tag').value;
	<?php endif; ?>
			
   
	
	FCKwulists.Add( sVaule );
	return true;
}

function insert_it()
{
	alert( 'he' );
}
</script>
</head>
<body>
<?php
//print_r( $_REQUEST );
//exit;
//print_r( $type_now );
//print_r( $list[$type_now] );

?>
<form action="" method="POST">
<table cellspacing="5" cellpadding="5" >
<tr>
	<td>
		<font color=red>列表设置</font> 
	</td>
	<td>
	 <a href="fck_wuword.php">变量设置</a>
	</td>
</tr>
<tr>
	<td>
		显示内容
	</td>
	<td>
		<select name="list_type" onchange="location='?Lid=' + this.options[selectedIndex].value">
		<option value="0">请选择</option>
		<?php echo @join( '' , $ohtml ); ?></select>
	</td>
</tr>
<?php if( $type_now > 0 )  : ?>

<?php if( $list[$type_now]['see_on'] ) : ?>
<tr>
	<td>
		可见性
	</td>
	<td>
		<select name="see_id"><?php echo @join( '' , $shtml ); ?></select>
	</td>
</tr>
<?php endif; ?>

<?php if( $list[$type_now]['module_on'] ) : ?>
<tr>
	<td>
		所属模块
	</td>
	<td>
		<select name="module_id"><?php echo @join( '' , $mhtml ); ?></select>
	</td>
</tr>
<?php endif; ?>
<?php 
	$tpls = get_meta_template_list( $_REQUEST['Lid'] );
	foreach( $tpls as $key=>$tpl )
	{
		if( $_REQUEST['Tid'] ==  $name = reset( explode( '.' , basename($tpl) ) ) )
			$thtml[] = '<option value="' . $name . '" selected>' . basename($tpl) . '</option>';
		else
			$thtml[] = '<option value="' . $name . '">' . basename($tpl) . '</option>';

		
	}
?>

<?php if( $list[$type_now]['template_on'] == true ) : ?>
<tr>
	<td>
		使用模版
	</td>
	<td>
		<select name="tpl_id"><?php echo @join( '' , $thtml ); ?></select></select>
	</td>
</tr>
<?php endif; ?>
<?php if( $list[$type_now]['all_on'] == true ) : ?>
<tr>
	<td>
		显示条数
	</td>
	<td>
		<input name="item_all" type="text" value="<?php echo $_REQUEST['All'] ?>">
	</td>
</tr>
<?php endif; ?>
<?php if( $list[$type_now]['row_on'] == true ) : ?>
<tr>
	<td>
		每行个数
	</td>
	<td>
		<input name="item_row" type="text" value="<?php echo $_REQUEST['Row'] ?>">
	</td>
</tr>
<?php endif; ?>

<?php if( $list[$type_now]['tag_on'] == true ) : ?>
<tr>
	<td>
		Tag
	</td>
	<td>
		<input name="riki_tag" type="text" value="<?php echo $_REQUEST['Tag'] ?>">
	</td>
</tr>
<?php endif; ?>
<?php endif; ?>
</table>
</form>
</body>
</html>