login.phtml #1

  • //
  • guest/
  • thomas_gray/
  • jambox/
  • main/
  • swarm/
  • module/
  • Accounts/
  • view/
  • accounts/
  • index/
  • login.phtml
  • View
  • Commits
  • Open Download .zip Download (4 KB)
<?php
$this->headTitle()->set('Login');

$services = $this->getHelperPluginManager()->getServiceLocator();
$config   = $services->get('config');
?>
<?php if (isset($message)): ?>
    <div class="alert alert-block alert-<?php echo $message['type']; ?>">
        <button type="button" class="close" data-dismiss="alert">&times;</button>
        <?php echo $message['body']; ?>
    </div>
<?php endif ?>
<?php if (!$partial): ?>
  <div class="login-panel">
    <h1 class="center">Log in to Swarm</h1>
<?php endif ?>
<div class="<?php echo $partial ? 'modal hide fade' : '' ?> login-dialog">
  <form method="post" class="modal-form">
    <div class="modal-header">
      <button type="button" class="close" data-dismiss="modal">&times;</button>
      <h3>Log in</h3>
    </div>
    <div class="modal-body">
        <div class="control-group">
            <label for="user">Username or Email</label>
            <input type="text" id="user" name="user" class="span4" value="<?php echo $this->escapeHtmlAttr($user) ?>">
        </div>
        <div class="control-group">
            <label for="password">Password</label>
            <input type="password" id="password" name="password" class="span4" autocomplete="off">
        </div>
        <div class="control-group">
            <label class="checkbox" for="remember">
                <input type="checkbox" id="remember" name="remember" <?php echo $remember ? 'checked' : ''?>>Remember Me
            </label>
            <?php if (array_key_exists('p4_super', $config)
                && array_key_exists('accounts', $config) && array_key_exists('skip_email_validation', $config['accounts'])
                && $config['accounts']['skip_email_validation'] == false) : ?>
            <a href="<?= $this->url('resetPassword') ?>" class="reset">Reset password.</a>
            <?php endif; ?>
        </div>
    </div>
    <div class="modal-footer">
      <button type="submit" class="btn btn-mlarge btn-primary login">Log in</button>
      <?php if (array_key_exists('p4_super', $config)) : ?>
      <button type="button" class="btn btn-mlarge btn-info signup">Sign up</button>
      <?php endif; ?>
    </div>
  </form>
</div>
<?php if (!$partial): ?>
  <div class="links muted center">
    <a href="/docs/">Help</a>
  </div>
</div>
<?php endif ?>

<script type="text/javascript">
    $(function() {
        <?php if ($partial): ?>
            // focus first, empty, input on show
            $('.login-dialog').on('shown', function() {
                var user = $('input[name=user]', this);
                if (!user.val()) {

                    user.focus();
                } else {
                    $('input[name=password]', this).focus();
                }
            });

            swarm.modal.show('.login-dialog');
        <?php else: ?>
            // focus first, empty, input on show
            var user = $('.login-dialog input[name=user]');
            if (!user.val()) {
                user.focus();
            } else {
                $('.login-dialog input[name=password]').focus();
            }
        <?php endif ?>

        $('.login-dialog form').submit(function(e) {
            e.preventDefault();
            swarm.form.post(swarm.url('/login'), '.login-dialog form', function(response){
                if (response.isValid) {
                    <?php if ($partial): ?>
                        if ($('body').is('.login-reload')) {
                            return window.location.reload();
                        }
                        $(document).trigger($.extend($.Event('swarm-login'), {
                            user:    response.user,
                            toolbar: response.toolbar,
                            csrf:    response.csrf
                        }));
                        $('.login-dialog').modal('hide');
                        window.location.reload();
                    <?php elseif ($statusCode === 401): ?>
                        // try reloading the active page after login if the
                        // initial page load had an 'unauthorized' statusCode
                        window.location.reload();
                    <?php else: ?>
                        // redirect the user to the homepage
                        window.location = "<?php echo $this->url('home') ?>";
                    <?php endif ?>
                }
            }, '.login-dialog .modal-body');
        });
    });
</script>
# Change User Description Committed
#1 18334 Liz Lam initial add of jambox