<div
  xmlns="http://www.w3.org/1999/xhtml"
  xmlns:metal="http://xml.zope.org/namespaces/metal"
  xmlns:tal="http://xml.zope.org/namespaces/tal"
  xmlns:i18n="http://xml.zope.org/namespaces/i18n"
  i18n:domain="silva_news"

  tal:define="view here;
              model view/REQUEST/model;
              currentmonth request/month | options/month | view/currentmonth;
              currentyear request/year | options/year | view/currentyear;
              months view/get_months;
              results python:model.get_items_by_date(currentmonth, currentyear);
              offset python:int(request.get('offset', 0));
              batch_size model/number_to_show_archive;
              batch python:modules['ZTUtils'].Batch(results, size=batch_size, start=offset);
              previous batch/previous;
              next batch/next;
              user_role view/get_user_role;
              silva_root view/silva_root;
              formatdate nocall:view/service_news/format_date;
              "
>

  <h2 class="heading" i18n:translate="">
    Archive of <tal:block i18n:name="title" tal:content="model/get_title" />
  </h2>

  <table class="timetable">
    <tbody>
      <tr class="even">
        <td>
          <a href="3" tal:content="structure python: '<<&nbsp;%s' % str(int(currentyear) - 1)" tal:attributes="href python:'?month=%s&year=%s&view=view_archive' % (currentmonth, int(currentyear) - 1)">2001</a>
        </td>
        <tal:repeat repeat="month months">
          <tal:define define="id repeat/month/index">
            <td align="center" tal:attributes="class python:test(id == int(currentmonth) - 1, 'selected_month', '');">
              <a href="#" tal:content="month" tal:attributes="href python: '?month=%s&year=%s&view=view_archive' % (id + 1, currentyear)"></a>
            </td>
          </tal:define>
        </tal:repeat>
        <td>
          <a href="3" tal:content="structure python: '%s&nbsp;>>' % str(int(currentyear) + 1)" tal:attributes="href python:'?month=%s&year=%s&view=view_archive' % (currentmonth, int(currentyear) + 1)">2003</a>
        </td>
      </tr>
    </tbody>
  </table>

  <div class="offsetnav"
      tal:condition="python: previous or next"
      >
    <tal:block tal:condition="previous">
      <a tal:attributes="href python:'?view=view_archive&month=%s&year=%s&offset=%s' % (currentmonth, currentyear, (offset - batch_size))">previous</a>&nbsp;
    </tal:block>
    <a tal:condition="next" tal:attributes="href python:'?view=view_archive&month=%s&year=%s&offset=%s' % (currentmonth, currentyear, (offset + batch_size))">next</a>
  </div>

  <tal:comment condition="nothing">Begin items</tal:comment>

  <div class="newsitem" tal:repeat="r batch">
   <tal:block define="obj r/getObject">
    <metal:macro use-macro="here/agendaitem_macro/macros/agendaitem" />
   </tal:block>
  </div>

  <p class="p newsmessage" tal:condition="python: len(results) < 1" i18n:translate="">
    There are no articles available
  </p>

  <tal:comment condition="nothing">End items</tal:comment>

  <div class="offsetnav"
      tal:condition="python: previous or next"
      >
    <tal:block tal:condition="previous">
      <a tal:attributes="href python:'?view=view_archive&month=%s&year=%s&offset=%s' % (currentmonth, currentyear, (offset - batch_size))">previous</a>&nbsp;
    </tal:block>
    <a tal:condition="next" tal:attributes="href python:'?view=view_archive&month=%s&year=%s&offset=%s' % (currentmonth, currentyear, (offset + batch_size))">next</a>
  </div>

  <table class="timetable">
    <tbody>
      <tr>
        <td>
          <a href="3" tal:content="structure python: '<<&nbsp;%s' % str(int(currentyear) - 1)" tal:attributes="href python:'?month=%s&year=%s&view=view_archive' % (currentmonth, int(currentyear) - 1)">2001</a>
        </td>
        <tal:repeat repeat="month months">
          <tal:define define="id repeat/month/index">
            <td align="center" tal:attributes="class python:test(id == int(currentmonth) - 1, 'selected_month', '');">
              <a href="#" tal:content="month" tal:attributes="href python: '?month=%s&year=%s&view=view_archive' % (id + 1, currentyear)"></a>
            </td>
          </tal:define>
        </tal:repeat>
        <td>
          <a href="3" tal:content="structure python: '%s&nbsp;>>' % str(int(currentyear) + 1)" tal:attributes="href python:'?month=%s&year=%s&view=view_archive' % (currentmonth, int(currentyear) + 1)">2003</a>
        </td>
      </tr>
    </tbody>
  </table>

    <p class="p viewlink">
      <a href="#" tal:attributes="href string:?view=view_agenda" i18n:translate="">view agenda</a>
    </p>

</div>
