<?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>
<td class="markdown-body">{rval item/items/contents}</td>
</tr>
<!--{/each}-->
</table>

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

$block_table = array(
		"title" => "表（テーブル）",
		"name" => "block_table",			// 名称、重複すると正しく動作しません
		"template" => $template,		// ブロックのテンプレートファイル
		"input" => array(
		"help" => array(
			"title" => "使い方",
			"type" => "comment",
			"link" => DOCUMENT1 . "/?act=block_table",
			"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_table",
	);

block_add($block_table);

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