<?php
if(!defined('R_P')) die("access die");
$id = intval($_GET['id']);
$_output = $cms->get_item($id);
$ppcid = $_output['cid'];
$strall = str_replace("value=\"{$ppcid}-", " selected value=\"{$ppcid}-", $menuTree);
if (isset($_POST['myFormAc']) && $_POST['myFormAc'] == 'update') {
	$filter = $_POST['filter'];
	$param = array();
	$param['subject'] = trim($_POST['subject']);
	$param['description'] = trim($_POST['description']);
	$param['subject_pre'] = trim($_POST['subject_pre']);
	$param['subject_color'] = trim($_POST['subject_color']);
	$param['is_comend'] = intval($_POST['is_comend']);
	$param['nocoment'] = intval($_POST['nocoment']);
	$param['stars'] = intval($_POST['stars']);
	$param['filename'] = trim($_POST['filename']);
	if(!$param['filename'] && intval($_POST['auto_filename'])){
		$param['filename'] = substr(formatFileName($cms->autoFilename($param['subject'])), 0, 64);
	}
	if(is_array($filter)){
		$temp = array();
		foreach($filter as $val){
			$val = intval($val);
			if(!$val) continue;
			$temp[] = $val;
		}
		$temp = array_unique($temp);
		$filter = empty($temp) ? 0 : implode(',', $temp);
	}
	else $filter = 0;
	$param['filter'] = $filter;
	foreach($param as $key=>$val){
		if($val == $_output[$key]){
			unset($param[$key]);
		}
	}
	if(!empty($param)){
		$param['edit_time'] = $_SERVER['REQUEST_TIME'];
		$cms->update_item($id, $param);
	}
	echo qbase::xmlPrint(qbase::jsonencode(array('status'=>200)));
}else{
	$_output['filter'] = explode(",", $_output['filter']);
	$keywords_array = getTag($channelid, $id);
	include qbase::template($path . 'element/filter');
}
?>