<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en"
      xmlns:tal="http://xml.zope.org/namespaces/tal"
      xmlns:metal="http://xml.zope.org/namespaces/metal"
      xmlns:i18n="http://xml.zope.org/namespaces/i18n"
      lang="en"
      metal:use-macro="context/main_template/macros/master"
      i18n:domain="plone">

<head>
    <metal:block fill-slot="top_slot"
                 tal:define="dummy python:request.set('disable_border',1);
                             disable_column_one python:request.set('disable_plone.leftcolumn',1);
                             disable_column_two python:request.set('disable_plone.rightcolumn',1);" />
</head>

<body>

<tal:comment replace="nothing">
    Please note that this template fills the "content" slot instead of the
    "main" slot, this is done so we can provide stuff like the content
    tabs. This also means that we have to supply things that are normally
    present from main_template.
</tal:comment>

<metal:main fill-slot="content"
    tal:define="errors options/state/getErrors;">
    <tal:main-macro metal:define-macro="main"
                    tal:define="site_properties here/portal_properties/site_properties;
                                allowAnonymousViewAbout python:site_properties.getProperty('allowAnonymousViewAbout', True);
                                isAnon context/@@plone_portal_state/anonymous;
                                raiseUnauthorized python:(not isAnon or allowAnonymousViewAbout) or here.raiseUnauthorized();
                                url_unquote_plus python:modules['Products.PythonScripts.standard'].url_unquote_plus;
                                author python:(len(request.traverse_subpath) > 0 and url_unquote_plus(request.traverse_subpath[0])) or request.get('author', None);
                                mtool python:context.portal_membership;
                                portrait python: mtool.getPersonalPortrait(author);
                                portal_types context/portal_types;
                                authorinfo python: mtool.getMemberInfo(author);
                                portal_url context/@@plone_portal_state/navigation_root_url;
                                here_url context/@@plone_context_state/object_url;
                                member context/@@plone_portal_state/member;
                                portal context/@@plone_portal_state/portal;
                                email_from_address portal/email_from_address">

        <tal:noAuthor condition="not: authorinfo">
            <dl class="portalMessage error">
                <dt i18n:translate="">
                    Error
                </dt>
                <dd i18n:translate="text_no_user_by_name">
                    No user by that name.
                </dd>
            </dl>
            <div id="content">
                &nbsp;
            </div>
        </tal:noAuthor>


        <tal:haveAuthor condition="authorinfo"
            tal:define="isOwner python:member.getId()==author;
                        isAnon context/@@plone_portal_state/anonymous;">

            <div id="edit-bar" tal:condition="isOwner">
                <h5 class="hiddenStructure">Views</h5>
                <ul id="content-views"
                    class="contentViews">
                  <li class="selected">
                    <a href=""
                        tal:define="url_quote_plus python:modules['Products.PythonScripts.standard'].url_quote_plus;
                                    memberurl python:url_quote_plus(member.getId())"
                       tal:attributes="href string:${portal_url}/author/${memberurl}"
                       i18n:translate="label_view">View</a>
                  </li>
                  <li>
                    <a href=""
                       tal:attributes="href string:${portal_url}/@@personal-information"
                       i18n:translate="label_edit">Edit</a>
                  </li>
                </ul>
                <div class="contentActions">&nbsp;</div>
                 <!-- end simulated tabs -->
            </div>


            <div metal:use-macro="context/global_statusmessage/macros/portal_message">
                Portal status message
            </div>

            <div id="content">
                <!-- Author information -->
                <h1 class="documentFirstHeading" tal:condition="authorinfo/fullname" tal:content="authorinfo/fullname">
                    Author name
                </h1>

                <h1 class="documentFirstHeading" tal:condition="not: authorinfo/fullname" tal:content="author">
                    Author ID
                </h1>

                <div class="documentDescription" tal:content="authorinfo/description">
                    Author description.
                </div>

                <div id="content-core">
                    <div class="discreet">
                        <tal:location condition="authorinfo/location"
                                      i18n:translate="text_location">
                            Location:
                            <span tal:content="authorinfo/location"
                                  tal:omit-tag=""
                                  i18n:name="location">
                                Some location
                            </span>
                        </tal:location>

                        <tal:language condition="authorinfo/language">
                        &mdash;
                        <span i18n:translate="label_main_language">Main Language:</span>
                        <span tal:replace="authorinfo/language">Some language</span>
                        </tal:language>
                    </div>

                    <img src=""
                         alt=""
                         class="portraitPhoto"
                         width="75"
                         style="float: left; margin: 1em;"
                         tal:attributes="src portrait/absolute_url" />

                    <div class="visualClear"><!-- --></div>

                    <p tal:condition="python:mtool.getHomeFolder(id=author)">
                    <a href="#" tal:attributes="href python:mtool.getHomeFolder(id=author).absolute_url()"
                       i18n:translate="label_author_internal_home_page">Author's home page in this site&hellip;</a>
                    </p>

                    <p tal:condition="python: not mtool.getHomeFolder(id=author) and authorinfo['home_page']">
                    <a href="#"
                       rel="nofollow"
                       tal:attributes="href authorinfo/home_page"
                       i18n:translate="label_author_external_home_page">Author's external home page&hellip;</a>
                    </p>

                    <tal:noemailsetup tal:condition="python:not (email_from_address or isAnon)">
                        <p class="discreet"
                           i18n:translate="text_no_email_setup">
                            This site doesn't have a valid email setup, so you cannot use
                            any contact forms.
                        </p>
                    </tal:noemailsetup>

                    <tal:noemail tal:condition="python:not isAnon and not member.getProperty('email')">
                        <p class="discreet"
                           i18n:translate="text_no_member_email">
                            You do not have an email address, so you
                            cannot use any contact forms. Please edit
                            your personal information.
                        </p>
                    </tal:noemail>

                    <tal:mailsetup tal:condition="python:email_from_address and authorinfo['has_email']">

                        <div class="formControls" tal:condition="isAnon">
                        <form
                          tal:define="pss modules/Products/PythonScripts/standard"
                          tal:attributes="action string:$portal_url/login">
                           <input class="standalone"
                               type="submit"
                               value="Log in to send feedback"
                               i18n:attributes="value label_login_to_send_feedback;"
                               />
                        </form>
                        </div>

                        <!-- feedback form -->


                        <tal:owner tal:condition="python: not isOwner and not isAnon and member.getProperty('email')">
                            <p class="discreet"
                               i18n:translate="description_author_feedback">
                                If you want to contact this author, fill in the form
                                below.
                            </p>

                            <form name="feedback_form"
                                  action=""
                                  method="post"
                                  tal:attributes="action string:$here_url/${template/getId}">

                            <fieldset>

                            <legend i18n:translate="legend_feedback_for_author">Feedback for author</legend>

                            <div class="field"
                              tal:define="error errors/subject|nothing"
                              tal:attributes="class python:test(error, 'field error', 'field')">
                              <label for="subject" i18n:translate="label_subject">
                                Subject
                              </label>

                              <span class="fieldRequired" title="Required"
                                      i18n:attributes="title title_required;"
                                      i18n:translate="label_required">(Required)</span>

                              <br />
                              <input type="text"
                                     id="subject"
                                     name="subject"
                                     size="25"
                                     value=""
                                     tal:attributes="value request/subject|nothing"
                                     />
                            </div>
                            <div class="field"
                              tal:define="error errors/message|nothing"
                              tal:attributes="class python:test(error, 'field error', 'field')">
                              <label for="message" i18n:translate="label_message">
                                Message
                              </label>

                              <span class="fieldRequired" title="Required"
                                      i18n:attributes="title title_required;"
                                      i18n:translate="label_required">(Required)</span>

                              <textarea name="message"
                                        id="message"
                                        rows="5"
                                        cols="25"
                                        tal:content="request/message|nothing"
                                        ></textarea>
                            </div>

                            <div class="formControls">

                                <input class="context"
                                       type="submit"
                                       name="form.button.Send"
                                       value="Send"
                                       i18n:attributes="value label_send;" />

                            </div>

                            </fieldset>

                            <input type="hidden" name="author" value="" tal:attributes="value author" />
                            <input type="hidden" name="referer" value=""
                              tal:attributes="value python:request.get('referer', request.get('HTTP_REFERER', 'unknown url') )" />
                            <input type="hidden" name="form.submitted" value="1" />

                            </form>
                        </tal:owner>
                    </tal:mailsetup>

                    <!-- listing of content created by this user -->
                    <tal:authorContent define="author_content python:context.portal_catalog.searchResults(dict(Creator=author, sort_on='created', sort_order='reverse'))[:10];"
                                       condition="author_content">

                        <h2 i18n:translate="heading_author_content">
                            Latest content created by this user
                        </h2>

                        <div metal:define-macro="user_content_listing">
                        <table class="vertical listing"
                               summary="Lists content written by an author grouped by content type"
                               i18n:attributes="summary summary_author_content_list;">
                            <tal:repeat repeat="item author_content">
                                <tr>
                                    <th tal:define="toLocalizedTime nocall: context/@@plone/toLocalizedTime;"
                                        tal:content="python:toLocalizedTime(item.Date)"
                                        style="white-space: nowrap">
                                        Date
                                    </th>
                                    <td>
                                        <a href="" tal:attributes="href item/getURL"
                                           tal:content="item/pretty_title_or_id">title</a>
                                    </td>
                                </tr>
                            </tal:repeat>
                        </table>
                        </div>

                        <p>
                        <a href=""
                           tal:attributes="href string:$here_url/search?Creator=${author}&amp;sort_on=created&amp;sort_order=reverse"
                           i18n:translate="go_to_search_author_content">
                            All content created by
                            <span i18n:name="user" tal:omit-tag="" tal:content="python:authorinfo['fullname'] or author"/>&hellip;
                        </a>
                        </p>

                    </tal:authorContent>
                </div>
            </div>



            </tal:haveAuthor>

    </tal:main-macro>

</metal:main>

</body>
</html>
