<?php
$template = <<<END
<!-- hairsalon1 プラン・価格 -->
<section class="hairsalon_plan">
<!--{each item/list}-->
<h3>{val item/list/title}</h3>
<dl class="line">
<!--{each item/list/item}-->
<dt>{val item/list/item/dt}</dt>
<dd>{val item/list/item/dd}</dd>
<!--{/each}-->
</dl>
<!--{/each}-->
</section>
END;

$hairsalon_plan = array(
	"title" => "hairsalon1 プラン・価格",
	"name" => "hairsalon_plan",		// 名称、重複すると正しく動作しません
	"template" => $template,		// ブロックのテンプレート
	"input" => array(
		"help" => array(
			"title" => "使い方",
			"type" => "comment",
			"link" => DOCUMENT1 . "/?act=hairsalon_plan",
			"class" => "notice",
		),
		"title1" => array(
			"title" => "タイトル1",
			"type" => "text",
		),
		"item1" => array(
			"title" => "項目と値1",
			"type" => "textarea",
			"info" => "1行に1項目、項目と値は「|」で区切ります。（例：子供|1,500円）",
		),
		"dummy1" => array(
			"title" => " ",
			"type" => "comment",
		),
		"title2" => array(
			"title" => "タイトル2",
			"type" => "text",
		),
		"item2" => array(
			"title" => "項目と値2",
			"type" => "textarea",
			"info" => "1行に1項目、項目と値は「|」で区切ります。（例：子供|1,500円）",
		),
		"dummy3" => array(
			"title" => " ",
			"type" => "comment",
		),
		"title3" => array(
			"title" => "タイトル3",
			"type" => "text",
		),
		"item3" => array(
			"title" => "項目と値3",
			"type" => "textarea",
			"info" => "1行に1項目、項目と値は「|」で区切ります。（例：子供|1,500円）",
		),
		"dummy4" => array(
			"title" => " ",
			"type" => "comment",
		),
		"title4" => array(
			"title" => "タイトル4",
			"type" => "text",
		),
		"item4" => array(
			"title" => "項目と値4",
			"type" => "textarea",
			"info" => "1行に1項目、項目と値は「|」で区切ります。（例：子供|1,500円）",
		),
		"dummy5" => array(
			"title" => " ",
			"type" => "comment",
		),
		"title5" => array(
			"title" => "タイトル5",
			"type" => "text",
		),
		"item5" => array(
			"title" => "項目と値5",
			"type" => "textarea",
			"info" => "1行に1項目、項目と値は「|」で区切ります。（例：子供|1,500円）",
		),
	),
	"func" => "func_hairsalon1_plan",		// 処理プログラム（指定がない物は標準処理）
);

block_add($hairsalon_plan);

function func_hairsalon1_plan($def, $info)
{
	$list = array();
	for ($i = 1; $i <= 10; $i++) {
		$title = $info["title" . $i];
		$item = trim($info["item" . $i]);
		$ary = explode("\n", $item);
		if ($title && $ary) {
			$list2 = array();
			foreach ($ary as $val) {
				$item = array();
				$ary2 = explode("|", trim($val));
				if ($ary2) {
					$item["dt"] = $ary2[0];
					$item["dd"] = $ary2[1];
				}
				$list2["item"][] = $item;
			}
			$list2["title"] = $title;
			$list[] = $list2;
		}
	}
	$info["list"] = $list;
	return $info;
}
