<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xmlns:xi="http://www.w3.org/2001/XInclude" xmlns:py="http://genshi.edgewall.org/">
  <xi:include href="discussion-macros.html"/>
  <xi:include href="layout.html"/>
  <head>
    <title>Topic List</title>
  </head>

  <body>
    <xi:include href="discussion-header.html"/>

    <div id="content" class="discussion">
      <div id="${discussion.mode}" class="${discussion.mode}">

        <h1>${discussion.forum.name} (#${discussion.forum.id}) - Topic List</h1>
        <h2>${discussion.forum.subject}</h2>
        <p>${discussion.forum.description}</p>

        <py:choose>
          <table py:when="len(discussion.topics)" class="listing">
            <thead>
              <tr>
                ${sortable_th(discussion.order, discussion.direction, 'id', 'ID', href.discussion(discussion.forum.id))}
                ${sortable_th(discussion.order, discussion.direction, 'subject', 'Subject', href.discussion(discussion.forum.id))}
                ${sortable_th(discussion.order, discussion.direction, 'author', 'Author', href.discussion(discussion.forum.id))}
                ${sortable_th(discussion.order, discussion.direction, 'lastreply', 'Last Reply', href.discussion(discussion.forum.id))}
                ${sortable_th(discussion.order, discussion.direction, 'time', 'Founded', href.discussion(discussion.forum.id))}
                ${sortable_th(discussion.order, discussion.direction, 'replies', 'Replies', href.discussion(discussion.forum.id))}
                <th class="new_replies">New Replies</th>
              </tr>
            </thead>
            <tbody>
              <tr py:for="line, topic in enumerate(discussion.topics)" class="${line % 2 and 'even' or 'odd'}">
                <td class="id">
                  <div class="id">
                    <a href="${href.discussion(discussion.forum.id, topic.id)}">
                      <span>${topic.id}</span>
                    </a>
                  </div>
                </td>
                <td class="subject">
                  <div class="subject">
                    <a href="${href.discussion(discussion.forum.id, topic.id)}">
                      <span>${topic.subject or '&nbsp;'}</span>
                    </a>
                  </div>
                </td>
                <td class="author">
                  <div class="author">
                    <a href="${href.discussion(discussion.forum.id, topic.id)}">
                      <span>${topic.author or '&nbsp;'}</span>
                    </a>
                  </div>
                </td>
                <td class="lastreply">
                  <div class="lastreply">
                    <a href="${href.discussion(discussion.forum.id, topic.id)}">
                      <span>${topic.lastreply or '&nbsp;'}</span>
                    </a>
                  </div>
                </td>
                <td class="founded">
                  <div class="founded">
                    <a href="${href.discussion(discussion.forum.id, topic.id)}">
                      <span>${topic.time or '&nbsp;'}</span>
                    </a>
                  </div>
                </td>
                <td class="replies">
                  <div class="replies">
                    <a href="${href.discussion(discussion.forum.id, topic.id)}">
                      <span>${topic.replies or '0'}</span>
                    </a>
                  </div>
                </td>
                <td class="new_replies">
                  <div class="new_replies">
                    <a href="${href.discussion(discussion.forum.id, topic.id)}">
                      <span>${topic.new_replies or '0'}</span>
                    </a>
                  </div>
                </td>
              </tr>
            </tbody>
          </table>
          <p py:otherwise="" class="help">There are no topics created in this forum.</p>
        </py:choose>

        <div class="buttons">
          <form py:if="'DISCUSSION_APPEND' in perm" method="post" action="${href.discussion(discussion.forum.id)}">
            <div>
              <input type="submit" name="newtopic" value="New Topic"/>
              <input type="hidden" name="forum" value="${discussion.forum.id}"/>
              <input type="hidden" name="discussion_action" value="add"/>
            </div>
          </form>
          <form py:if="'DISCUSSION_ADMIN' in perm" method="post" action="${href.discussion()}">
            <div>
              <input type="submit" name="deleteforum" value="Delete Forum" onclick="return confirm('Do you realy want to delete this forum?')"/>
              <input type="hidden" name="forum" value="${discussion.forum.id}"/>
              <input type="hidden" name="discussion_action" value="delete"/>
            </div>
          </form>
        </div>

      </div>
    </div>

    <xi:include href="discussion-footer.html"/>
  </body>
</html>
