<?php
$template = <<<END
<!--{def item/items}-->
<!--block_table:表・テーブル-->
<section class="block_table">
<!--{def item/title}-->
<h2>{val item/title}</h2>
<!--{/def}-->

<table class="ta1">
<!--{def item/caption}-->
<caption>{val item/caption}</caption>
<!--{/def}-->
<!--{each item/items}-->
<tr>
<th>{val item/items/item}</th>
<!--{each item/items/contents}-->
<td>{rval item/items/contents}</td>
<!--{/each}-->
</tr>
<!--{/each}-->
</table>

</section>
<!--{/def}-->
END;

$block_table2 = array(
	"title" => "表2（テーブル）",
	"name" => "block_table2",			// 名称、重複すると正しく動作しません
	"template" => $template,		// ブロックのテンプレートファイル
	"input" => array(
		"help" => array(
			"title" => "使い方",
			"type" => "comment",
			"link" => DOCUMENT1 . "/?act=block_table2",
			"class" => "notice",
		),
		"title" => array(
			"title" => "タイトル",
			"type" => "text",
		),
		"caption" => array(
			"title" => "表見出し",
			"type" => "text",
		),
		"item1" => array(
			"title" => "項目１",
			"type" => "text",
		),
		"contents1" => array(
			"title" => "内容１",
			"type" => "textarea",
		),
		"item2" => array(
			"title" => "項目２",
			"type" => "text",
		),
		"contents2" => array(
			"title" => "内容２",
			"type" => "textarea",
		),
		"item3" => array(
			"title" => "項目３",
			"type" => "text",
		),
		"contents3" => array(
			"title" => "内容３",
			"type" => "textarea",
		),
		"item4" => array(
			"title" => "項目４",
			"type" => "text",
		),
		"contents4" => array(
			"title" => "内容４",
			"type" => "textarea",
		),
		"item5" => array(
			"title" => "項目５",
			"type" => "text",
		),
		"contents5" => array(
			"title" => "内容５",
			"type" => "textarea",
		),
		"item6" => array(
			"title" => "項目６",
			"type" => "text",
		),
		"contents6" => array(
			"title" => "内容６",
			"type" => "textarea",
		),
		"item7" => array(
			"title" => "項目７",
			"type" => "text",
		),
		"contents7" => array(
			"title" => "内容７",
			"type" => "textarea",
		),
		"item8" => array(
			"title" => "項目８",
			"type" => "text",
		),
		"contents8" => array(
			"title" => "内容８",
			"type" => "textarea",
		),
		"item9" => array(
			"title" => "項目９",
			"type" => "text",
		),
		"contents9" => array(
			"title" => "内容９",
			"type" => "textarea",
		),
		"item10" => array(
			"title" => "項目１０",
			"type" => "text",
		),
		"contents10" => array(
			"title" => "内容１０",
			"type" => "textarea",
		),
	),
	"func" => "func_block_table2",
);

block_add($block_table2);

// 表・テーブル
function func_block_table2($def, $info)
{
	$ary = array();
	for ($i = 1; $i <= 10; $i++) {
		unset($item);
		$item["item"] = $info["item" . $i];
		$item["contents"] = explode("\n", $info["contents" . $i]);
		if ($item["item"] && $item["contents"]) {
			$ary[] = $item;
		}
	}
	if ($ary) {
		$info["items"] = $ary;
	}
	return $info;
}
