<?php
	require("__include-common.php");
	require("__include-common-rss.php");
	require("../account/__logincheck.php");
	require("magpierss/rss_fetch.inc");

	$table_name = "m_rss";
	$http_arg = array();
	$http_arg['cat'] = '';
	_GET_to_http_arg_pool($http_arg, $table_name);

	html_header(HTML_TITLE, "_add_header_index.php");
	page_header();
	contents_header();
	ob_implicit_flush();	//自動フラッシュをオン(出力をバッファリングしない)
	rss_body($http_arg, $table_name);
	page_footer();
	html_footer();
	exit();
?>
<?php
function rss_body($http_arg, $table_name) {
	$con = my_mysql_connect(_DB_SCHEMA);
?>
<div id="rss_navi_box">
<ul id="rss_navi">
<?php
	$sql_cat = "select * from m_category where c_delete = 0";
	$sql_cat .= " and id_account = '" . $_SESSION['current_id'] . "' order by c_categoryDisplayOrder asc";
	$rs_cat = my_mysql_query($sql_cat);
	$cat_tbl = array();
	$cnt = 0;
	$cat_id = 0;
	while ($rec_cat = mysql_fetch_array($rs_cat)) {
		if ($cnt == 0 || $rec_cat['id_category'] == intval($http_arg['cat'])) {
			$cat_id = $rec_cat['id_category'];	// カテゴリ選択必須。
		}
		$cat_tbl[] = array($rec_cat['id_category'], my_htmlspecialchars($rec_cat['c_categoryName']));
		$cnt++;
	}
	if ($cnt == 0) {
		echo '<br>サイトが未登録です。<br>最初に、カテゴリを登録してください。';
		return;
	}
	$http_arg['cat'] = $cat_id;
	arg_val_to_http_arg_pool($http_arg, $table_name);	// 追加/修正(一覧)で、同じカテゴリで開かせるため。
	foreach ($cat_tbl as $category) {
		$categoryName = my_htmlspecialchars($rec_cat['c_categoryName']);
?>
		<li<?= ($category[0] == $cat_id) ? ' id="rss_navi_current"' : ' class="rss_navi_tag"' ?> style="width: <?= mb_strwidth($category[1])+4 ?>ex;">
		<a href="<?= $_SERVER['SCRIPT_NAME'] ?>?cat=<?= $category[0] ?>"><?= $category[1] ?></a></li>
<?php
	}
?>
<script type="text/javascript">
window.onload=function(){
	if(!NiftyCheck()) return;
	//RoundedTop("div#rss_navi li", "transparent", "#404020");
	RoundedTop("li.rss_navi_tag", "transparent", "#a9b0e0");
	AddTop(document.getElementById("rss_navi_current"), "transparent", "#ff8c00");
}
</script>
</ul>
</div>
<div id="rss_body"><!--
<?php
	$sql = "select * from v_rss where c_delete = 0 and id_account = '" . $_SESSION['current_id'] . "'";
	$sql .= " and id_category = " . $cat_id;
	if ($_SESSION['current_id'] != $_SESSION['login_id']) {
		$sql .= " and c_privacy = 0";
	}
	$sql .= " order by c_displayOrder, c_title";
	$rs = my_mysql_query($sql);
	while ($rec = mysql_fetch_array($rs)) {
?>
		--><div class="rss_thumbnail">
<?php
		rss_view($rec, RSS_ARTICLE_TABLE_WIDTH, RSS_ARTICLE_VIEW_CNT, RSS_ARTICLE_TABLE_WIDTH_POPUP);
?>
		</div><!--
<?php
	}
?>
--></div>
<?php
}
?>
