<!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>Forum List</title>
  </head>

  <py:def function="display_group(group, forums)">
    <table class="listing">
      <thead>
        <tr py:if="group and group.id != 0">
          <th class="group" colspan="10">
            <div class="name">${group.name}</div>
            <div class="description">${group.description}</div>
          </th>
        </tr>
        <tr>
          ${sortable_th(discussion.order, discussion.direction, 'id', 'ID', href.discussion())}
          ${sortable_th(discussion.order, discussion.direction, 'subject', 'Forum', href.discussion())}
          ${sortable_th(discussion.order, discussion.direction, 'moderators', 'Moderators', href.discussion())}
          ${sortable_th(discussion.order, discussion.direction, 'lasttopic', 'Last Topic', href.discussion())}
          ${sortable_th(discussion.order, discussion.direction, 'lastreply', 'Last Reply', href.discussion())}
          ${sortable_th(discussion.order, discussion.direction, 'time', 'Founded', href.discussion())}
          ${sortable_th(discussion.order, discussion.direction, 'topics', 'Topics', href.discussion())}
          <th>New Topics</th>
          ${sortable_th(discussion.order, discussion.direction, 'replies', 'Replies', href.discussion())}
          <th>New Replies</th>
        </tr>
      </thead>
      <tbody>
        <py:for each="line, forum in enumerate(forums)">
          <tr py:if="forum.group == group.id" class="${line % 2 and 'even' or 'odd'}">
            <td class="id">
              <div class="id">
                 <a href="${href.discussion(forum.id)}">
                   <span>${forum.id}</span>
                 </a>
              </div>
            </td>
            <td class="title">
              <div class="subject">
                <a href="${href.discussion(forum.id)}">
                  <span>${forum.subject or '&nbsp;'}</span>
                </a>
              </div>
              <div class="description">
                <a href="${href.discussion(forum.id)}">
                  <span>${forum.description or '&nbsp;'}</span>
                </a>
              </div>
            </td>
            <td class="moderators">
              <div class="moderators">
                <a href="${href.discussion(forum.id)}">
                  <span>${forum.moderators or '&nbsp;'}</span>
                </a>
              </div>
            </td>
            <td class="lasttopic">
              <div class="lasttopic">
                <a href="${href.discussion(forum.id)}">
                  <span>${forum.lasttopic or '&nbsp;'}</span>
                </a>
              </div>
            </td>
            <td class="lastreply">
              <div class="lastreply">
                <a href="${href.discussion(forum.id)}">
                  <span>${forum.lastreply or '&nbsp;'}</span>
                </a>
              </div>
            </td>
            <td class="founded">
              <div class="founded">
                <a href="${href.discussion(forum.id)}">
                  <span>${forum.time or '&nbsp;'}</span>
                </a>
              </div>
            </td>
            <td class="topics">
              <div class="topics">
                <a href="${href.discussion(forum.id)}">
                  <span>${forum.topics or '0'}</span>
                </a>
              </div>
            </td>
            <td class="new_topics">
              <div class="new_topics">
                <a href="${href.discussion(forum.id)}">
                  <span>${forum.new_topics or '0'}</span>
                </a>
              </div>
            </td>
            <td class="replies">
              <div class="replies">
                <a href="${href.discussion(forum.id)}">
                  <span>${forum.replies or '0'}</span>
                </a>
              </div>
            </td>
            <td class="new_replies">
              <div class="new_replies">
                <a href="${href.discussion(forum.id)}">
                  <span>${forum.new_replies or '0'}</span>
                </a>
              </div>
            </td>
          </tr>
        </py:for>
      </tbody>
    </table>
  </py:def>

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

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

        <h1>Forum List</h1>

        <py:choose>
          <py:for py:when="len(discussion.forums)" each="group in discussion.groups">
            <py:if test="group.forums">
              ${display_group(group, discussion.forums)}
            </py:if>
          </py:for>
          <p py:otherwise="" class="help">There are no forums created.</p>
        </py:choose>

        <div py:if="'DISCUSSION_ADMIN' in perm" class="buttons">
          <form method="post" action="${href.discussion()}">
            <div>
              <input type="submit" name="newforum" value="New Forum"/>
              <input type="hidden" name="discussion_action" value="add"/>
            </div>
          </form>
        </div>

      </div>
    </div>

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