<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" 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"
      metal:use-macro="context/main_template/macros/master"
      i18n:domain="plone">

<head>
    <metal:js fill-slot="javascript_head_slot">
        <script type="text/javascript"
              src=""
              tal:attributes="src string:${context/portal_url}/login.js">
      </script>
    </metal:js>
    <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>
    
    <metal:header fill-slot="header">
        <dl class="portalMessage error"
            id="enable_cookies_message"
            style="display:none">
            <dt i18n:translate="">
                Error
            </dt>
            <dd i18n:translate="enable_cookies_message_before_login">
                Cookies are not enabled. You must enable cookies before you can log in.
            </dd>
        </dl>
    </metal:header>

    <metal:main fill-slot="main"
         tal:define="auth nocall:context/acl_users/credentials_cookie_auth|context/cookie_authentication|nothing;
                     came_from request/came_from|request/HTTP_REFERER|nothing;
                     came_from python:test(context.portal_url.isURLInPortal(came_from), came_from, None);
                     errors options/state/getErrors;
                     ac_name auth/name_cookie|string:__ac_name;
                     ac_password auth/pw_cookie|string:__ac_password;
                     ac_persist auth/persist_cookie|nothing;
                     login_name python:request.get('login_name', request.get(ac_name, ''));">
    <div id="content-core">
        <div tal:condition="python: not auth" i18n:translate="login_form_disabled">
            Since cookie authentication is disabled, cookie-based login is not available.
        </div>
        <metal:login define-macro="login"
            tal:define="checkPermission nocall: context/portal_membership/checkPermission;
                        site_properties context/portal_properties/site_properties;
                        use_email_as_login site_properties/use_email_as_login|nothing;
                        ztu modules/ZTUtils;">
            <form tal:attributes="action python:context.absolute_url()+'/'+template.id"
                  class="enableAutoFocus"
                  method="post"
                  id="login_form"
                  tal:condition="python:auth">

                <div id="login-form">

                    <input type="hidden"
                        name="came_from"
                        value=""
                    tal:attributes="value came_from" />

                    <input type="hidden" name="form.submitted" value="1" />
                    <input type="hidden" name="js_enabled" id="js_enabled" value="0" />
                    <input type="hidden" name="cookies_enabled" id="cookies_enabled" value="" />
                    <input type="hidden" name="login_name" id="login_name" value="" />
                    <input type="hidden" name="pwd_empty" id="pwd_empty" value="0" />

                    <div class="field"
                         tal:define="error python:errors.get(ac_name, None);"
                         tal:attributes="class python:test(error, 'field error', 'field')">

                        <label i18n:translate="label_login_name"
                               tal:condition="not:use_email_as_login"
                               tal:attributes="for ac_name">Login Name</label>

                        <label i18n:translate="label_email"
                               tal:condition="use_email_as_login"
                               tal:attributes="for ac_name">E-mail</label>

                        <div tal:condition="error"
                             tal:content="error">Validation error output</div>

                        <input type="text"
                               size="15"
                               tal:attributes="name ac_name;
                                               id ac_name;
                                               value login_name;"
                               />

                </div>

                <div class="field"
                         tal:define="error python:errors.get(ac_password, None);"
                         tal:attributes="class python:test(error, 'field error', 'field')">

                        <label i18n:translate="label_password"
                               tal:attributes="for ac_password">Password</label>

                        <div tal:condition="error"
                             tal:content="error">Validation error output</div>

                        <input type="password"
                               size="15"
                               tal:attributes="name ac_password;
                                               id ac_password;"
                               />
                </div>

                    <div class="field" tal:condition="ac_persist">

                        <input type="checkbox"
                               class="noborder formRememberName"
                               value="1"
                               checked="checked"
                               id="cb_remember"
                               tal:attributes="name ac_persist;
                                               checked python:request.get(ac_name, '') and 'checked' or None;"
                               />

                        <tal:username tal:condition="not:use_email_as_login">
                        <label for="cb_remember" i18n:translate="label_remember_my_name">Remember my name.</label>

                        <div i18n:translate="help_remember_my_name"
                             class="formHelp">
                            Check this to have your user name filled in automatically when you log in later.
                        </div>
                        </tal:username>

                        <tal:email tal:condition="use_email_as_login">
                        <label for="cb_remember" i18n:translate="label_remember_my_email">Remember my email address.</label>

                        <div i18n:translate="help_remember_my_email"
                             class="formHelp">
                            Check this to have your email address filled in automatically when you log in later.
                        </div>
                        </tal:email>

                    </div>

                    <div class="formControls">

                        <input class="context"
                               type="submit"
                               name="submit"
                               value="Log in"
                               i18n:attributes="value label_log_in;"
                               />

                    </div>

                </div>

            </form>

            <div tal:condition="python:checkPermission('Mail forgotten password', context)">
                <strong i18n:translate="box_forgot_password_option">
                    Forgot your password?
                </strong>
                <p class="discreet"
                   i18n:translate="help_password_retrieval">
                    If you have forgotten your password,
                    <span i18n:name="click_here">
                        <a tal:attributes="href python:'mail_password_form?'+ztu.make_query(userid=login_name)"
                           i18n:translate="label_click_here_to_retrieve">we can send you a new one</a></span>.
                </p>
            </div>

            <div
               tal:define="actions python:context.portal_actions.listActionInfos('user/join', object=context);
                           join python:[a['url'] for a in actions];"
               tal:condition="python: join and checkPermission('Add portal member', context)">
                <h3 i18n:translate="heading_new_user">
                New user?
                </h3>

                <p i18n:translate="description_no_account">
                If you do not have an account here, head over to the
                <span i18n:name="registration_form">
                    <a href=""
                       tal:define="join python:join.pop();
                                   join join;
                                   join python:join+test(join.find('?')==-1, '?', '&amp;')+ztu.make_query(came_from=came_from);"
                       tal:attributes="href join"
                       i18n:translate="description_no_account_registration_linktext">
                        registration form</a></span>.
                </p>

            </div>

        </metal:login>
    </div>
    
    </metal:main>
</body>
</html>
