<?php
$template = <<<END
<section class="kids7_event">
<h2>{val item/title}</h2>
<table class="ta1">
<!--{def item/caption}-->
<caption>{val item/caption}</caption>
<!--{/def}-->
<tr>
<!--{each item/list}-->
<th>{val item/list/item}</th>
<td class="markdown-body">{rval item/list/text}<br>
<!--{def item/list/image}-->
<img src="user_data/{val item/list/image}" alt="">
<!--{/def}-->
</td>
</tr>
<!--{/each}-->
</table>
</section>
END;

$kids7_event = array(
		"title" => "kids7 イベント",
		"name" => "kids7_event",			// 名称、重複すると正しく動作しません
		"template" => $template,		// ブロックのテンプレート
		"input" => array(
		"help" => array(
			"title" => "使い方",
			"type" => "comment",
			"link" => DOCUMENT1 . "/?act=kids7_event",
			"class" => "notice",
		),
			"title" => array(
				"title" => "タイトル",
				"type" => "text",
			),
			"caption" => array(
				"title" => "表見出し",
				"type" => "text",
			),
			"dummy1" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item1" => array(
				"title" => "項目名1",
				"type" => "text",
			),
			"text1" => array(
				"title" => "内容1",
				"type" => "textarea",
			),
			"image1" => array(
				"title" => "画像1",
				"type" => "image",
			),
			"dummy2" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item2" => array(
				"title" => "項目名2",
				"type" => "text",
			),
			"text2" => array(
				"title" => "内容2",
				"type" => "textarea",
			),
			"image2" => array(
				"title" => "画像2",
				"type" => "image",
			),
			"dummy3" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item3" => array(
				"title" => "項目名3",
				"type" => "text",
			),
			"text3" => array(
				"title" => "内容3",
				"type" => "textarea",
			),
			"image3" => array(
				"title" => "画像3",
				"type" => "image",
			),
			"dummy4" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item4" => array(
				"title" => "項目名4",
				"type" => "text",
			),
			"text4" => array(
				"title" => "内容4",
				"type" => "textarea",
			),
			"image4" => array(
				"title" => "画像4",
				"type" => "image",
			),
			"dummy5" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item5" => array(
				"title" => "項目名5",
				"type" => "text",
			),
			"text5" => array(
				"title" => "内容5",
				"type" => "textarea",
			),
			"image5" => array(
				"title" => "画像5",
				"type" => "image",
			),
			"dummy6" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item6" => array(
				"title" => "項目名6",
				"type" => "text",
			),
			"text6" => array(
				"title" => "内容6",
				"type" => "textarea",
			),
			"image6" => array(
				"title" => "画像6",
				"type" => "image",
			),
			"dummy7" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item7" => array(
				"title" => "項目名7",
				"type" => "text",
			),
			"text7" => array(
				"title" => "内容7",
				"type" => "textarea",
			),
			"image7" => array(
				"title" => "画像7",
				"type" => "image",
			),
			"dummy8" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item8" => array(
				"title" => "項目名8",
				"type" => "text",
			),
			"text8" => array(
				"title" => "内容8",
				"type" => "textarea",
			),
			"image8" => array(
				"title" => "画像8",
				"type" => "image",
			),
			"dummy9" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item9" => array(
				"title" => "項目名9",
				"type" => "text",
			),
			"text9" => array(
				"title" => "内容9",
				"type" => "textarea",
			),
			"image9" => array(
				"title" => "画像9",
				"type" => "image",
			),
			"dummy10" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item10" => array(
				"title" => "項目名10",
				"type" => "text",
			),
			"text10" => array(
				"title" => "内容10",
				"type" => "textarea",
			),
			"image10" => array(
				"title" => "画像10",
				"type" => "image",
			),
			"dummy11" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item11" => array(
				"title" => "項目名11",
				"type" => "text",
			),
			"text11" => array(
				"title" => "内容11",
				"type" => "textarea",
			),
			"image11" => array(
				"title" => "画像11",
				"type" => "image",
			),
			"dummy12" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item12" => array(
				"title" => "項目名12",
				"type" => "text",
			),
			"text12" => array(
				"title" => "内容12",
				"type" => "textarea",
			),
			"image12" => array(
				"title" => "画像12",
				"type" => "image",
			),
		),
		"func" => "func_kids7_event",		// 処理プログラム（指定がない物は標準処理）
	);

block_add($kids7_event);

function func_kids7_event($def, $info)
{
	$list = array();
	for ($i = 1; $i <= 12; $i++) {
		unset($item);
		if ($info["item". $i]) {
			$item["item"] = $info["item". $i];
			$item["text"] = $info["text". $i];
			if ($info["image" . $i]) {
				$item["image"] = $info["image" . $i . "_file"];
			}
			$list[] = $item;
		}
	}
	$info["list"] = $list;
	return $info;
}
