<!DOCTYPE html>
<html>
	<head>
		<%= htmlparts["headtag"] %>
		<%= htmlparts['headjs_switchpost'] %>
	</head>
	<body>
		<form action="<%= cgi.script_name %>" method="POST">
			<div class="menu_wrapper">
				<%= htmlparts["menu"] %>
			</div>
			<%= htmlparts["selectfile"] %>
			<%= htmlparts["infoarea"] %>
			<div class="contents">
				<h1>記事削除</h1>
				<input type="hidden" name="target_filepath" value="<%= session["target_filepath"] %>"><% case params["action"]
                when "confirm" %>
                <input type="hidden" name="delid" value="<%= session["delid"] %>">
                　■　次の記事を削除します。よろしいですか？
                <br>
                <table>
                    <tbody>
                        <% db.transaction do
                        entry = db["delentry"]
                        entry.paramlist.each do |val| %>
                        <tr style="display: <%= entry.display[val] %>;">
                            <th class="small middle padding_normal">
                                <%= entry.name[val] %>
                            </th>
                            <td class="large middle padding_normal">
                                <% if val != "content" %><%= entry.send(val) %><% else %><%= entry.content_for_view %><% end %>
                            </td>
                        </tr>
                        <tr style="display: <%= entry.display[val] %>;">
                            <td class="hr"></td>
                            <td class="hr"></td>
                        </tr>
                        <% end %>
                        <% end %>
                    </tbody>
                </table>
                <br>
                <div class="center">
                	<input type="hidden" name="mode" value="delentry"><input type="hidden" name="action" value=""><input type="button" value="戻る" onclick="switchsubmit(this.form, 'back')">　<input type="button" value="確定" onclick="switchsubmit(this.form, 'exec')">
                </div>
                <br>
                <% else %>
                <% db.transaction do %>
                <table>
                    <tbody>
                        <tr>
                            <td class="center" style="width: 50px;">
                                　 
                            </td>
                            <th class="large center padding_normal">
                                記事のタイトル
                            </th>
                            <th class="small center padding_normal">
                                最終更新時間
                            </th>
                        </tr>
                        <tr>
                            <td class="hr"></td>
                            <td class="hr"></td>
                            <td class="hr"></td>
                        </tr>
                        <% db["entry"].each_with_index do |entry, i| %>
                        <tr>
                            <td class="center padding_normal">
                                <% if params["action"] == "back" and session["delid"] == entry.entryid %>
                                <input type="radio" name="delid" value="<%= entry.send("entryid") %>" checked="checked"><% else %>
                                <input type="radio" name="delid" value="<%= entry.send("entryid") %>"><% end %>
                            </td>
                            <td class="left padding_normal default_word_break">
                                <%= entry.send("title") %>
                            </td>
                            <td class="center padding_normal">
                                <%= entry.send("published").gsub("+09:00", "").gsub("T", " ") %>
                            </td>
                        </tr>
                        <tr>
                            <td class="hr"></td>
                            <td class="hr"></td>
                            <td class="hr"></td>
                        </tr>
                        <% end %>
                    </tbody>
                </table>
                <br>
                <% if db["entry"].length != 0 %>
                <div class="center">
                	<input type="hidden" name="mode" value="delentry"><input type="hidden" name="action" value="confirm"><input type="submit" value="確認">
                </div>
                <br>
                <% else %>
                <div class="center">
                	削除対象となる記事が存在しません。
                </div>
                <br>
                <br>
                <% end %>
                <% end %>
                <% end %>
			</div>
			<div class="bottom_area">
				<%= APPVERSION %>
			</div>
		</form>
	</body>
</html>
