<?php defined('C5_EXECUTE') or die('Access denied.'); ?>

<div class="alert alert-info">
    <h4><?php echo t('Twitter Login Configuration'); ?></h4>
    <p><?php echo t('<a href="%s" target="_blank">Click here</a> to obtain your access keys.', 'https://apps.twitter.com/'); ?></p>
    <p><?php echo t('Check the box labeled "Allow this application to be used to Sign in with Twitter".'); ?></p>
    <p><?php echo t('Set the "Callback URL" to:%s.', ' <code>'.BASE_URL.DIR_REL.\URL::to('/system/authentication/twitter/callback').'</code>'); ?></p>
</div>

<div class='form-group'>
    <?php echo $form->label('apikey', t('Consumer Key (API Key)'))?>
    <?php echo $form->text('apikey', $apikey, array('autocomplete' => 'off'))?>
</div>
<div class='form-group'>
    <?php echo $form->label('apisecret', t('Consumer Secret (API Secret)'))?>
    <div class="input-group">
        <?php echo $form->password('apisecret', $apisecret, array('autocomplete' => 'off'))?>
        <span class="input-group-btn">
        <button id="showsecret" class="btn btn-warning" type="button"><?php echo t('Show API secret')?></button>
      </span>
    </div>
</div>
<div class='form-group'>
    <div class="input-group">
        <label type="checkbox">
            <input type="checkbox" name="registration_enabled" value="1" <?php echo \Config::get('auth.twitter.registration_enabled', false) ? 'checked' : '' ?>>
            <span style="font-weight:normal"><?php echo t('Allow automatic registration') ?></span>
        </label>
        </span>
    </div>
</div>

<script type="text/javascript">
    var button = $('#showsecret');
    button.click(function() {
        var apisecret = $('#apisecret');
        if(apisecret.attr('type') == 'password') {
            apisecret.attr('type', 'text');
            button.html('<?php echo addslashes(t('Hide API secret'))?>');
        } else {
            apisecret.attr('type', 'password');
            button.html('<?php echo addslashes(t('Show API secret'))?>');
        }
    });
</script>
