<?php
$template = <<<END
<!--travel1_imagetext:画像＋記事-->
<section class="travel1_imagetext">
<!--{def item/title}-->
<h2>{val item/title}</h2>
<!--{/def}-->
<div class="list-normal">
<!--{each item/items}-->
<div class="list">
<figure class="image"><img src="user_data/{val item/items/image_file}" alt="{val item/items/image_name}"></figure>
<div class="text">
<h4>{val item/items/title}</h4>
<p class="markdown-body">{rval item/items/text}</p>
</div>
</div>
<!--{/each}-->
</div>
</section>
END;

$travel1_imagetext = array(
		"title" => "travel1 画像＋記事",
		"name" => "travel1_imagetext",
		"template" => $template,		// ブロックのテンプレート
		"input" => array(
		"help" => array(
			"title" => "使い方",
			"type" => "comment",
			"link" => DOCUMENT1 . "/?act=travel1_imagetext",
			"class" => "notice",
		),
			"title" => array(
				"title" => "見出し",
				"type" => "text",
			),
			"dummy1-1" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item1_title" => array(
				"title" => "タイトル",
				"type" => "text",
			),
			"item1_image" => array(
				"title" => "画像",
				"type" => "image",
			),
			"item1_text" => array(
				"title" => "説明",
				"type" => "textarea",
			),
			"dummy1-2" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item2_title" => array(
				"title" => "タイトル",
				"type" => "text",
			),
			"item2_image" => array(
				"title" => "画像",
				"type" => "image",
			),
			"item2_text" => array(
				"title" => "説明",
				"type" => "textarea",
			),
			"dummy1-3" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item3_title" => array(
				"title" => "タイトル",
				"type" => "text",
			),
			"item3_image" => array(
				"title" => "画像",
				"type" => "image",
			),
			"item3_text" => array(
				"title" => "説明",
				"type" => "textarea",
			),
			"dummy1-4" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item4_title" => array(
				"title" => "タイトル",
				"type" => "text",
			),
			"item4_image" => array(
				"title" => "画像",
				"type" => "image",
			),
			"item4_text" => array(
				"title" => "説明",
				"type" => "textarea",
			),
			"dummy1-5" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item5_title" => array(
				"title" => "タイトル",
				"type" => "text",
			),
			"item5_image" => array(
				"title" => "画像",
				"type" => "image",
			),
			"item5_text" => array(
				"title" => "説明",
				"type" => "textarea",
			),
			"dummy1-6" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item6_title" => array(
				"title" => "タイトル",
				"type" => "text",
			),
			"item6_image" => array(
				"title" => "画像",
				"type" => "image",
			),
			"item6_text" => array(
				"title" => "説明",
				"type" => "textarea",
			),
			"dummy1-7" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item7_title" => array(
				"title" => "タイトル",
				"type" => "text",
			),
			"item7_image" => array(
				"title" => "画像",
				"type" => "image",
			),
			"item7_text" => array(
				"title" => "説明",
				"type" => "textarea",
			),
			"dummy1-8" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item8_title" => array(
				"title" => "タイトル",
				"type" => "text",
			),
			"item8_image" => array(
				"title" => "画像",
				"type" => "image",
			),
			"item8_text" => array(
				"title" => "説明",
				"type" => "textarea",
			),
			"dummy1-9" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item9_title" => array(
				"title" => "タイトル",
				"type" => "text",
			),
			"item9_image" => array(
				"title" => "画像",
				"type" => "image",
			),
			"item9_text" => array(
				"title" => "説明",
				"type" => "textarea",
			),
			"dummy1-10" => array(
				"title" => " ",
				"type" => "comment",
			),
			"item10_title" => array(
				"title" => "タイトル",
				"type" => "text",
			),
			"item10_image" => array(
				"title" => "画像",
				"type" => "image",
			),
			"item10_text" => array(
				"title" => "説明",
				"type" => "textarea",
			),
		),
		"func" => "func_travel1_imagetext",
	);

block_add($travel1_imagetext);

// 画像＋文章
function func_travel1_imagetext($def, $info)
{
	$ary = array();
	for ($i = 1; $i <= 10; $i++) {
		unset($item);
		$item["title"] = $info["item" . $i . "_title"];
		$item["text"] = $info["item" . $i . "_text"];
		if ($item["title"] && $item["text"]) {
			$item["image_file"] = $info["item" . $i . "_image_file"];
			$item["image_name"] = $info["item" . $i . "_image_name"];
			$ary[] = $item;
		}
	}
	if ($ary) {
		$info["items"] = $ary;
	}
	return $info;
}
