<?php
if(!defined( 'MOD' ))die("access die");
$action = $_GET['action'] ? $_GET['action'] : 'manage';
switch($action){
	case 'manage':
		if($_POST['myFormAc'] == 'update'){
			$source = formatValue(trim($_POST['source']));
			$author = formatValue(trim($_POST['author']));
			$filter = formatValue(trim($_POST['filter']));
			qdb::query("replace into ".TABLEPRE."config (g, k, v) values ('author', 'author', '{$author}')");
			qdb::query("replace into ".TABLEPRE."config (g, k, v) values ('author', 'from', '{$source}')");
			qdb::query("replace into ".TABLEPRE."config (g, k, v) values ('author', 'filter', '{$filter}')");
			adminLog("ÎÄµµÉèÖÃ");
			qbase::get_object('event', 'option', array('type'=>'author'));
		}
		$data['author'] = qdb::queryAlone("select v from ".TABLEPRE."config where g = 'author' and k = 'author' ");
		$data['source'] = qdb::queryAlone("select v from ".TABLEPRE."config where g = 'author' and k = 'from' ");
		$data['filter'] = qdb::queryAlone("select v from ".TABLEPRE."config where g = 'author' and k = 'filter' ");
		include qbase::template($path . 'author');
	break;
	
	case 'get':
		$type = $_GET['type'];
		$temp = qdb::queryAlone("select v from ".TABLEPRE."config where g = 'author' and k = '{$type}' ");
		$data = explode("\n", $temp);
		$string = '';
		foreach($data as $val){
			$val = trim($val);
			if(empty($val)) continue;
			$string .= "<a href='javascript:void(0);' onclick=\"$('{$type}').value=this.innerHTML;qmeCms.dialogView.close();\">{$val}</a>";
		}
		echo qbase::xmlPrint("<span class=\"morelink\">" . $string . "</span>");
	break;
}

function formatValue($string){
	$data = array();
	$temp = explode("\n", $string);
	foreach($temp as $val){
		$val = trim($val);
		if(!$val) continue;
		$data[] = $val;
	}
	return implode("\n", $data);
}
?>
