<?php
require_once('./global.php');
$action = $_GET['action'] ? $_GET['action'] : 'show';

require_once(ROOT_PATH . '/includes/xajax/xajax.inc.php');
require_once(ROOT_PATH . '/admin/includes/function.xajax.php');
require_once(ROOT_PATH . '/includes/xajax/xajaxExtend.php');
//$xajax = new xajax();
$xajax = new xajaxExtend;
//$xajax->debugOn();
$xajax->registerFunction("ShowCreateLanguage");
$xajax->registerFunction("CreateLanguage");
$xajax->registerFunction("DeleteLanguage");
$xajax->registerFunction("ModifyLanguage");
$xajax->registerFunction("UpdateLanguage");
$xajax->processRequests();

$PrintXajax = $xajax->getJavascript($CONFIG['ROOT_PATH'] . '/includes/xajax');

//默认显示已经添加的语言
if($action == 'show'){
	$total = $db->number("SELECT `languageid` FROM `{$tablefix}language`");
	$pg = new page();
	$pg->sendstr(array(
		'action' => $action
		));
	$pg->set(12,$total,$_GET['page']);
	$result = $db->query("SELECT * FROM `{$tablefix}language` ORDER BY `ord` LIMIT ".$pg->limit());
	while($r = $db->fetch_array($result)) {
		if($r['filename'] != ''){
			$filename = "<img src=\"{$CONFIG['ROOT_PATH']}/attaches/{$r['filename']}\" width=\"21\">";
			}else{
			$filename = '';
			}
		$language[] = array(
			'languageid' => $r['languageid'],
			'name' => $r['name'],
			'charset' => $r['charset'],
			'filename' => $filename,
			'ord' => $r['ord']
			);
		}
	$smarty->assign('page',$pg->output);
	$smarty->assign('language',$language);
	$smarty->assign('PrintXajax',$PrintXajax);
	$smarty->display('language.htm');
	}
?>