<metal:block define-macro="version_contributor"
    tal:define="contributor version/contributor;
                auth_tool here/getAuthenticationTool;
                username python: auth_tool.name_from_userid(contributor) or contributor;
                user_quoted python:here.utUrlEncode(contributor);
                source_title python: auth_tool.source_name_from_userid(contributor);">
      <tal:block condition="python:source_title.lower() == 'eionet'" >
        <a rel="external"
        tal:attributes="href string:https://www.eionet.europa.eu/directory/user?uid=${user_quoted}"
        tal:content="username"/>
      </tal:block>
      <tal:block condition="python:source_title.lower() == 'local' and
                            here.checkPermissionPublishObjects()" >
        <a rel="external"
        tal:attributes="href string:${site_url}/admin_edituser_html?name=${user_quoted}&from=all"
        tal:content="username"/>
      </tal:block>
      <tal:block condition="python:source_title.lower() not in ['local', 'eionet'] or (source_title.lower() == 'local' and not here.checkPermissionPublishObjects())"
        content="username" />

</metal:block>

<metal:block define-macro="contributor_tr">
<tr tal:define="contributor here/contributor;
                submitter_name here/submitter_info/name|nothing;
                submitter_email here/submitter_info/email|nothing;
                auth_tool here/getAuthenticationTool;
                username python: submitter_name or auth_tool.name_from_userid(contributor) or contributor;
                user_quoted python:here.utUrlEncode(contributor);
                source_title python: auth_tool.source_name_from_userid(contributor);"
    tal:condition="python: here.display_contributor or here.checkPermissionEditObjects()">
    <th i18n:translate="">Contributor</th>
    <td>
        <tal:block condition="python:source_title.lower() == 'eionet'" >
          <a rel="external"
          tal:attributes="href string:https://www.eionet.europa.eu/directory/user?uid=${user_quoted}"
          tal:content="username"/>
        </tal:block>
        <tal:block condition="python:source_title.lower() == 'local' and
                              here.checkPermissionPublishObjects()" >
          <a rel="external"
          tal:attributes="href string:${site_url}/admin_edituser_html?name=${user_quoted}&from=all"
          tal:content="username"/>
        </tal:block>
        <tal:block condition="python:source_title.lower() not in ['local', 'eionet'] or (source_title.lower() == 'local' and not here.checkPermissionPublishObjects())"
          content="username" />
        <tal:block condition="python:submitter_email and here.checkPermissionPublishObjects()">
          <em>(<a tal:attributes="href string:mailto:${submitter_email}"
                   tal:content="submitter_email" />)</em></tal:block>
    </td>
</tr>
</metal:block>

<metal:block define-macro="action_buttons">
  <tal:block tal:condition="python:here.checkPermissionEditObject()">
  <div id="admin_this_folder"
     tal:define="versioning_available python:(here.isVersionable() and
                                              here.content_versioning_enabled)">
    <tal:block tal:condition="python:not here.hasVersion()">
      <a tal:condition="versioning_available"
         tal:attributes="href string:${here/absolute_url}/startVersion"
         ><span i18n:translate="">Checkout</span></a>
      <a tal:attributes="href string:${here/absolute_url}/edit_html"
         ><span i18n:translate="">Edit</span></a>
    </tal:block>
    <tal:block condition="versioning_available">
      <a tal:condition="python:here.hasVersion() and here.isVersionAuthor()"
         tal:attributes="href string:${here/absolute_url}/edit_html"
         ><span i18n:translate="">Version control</span></a>
      <tal:block condition="python:here.hasVersion() and not here.isVersionAuthor()">
        <strong i18n:translate="">This item has been checked out by another user</strong>
        <a tal:attributes="href string:${here/absolute_url}/discardVersion"
          onclick="return confirm(gettext('Are you sure?'))">
          <span i18n:translate="">Discard unpublished changes</span>
        </a>
      </tal:block>
    </tal:block>
    <a tal:condition="here/checkPermissionDeleteObject"
       tal:attributes="href string:${here/absolute_url}/deleteThis"
       onclick="return confirm(gettext('Are you sure?'))"
       ><span i18n:translate="">Delete</span></a>
    <a tal:condition="python:here.rstk['provides'](here, 'naaya.content.base.interfaces.INyContentObjectExport')"
       tal:attributes="href string:${here/absolute_url}/do_export"><span i18n:translate="">Download</span></a>
  </div>
  </tal:block>
</metal:block>

<metal:block define-macro="icon">
<img tal:define="icon python:here.rstk['get_object_view_info'](here)['icon']"
     tal:attributes="src icon/url; title icon/title; alt icon/title" />
</metal:block>
