<tal:block define="
  model request/ghost_model | request/model;
  public options/public | nothing;
  title_method python: test(public, 'get_title', 'get_title_editable');
  append_to_url options/append_to_url | string:edit/tab_edit;
  root_url model/get_root_url
  "
  xmlns:i18n="http://xml.zope.org/namespaces/i18n"
  i18n:domain="silva">

<h2 class="heading"
  tal:content="model/get_title">
  title
</h2>

<div class="searchform" tal:condition="model/isFormNeeded">
  <form tal:attributes="action model/absolute_url">
    <table class="silvatable plain">
      <tbody>
        <tr tal:repeat="fieldView model/getPublicFieldViews">
          <td class="searchform-title"
            tal:content="fieldView/getTitle"
            i18n:translate="">
            a search object
          </td>
          <td tal:content="structure fieldView/renderPublicWidget">
            a search object
          </td>
          <td tal:content="structure fieldView/getDescription">
            field description
          </td>
        </tr>
        <tr>
          <td></td>
          <td>
            <input class="button searchform-submit"
              type="submit"
              value="Search"
              accesskey="s"
              title="access key: alt-s"
              i18n:attributes="value"
            />
          </td>
          <td></td>
        </tr>
      </tbody>
    </table>
  </form>
</div>

<tal:block tal:condition="request/form/keys">

<div class="searchresults"
  tal:define="
    resultparts python:model.searchResultsWithDescription(request);
    results python:resultparts[0];
    msg python:resultparts[1];
    columnTitles model/getResultsColumnTitles;
    batch python:model.getBatch(results);
    fields python:model.getPublicResultFieldViews();
">

<h3 class="heading" i18n:translate="">Search Results</h3>

<div class="searchresult-header"
  metal:define-macro="searchinfo"
  tal:condition="python:batch.size < len(results)">
  <span class="searchresult-previous">
    <tal:block condition="request/previous_batch_url | nothing">
      <a href="previousbatch" accesskey="p"
         title="See the previous result listing: alt-p"
         tal:attributes="href request/previous_batch_url"
         i18n:attributes="title">
      <img alt="Previous"
        tal:define="image here/globals/left.gif"
        tal:attributes="
          src image/absolute_url;
          width image/width;
          height image/height;
        "/>
      <tal:block i18n:translate="">Previous</tal:block></a>
    </tal:block>
  </span>
  <span class="searchresult-info" i18n:translate="">
    <img alt="spacer" width="16" height="16" border="0"
      tal:attributes="src here/globals/pixel.gif/absolute_url" />
    Showing results
    <tal:block replace="batch/start" i18n:name="batch_start" />
    to
    <tal:block replace="batch/end" i18n:name="batch_end" />
    <tal:block tal:condition="python:'totalresultcount' in [f.getName() for f in fields]">
    of about
    <tal:block replace="batch/total" i18n:name="total" />
    </tal:block>
  </span>
  <span class="searchresult-next">
    <tal:block condition="request/next_batch_url | nothing">
      <a href="nextbatch" accesskey="n"
        title="See the next result listing: alt-n"
        tal:attributes="href request/next_batch_url"
        i18n:attributes="title">
        <tal:block i18n:translate="">Next</tal:block>
        <img alt="Next"
          tal:define="image here/globals/right.gif"
          tal:attributes="
            src image/absolute_url;
            width image/width;
            height image/height;
        "/>
      </a>
    </tal:block>
  </span>
</div>

<ul tal:condition="batch">
  <li tal:repeat="item batch">
    <tal:block define="ix repeat/item/index;"
      condition="fields">
      <div class="searchresult">
        <tal:block repeat="field fields">
          <span class="searchresult-counter"
            tal:define="num python:str(batch.start + ix)"
            tal:condition="python:field.getName() == 'resultcount'"
            tal:attributes="style python:'padding-left:%sex' % (3-len(num))"
            tal:content="string:${num}.">
            count
          </span>
          <tal:block define="result python:field.render(context, item)"
               condition="python:not field.getName() in ['resultcount', 'totalresultcount']">
            <span tal:condition="python:same_type(result, [])"
              tal:repeat="item result"
              tal:replace="structure item" />
            <span tal:condition="python:not same_type(result, [])"
              tal:replace="structure result" />
          </tal:block>
        </tal:block>
      </div>
    </tal:block>
  </li>
</ul>

<div metal:use-macro="here/render_helper/macros/searchinfo"/>
<p class="searchresult-nomatch searchresult-header"
tal:condition="not:batch/end"
tal:content="msg"/>

</div>

</tal:block>
</tal:block>
