<?php
$template = <<<END
<!-- biz63_news:お知らせ -->
<section>
<div class="c2">
<!--{def item/title}-->
<div class="title">
<h2>{val item/title}</h2>
</div><!--/.title-->
<!--{/def}-->
<div class="text">
<dl class="new">
<!--{each item/newinfo}-->
<dt>{val item/newinfo/news_date}<!--{def item/newinfo/kind}--><span<!--{def item/newinfo/color}--> class="{val item/newinfo/color}"<!--{/def}-->>{val item/newinfo/kind}</span><!--{/def}--></dt>
<!--{def item/newinfo/url}-->
<dd><a href="{val item/newinfo/url}">{val item/newinfo/title}</a></dd>
<!--{/def}-->
<!--{ndef item/newinfo/url}-->
<dd>{val item/newinfo/title}</dd>
<!--{/ndef}-->
<!--{/each}-->
</dl>
</div><!--/.text-->
</div><!--/.c2-->
<!--{def item/more_title}-->
<div class="{val item/pos}"><p class="btn1"><a href="{val item/more_link}" class="{val item/inline}">{val item/more_title}</a></p>
<!--{/def}-->
</section>
END;

$biz63_news = array(
	"title" => "biz63お知らせ",
	"name" => "biz63_news",			// 名称、重複すると正しく動作しません
	"template" => $template,		// ブロックのテンプレートファイル
	"input" => array(
		"help" => array(
			"title" => "使い方",
			"type" => "comment",
			"link" => DOCUMENT1 . "/?act=biz63_news",
			"class" => "notice",
		),
		"notice1" => array(
			"title" => "このブロックは1ページに1つしか使えません",
			"type" => "comment",
			"class"=> "notice",
		),
		"title" => array(
			"title" => "タイトル",
			"type" => "text",
		),
		"info_num" => array(
			"title" => "表示数",
			"type" => "text",
		),
		"dummy11" => array(
			"title" => " ",
			"type" => "comment",
		),
		"pos" => array(
			"title" => "表示位置",
			"type" => "select",
			"list" => array(
				"l" => "左",
				"c" => "中央",
				"r" => "右",
			),
		),
		"more_title" => array(
			"title" => "もっと見るタイトル",
			"type" => "text",
		),
		"more_link" => array(
			"title" => "もっと見るリンク",
			"type" => "text",
		),
		"inline" => array(
			"title" => "表示方法",
			"type" => "select",
			"list" => array(
				"inline-block" => "インライン",
				"" => "全体幅",
			),
		),
	),
	"func" => "func_biz63_news",		// 処理プログラム（指定がない物は標準処理）
);

block_add($biz63_news);

// お知らせの取得
function func_biz63_news($def, $info)
{
	$login = get_setup();
	$kiji_list = array("" => "");
	$kiji_color = array("" => "");
	for ($i = 1; $i <= 10; $i++) {
		if (trim($login["news" . $i])) {
			$ary = explode("|", trim($login["news" . $i]));
			$kiji_list[$i] = $ary[0];
			$kiji_color[$i] = $ary[1];
		}
	}
	$num = intval($info["info_num"]);
	if ($num) {
		$info["newinfo"] = get_newinfo(($setup["info_max"] == "")?$num:$setup["info_max"]);
	}
	if (is_array($info["newinfo"])) {
		foreach ($info["newinfo"] as $key => $val) {
			$info["newinfo"][$key]["kind"] = $kiji_list[$val["kind"]];
			$info["newinfo"][$key]["color"] = "bgcolor-" . $kiji_color[$val["kind"]] . "-maru";
		}
	}
	return $info;
}
