<?php
$template = <<<END
<!--block_faq:FAQ-->
<section class="block_faq">
<h2>{val item/title}</h2>
<dl class="faq">
<!--{each item/items}-->
<dt class="<!--{def item/openclose}-->openclose<!--{/def}-->">{val item/items/title}</dt>
<dd class="markdown-body">{rval item/items/answer}</dd>
<!--{/each}-->
</dl>
</section>
END;

$block_faq = array(
		"title" => "FAQ",
		"name" => "block_faq",
		"template" => $template,		// ブロックのテンプレート
		"input" => array(
		"help" => array(
			"title" => "使い方",
			"type" => "comment",
			"link" => DOCUMENT1 . "/?act=block_faq",
			"class" => "notice",
		),
			"title" => array(
				"title" => "タイトル",
				"type" => "text",
			),
			"openclose" => array(
				"title" => "開閉方法",
				
				"type" => "select",
				"list" => array(
					"" => "開いたまま",
					"1" => "開閉タイプ",
				),
			),
			"item1_title" => array(
				"title" => "質問１",
				"type" => "textarea",
			),
			"item1_answer" => array(
				"title" => "回答１",
				"type" => "textarea",
			),
			"item2_title" => array(
				"title" => "質問２",
				"type" => "textarea",
			),
			"item2_answer" => array(
				"title" => "回答２",
				"type" => "textarea",
			),
			"item3_title" => array(
				"title" => "質問３",
				"type" => "textarea",
			),
			"item3_answer" => array(
				"title" => "回答３",
				"type" => "textarea",
			),
			"item4_title" => array(
				"title" => "質問４",
				"type" => "textarea",
			),
			"item4_answer" => array(
				"title" => "回答４",
				"type" => "textarea",
			),
			"item5_title" => array(
				"title" => "質問５",
				"type" => "textarea",
			),
			"item5_answer" => array(
				"title" => "回答５",
				"type" => "textarea",
			),
			"item6_title" => array(
				"title" => "質問６",
				"type" => "textarea",
			),
			"item6_answer" => array(
				"title" => "回答６",
				"type" => "textarea",
			),
			"item7_title" => array(
				"title" => "質問７",
				"type" => "textarea",
			),
			"item7_answer" => array(
				"title" => "回答７",
				"type" => "textarea",
			),
			"item8_title" => array(
				"title" => "質問８",
				"type" => "textarea",
			),
			"item8_answer" => array(
				"title" => "回答８",
				"type" => "textarea",
			),
			"item9_title" => array(
				"title" => "質問９",
				"type" => "textarea",
			),
			"item9_answer" => array(
				"title" => "回答９",
				"type" => "textarea",
			),
			"item10_title" => array(
				"title" => "質問１０",
				"type" => "textarea",
			),
			"item10_answer" => array(
				"title" => "回答１０",
				"type" => "textarea",
			),
		),
		"func" => "func_block_faq",
	);

block_add($block_faq);

// FAQ
function func_block_faq($def, $info)
{
	$ary = array();
	for ($i = 1; $i <= 10; $i++) {
		unset($item);
		$item["title"] = $info["item" . $i . "_title"];
		$item["answer"] = $info["item" . $i . "_answer"];
		if ($item["title"] && $item["answer"]) {
			$ary[] = $item;
		}
	}
	if ($ary) {
		$info["items"] = $ary;
	}
	return $info;
}
