<?php
$template = <<<END
<!-- travel1:スライドショー-->
<aside id="mainimg" class="travel1_slide">
<!--{def item/image1_file}-->
<!--{def item/image1_video}-->
<div class="slide {val item/text_pos1}"><video src="user_data/{val item/image1_file}" autoplay loop muted playsinline></video>
<div>
<h2>{val item/title1}<span>{val item/subtitle1}</span></h2>
<p>{val item/text1}</p>
</div>
</div>
<!--{/def}-->
<!--{ndef item/image1_video}-->
<div class="slide {val item/text_pos1}" style="background: url('user_data/{val item/image1_file}') no-repeat center center / cover;">
<div>
<h2>{val item/title1}<span>{val item/subtitle1}</span></h2>
<p>{val item/text1}</p>
</div>
</div>
<!--{/ndef}-->
<!--{/def}-->
<!--{def item/image2_file}-->
<!--{def item/image2_video}-->
<div class="slide {val item/text_pos2}"><video src="user_data/{val item/image2_file}" autoplay loop muted playsinline></video>
<div>
<h2>{val item/title2}<span>{val item/subtitle2}</span></h2>
<p>{val item/text2}</p>
</div>
</div>
<!--{/def}-->
<!--{ndef item/image2_video}-->
<div class="slide {val item/text_pos2}" style="background: url('user_data/{val item/image2_file}') no-repeat center center / cover;">
<div>
<h2>{val item/title2}<span>{val item/subtitle2}</span></h2>
<p>{val item/text2}</p>
</div>
</div>
<!--{/ndef}-->
<!--{/def}-->
<!--{def item/image3_file}-->
<!--{def item/image3_video}-->
<div class="slide {val item/text_pos3}"><video src="user_data/{val item/image3_file}" autoplay loop muted playsinline></video>
<div>
<h2>{val item/title3}<span>{val item/subtitle3}</span></h2>
<p>{val item/text3}</p>
</div>
</div>
<!--{/def}-->
<!--{ndef item/image3_video}-->
<div class="slide {val item/text_pos3}" style="background: url('user_data/{val item/image3_file}') no-repeat center center / cover;">
<div>
<h2>{val item/title3}<span>{val item/subtitle3}</span></h2>
<p>{val item/text3}</p>
</div>
</div>
<!--{/ndef}-->
<!--{/def}-->
<!--{def item/image4_file}-->
<!--{def item/image4_video}-->
<div class="slide {val item/text_pos4}"><video src="user_data/{val item/image4_file}" autoplay loop muted playsinline></video>
<div>
<h2>{val item/title4}<span>{val item/subtitle4}</span></h2>
<p>{val item/text4}</p>
</div>
</div>
<!--{/def}-->
<!--{ndef item/image4_video}-->
<div class="slide {val item/text_pos4}" style="background: url('user_data/{val item/image4_file}') no-repeat center center / cover;">
<div>
<h2>{val item/title4}<span>{val item/subtitle4}</span></h2>
<p>{val item/text4}</p>
</div>
</div>
<!--{/ndef}-->
<!--{/def}-->
<!--{def item/image5_file}-->
<!--{def item/image5_video}-->
<div class="slide {val item/text_pos5}"><video src="user_data/{val item/image5_file}" autoplay loop muted playsinline></video>
<div>
<h2>{val item/title5}<span>{val item/subtitle5}</span></h2>
<p>{val item/text5}</p>
</div>
</div>
<!--{/def}-->
<!--{ndef item/image5_video}-->
<div class="slide {val item/text_pos5}" style="background: url('user_data/{val item/image5_file}') no-repeat center center / cover;">
<div>
<h2>{val item/title5}<span>{val item/subtitle5}</span></h2>
<p>{val item/text5}</p>
</div>
</div>
<!--{/ndef}-->
<!--{/def}-->
<div id="loading-text">loading...</div>
</aside>
END;

