<?php
$template = <<<END
<!--{def item/file_file}-->
<!--block_avp:オーディオ、ビデオ、パノラマ-->
<section class="block_avp">
<table class="ta1">
<tr>
<th>{val item/title}</th>
<td>
<!--{def item/type_audio}-->
<audio controls="" src="user_data/{val item/file_file}">{val item/file_name}</audio>
<!--{/def}-->
<!--{def item/type_video}-->
<video controls="" src="user_data/{val item/file_file}">{val item/file_name}</video>
<!--{/def}-->
<!--{def item/type_panorama}-->
<div id="panorama_{val id}"></div>
<script>
pannellum.viewer('panorama_{val id}', {
    "type": "equirectangular",
    "panorama": "user_data/{val item/file_file}",
    "autoLoad": true
});
</script>
<!--{/def}-->
</td>
</tr>
<!--{def item/contents}-->
<tr>
<th>説明</th>
<td class="markdown-body">{rval item/contents}</td>
</tr>
<!--{/def}-->
</table>

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

$block_avp = array(
	"title" => "音声・動画・パノラマ",
	"name" => "block_avp",			// 名称、重複すると正しく動作しません
	"template" => $template,		// ブロックのテンプレートファイル
	"input" => array(
		"help" => array(
			"title" => "使い方",
			"type" => "comment",
			"link" => DOCUMENT1 . "/?act=block_avp",
			"class" => "notice",
		),
		"title" => array(
			"title" => "タイトル",
			"type" => "text",
		),
		"type" => array(
			"title" => "種類",
			"type" => "select",
			"list" => array(
				"audio" => "オーディオ",
				"video" => "ビデオ",
				"panorama" => "パノラマ",
			),
		),
		"file" => array(
			"title" => "ファイル",
			"type" => "file",
		),
		"contents" => array(
			"title" => "説明",
			"type" => "textarea",
		),
	),
	"func" => "func_block_avp",
);

block_add($block_avp);

function func_block_avp($def, $info)
{
	if ($info["file"]) {
		$info["type_" . $info["type"]] = $info["type"];
	}
	return $info;
}
