<?php
$template = <<<END
<!--pop1_slide:スライドショー-->
<aside id="mainimg" class="pop1_slide">
<!--{each item/slide}-->
<div class="slide {val item/slide/text_pos}" style="background: url('user_data/{val item/slide/image}') no-repeat center center / cover;">
<div>
<p>
<!--{each item/slide/text}-->
<span>{val item/slide/text}</span><br>
<!--{/each}-->
</p>
</div>
</div>
<!--{/each}-->
</aside>
END;

$pop1_slide = array(						// ブロック
		"title" => "pop1スライドショー",	// ブロックの名称
		"name" => "pop1_slide",			// 名称、重複すると正しく動作しません
		"template" => $template,		// ブロックのテンプレート
		"input" => array(				// ブロックの入力定義
		"help" => array(
			"title" => "使い方",
			"type" => "comment",
			"link" => DOCUMENT1 . "/?act=pop1_slide",
			"class" => "notice",
		),
			"notice1" => array(
				"title" => "このブロックはトップページにしか使えません",
				"type" => "comment",
				"class"=> "notice",
			),
			"help" => array(
				"title" => "使い方",
				"type" => "comment",
				"link" => "https://q19cms.com/doc/",
				"class" => "notice",
			),
			"image1" => array(
				"title" => "画像1",
				"type" => "image",
			),
			"text1" => array(
				"title" => "文字1",
				"type" => "textarea",
				"info" => "2行で記入してください",
			),
			"text_pos1" => array(
				"title" => "文字位置1",
				"type" => "select",
				"list" => array(
					"slide1" => "左",
					"slide3" => "中央",
					"slide2" => "右",
				),
			),
			"image2" => array(
				"title" => "画像2",
				"type" => "image",
			),
			"text2" => array(
				"title" => "文字表示2",
				"type" => "textarea",
				"info" => "2行で記入してください",
			),
			"text_pos2" => array(
				"title" => "文字位置2",
				"type" => "select",
				"list" => array(
					"slide1" => "左",
					"slide3" => "中央",
					"slide2" => "右",
				),
			),
			"image3" => array(
				"title" => "画像3",
				"type" => "image",
			),
			"text3" => array(
				"title" => "文字表示3",
				"type" => "textarea",
				"info" => "2行で記入してください",
			),
			"text_pos3" => array(
				"title" => "文字位置3",
				"type" => "select",
				"list" => array(
					"slide1" => "左",
					"slide3" => "中央",
					"slide2" => "右",
				),
			),
			"image4" => array(
				"title" => "画像4",
				"type" => "image",
			),
			"text4" => array(
				"title" => "文字表示4",
				"type" => "textarea",
				"info" => "2行で記入してください",
			),
			"text_pos4" => array(
				"title" => "文字位置4",
				"type" => "select",
				"list" => array(
					"slide1" => "左",
					"slide3" => "中央",
					"slide2" => "右",
				),
			),
			"image5" => array(
				"title" => "画像5",
				"type" => "image",
			),
			"text5" => array(
				"title" => "文字表示5",
				"type" => "textarea",
				"info" => "2行で記入してください",
			),
			"text_pos5" => array(
				"title" => "文字位置5",
				"type" => "select",
				"list" => array(
					"slide1" => "左",
					"slide3" => "中央",
					"slide2" => "右",
				),
			),
		),
		"func" => "func_pop1_slide",	// 処理プログラム（指定がない物は標準処理）
		"output" => "slide",			// 出力位置
	);

block_add($pop1_slide);

// スライドの設定
function func_pop1_slide($def, $info)
{
	$slide = array();
	for ($i = 1; $i <= 10; $i++) {
		if ($info["image" . $i]) {
			unset($item);
			$item["image"] = $info["image" . $i . "_file"];
			// キャッチコピーの処理
			$text = $info["text" . $i];
			$ary = explode("\n", $text);
			unset($t);
			foreach ($ary as $val2) {
				$t[] = trim($val2);
			}
			$item["text"] = $t;
			$item["text_pos"] = $info["text_pos" . $i];
			$slide[] = $item;
		}
	}
	$info["slide"] = $slide;
	return $info;
}
