<?php
if(!defined('MOD'))  die("access die");
$action = $_GET['action'];
switch($action){
	case 'content':
		$channelid = intval($_GET['channelid']);
		$id = explode(",", trim($_GET['id']));
		$ids = array();
		foreach($id as $v){
			$temp = explode("-", $v);
			if(intval($temp[1]) < 1) continue;
			$ids[] = intval($temp[1]);
		}
		$ids = array_unique($ids);
		if(empty($channel[$channelid]) || empty($ids)) qbase::showmsg("error request");
		require_once(R_P. "/include/class.qmecms.php");
		$cms = new qmecms();
		$data = $cms->manage($ids);
		foreach($data as &$val){
			$val['channelname'] = $channel[$val['channelid']]['channelname'];
		}
		echo qbase::xmlPrint(qbase::jsonencode($data));
	break;

	case 'get':
		require_once(R_P . '/include/class.qmecms.php');
		$id = intval($_GET['id']);
		$cid = intval($_GET['cid']);
		$sid = $cid > 0 ? "{$cid}-{$id}" : "s-{$id}";
		$channelid = 1;
		$cms = new qmecms();
		$data = $cms ->get_related($sid);
		foreach($data as &$val){
			foreach($val['data'] as &$v){
				$v['channelname'] = $channel[$v['channelid']]['channelname'];
			}
		}
		echo qbase::xmlPrint(qbase::jsonencode($data));
	break;

	case 'category':
		echo qbase::xmlPrint(qbase::jsonencode($menus));
	break;
}
?>