$travel1_slide = array(						// ブロック
		"title" => "travel1 スライドショー",	// ブロックの名称
		"name" => "travel1_slide",			// 名称、重複すると正しく動作しません
		"template" => $template,		// ブロックのテンプレート
		"input" => array(				// ブロックの入力定義
		"help" => array(
			"title" => "使い方",
			"type" => "comment",
			"link" => DOCUMENT1 . "/?act=travel1_slide",
			"class" => "notice",
		),
			"notice1" => array(
				"title" => "このブロックはトップページにしか使えません",
				"type" => "comment",
				"class"=> "notice",
			),
			"image1" => array(
				"title" => "画像1",
				"type" => "file",
				"info" => "動画はmp4ファイルを使用してください",
			),
			"title1" => array(
				"title" => "タイトル1",
				"type" => "text",
			),
			"subtitle1" => array(
				"title" => "サブタイトル1",
				"type" => "text",
			),
			"text1" => array(
				"title" => "説明1",
				"type" => "textarea2",
			),
			"text_pos1" => array(
				"title" => "文字位置1",
				"type" => "select",
				"list" => array(
					"slide1" => "左",
					"slide3" => "中央",
					"slide2" => "右",
				),
			),
			"image2" => array(
				"title" => "画像2",
				"type" => "file",
				"info" => "動画はmp4ファイルを使用してください",
			),
			"title2" => array(
				"title" => "タイトル2",
				"type" => "text",
			),
			"subtitle2" => array(
				"title" => "サブタイトル2",
				"type" => "text",
			),
			"text2" => array(
				"title" => "説明2",
				"type" => "textarea2",
			),
			"text_pos2" => array(
				"title" => "文字位置2",
				"type" => "select",
				"list" => array(
					"slide1" => "左",
					"slide3" => "中央",
					"slide2" => "右",
				),
			),
			"image3" => array(
				"title" => "画像3",
				"type" => "file",
				"info" => "動画はmp4ファイルを使用してください",
			),
			"title3" => array(
				"title" => "タイトル3",
				"type" => "text",
			),
			"subtitle3" => array(
				"title" => "サブタイトル3",
				"type" => "text",
			),
			"text3" => array(
				"title" => "説明3",
				"type" => "textarea2",
			),
			"text_pos3" => array(
				"title" => "文字位置3",
				"type" => "select",
				"list" => array(
					"slide1" => "左",
					"slide3" => "中央",
					"slide2" => "右",
				),
			),
			"image4" => array(
				"title" => "画像4",
				"type" => "file",
				"info" => "動画はmp4ファイルを使用してください",
			),
			"title4" => array(
				"title" => "タイトル4",
				"type" => "text",
			),
			"subtitle4" => array(
				"title" => "サブタイトル4",
				"type" => "text",
			),
			"text4" => array(
				"title" => "説明4",
				"type" => "textarea2",
			),
			"text_pos4" => array(
				"title" => "文字位置4",
				"type" => "select",
				"list" => array(
					"slide1" => "左",
					"slide3" => "中央",
					"slide2" => "右",
				),
			),
			"image5" => array(
				"title" => "画像5",
				"type" => "file",
				"info" => "動画はmp4ファイルを使用してください",
			),
			"title5" => array(
				"title" => "タイトル5",
				"type" => "text",
			),
			"subtitle5" => array(
				"title" => "サブタイトル5",
				"type" => "text",
			),
			"text5" => array(
				"title" => "説明5",
				"type" => "textarea2",
			),
			"text_pos5" => array(
				"title" => "文字位置5",
				"type" => "select",
				"list" => array(
					"slide1" => "左",
					"slide3" => "中央",
					"slide2" => "右",
				),
			),
		),
		"func" => "func_travel1_slide",		// 処理プログラム（指定がない物は標準処理）
		"output" => "slide",		// 出力位置
	);

block_add($travel1_slide);


// スライドの設定
function func_travel1_slide($def, $info)
{
	$slide = array();
	if ($info["image1"]) {
		$f = Image::getData($info["image1"]);
		if ($f["filetype"] == "video/mp4") {
			$info["image1_video"] = "1";
		}
	}
	if ($info["image2"]) {
		$f = Image::getData($info["image2"]);
		if ($f["filetype"] == "video/mp4") {
			$info["image2_video"] = "1";
		}
	}
	if ($info["image3"]) {
		$f = Image::getData($info["image3"]);
		if ($f["filetype"] == "video/mp4") {
			$info["image3_video"] = "1";
		}
	}
	if ($info["image4"]) {
		$f = Image::getData($info["image4"]);
		if ($f["filetype"] == "video/mp4") {
			$info["image4_video"] = "1";
		}
	}
	if ($info["image5"]) {
		$f = Image::getData($info["image5"]);
		if ($f["filetype"] == "video/mp4") {
			$info["image5_video"] = "1";
		}
	}
	return $info;
}
