<?
/**
 * Copyright © 2012 Alcatel-Lucent.
 *
 * See the NOTICE file distributed with this work for additional information regarding copyright ownership. Licensed to you under the Apache License, Version 2.0 (the
 * "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
 * KIND, either express or implied.  See the License for the specific language governing permissions and limitations under the License.
 */

/**
 * @var Auth $auth
 */
$auths = $this->auths;

$addButtonTip = $this->translate("Add a new Auth");
$editLinkTip = $this->translate("Select to edit this Auth");
$deleteConfirmTitle = $this->translate("Are you sure?");
$deleteConfirmMessage = $this->translate("Click again to confirm");
$deleteConfirmOk = $this->translate("OK");
$deleteConfirmCancel = $this->translate("Cancel");

?>
<div class="container">
    <div class="hero-unit">
        <h1><? echo $this->translate("Auths")?></h1>
        <p><? echo $this->translate("Choose an Auth from the list below to edit")?></p>
    </div>
    <? if(!empty($this->messages)): ?>
    <div class="control-group success">
            <span class="help-block" id="messages">
                <? foreach ($this->messages as $message): ?>
                <?=$message?><br/>
                <? endforeach ?>
            </span>
    </div>
    <? endif ?>
    <div class="well">
        <div id="list">
            <div class="listItem">
                <div class="item-div pull-left"><span class="item1"><strong><? echo $this->translate("Auth ID")?></strong></span></div>
                <div class="item-div pull-left"><span class="item2"><strong><? echo $this->translate("Type")?></strong></span></div>
                <div class="item-div pull-left"><span class="item3"><strong><? echo $this->translate("Details")?></strong></span></div>
                <div class="item-div pull-left" align="center"><span class="item4">
                    <a href="/auth/create" class="btn btn-success"
                       rel="tooltip" title="<?=$addButtonTip?>" data-placement="right"><i class="icon-plus icon-white"></i></a>
                </div>
            </div>
            <? foreach($auths as $auth){?>
            <div class="listItem">
                <div class="item-div pull-left"><label class="item1" rel="tooltip" title="<?=$editLinkTip?>"><p>
                    <a id="<?=$auth->id?>" href="/auth/<?=$auth->id;?>" class="auth-link"><strong><?if(strlen($auth->id) > 15){ echo substr($auth->id, 0, 15) . "...";}else{ echo $auth->id;} ;?></strong></a>
                </p></label></div>
                <div class="item-div pull-left"><span class="item2"><p><?=$auth->type;?></p></span></div>
                <div class="item-div pull-left"><span class="item3"><p><?
                    switch($auth->type){
                        case AuthType::$BASIC:
                            echo $auth->basicAuth->username;
                            break;
                        case AuthType::$WSSE:
                            print $auth->wsseAuth->username;
                            break;
                        case AuthType::$AUTHKEY:
                            print $auth->authKeyAuth->keyValue;
                            break;
                        case AuthType::$IPWHITELIST:
                            echo $auth->ipWhiteListAuth->ips[0]."...";
                            break;
                    }?></p></span></div>
                <div class="item-div pull-left" align="center">
                      <span class="item4">
                      <a class="btn btn-danger delete" href="/auth/<?=$auth->id?>/delete" id="delete-<?=$auth->id?>"
                         confirm-title="<?=$deleteConfirmTitle?>" confirm-content="<?=$deleteConfirmMessage?>"
                         confirm-ok="<?=$deleteConfirmOk?>" confirm-cancel="<?=$deleteConfirmCancel?>"><? echo $this->translate("Delete")?></a>
                      </span>
                </div>
            </div>
            <?}?>
        </div>
    </div>
</div> <!-- /container -->
