Ejemplo n.º 1
0
?>
</li>
                    </ul>
                </div>
            </nav>
        </div>
    </div>

    <?php 
$arr_widget = ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\DataColumn', 'attribute' => 'title', 'format' => 'html', 'value' => function (\app\modules\yiipass\models\Password $password) {
    return Html::a($password->title, ['view?id=' . $password->id]);
}], 'group', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{copy}', 'buttons' => ['copy' => function ($url, $model, $key) {
    return '<button type="button" class="copy_username copy_button"
                                            data-toggle="modal" data-target="#mobileCopyModal"
                                            data-username="******"
                                            data-password="******"
                                            data-title="' . $model->title . '"
                                            title="Copy details">Copy</button>';
}]], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{update}', 'buttons' => ['open_url' => function ($url, $model, $key) {
    if ($model->url !== '') {
        return '<a href="' . $model->url . '" title="Open URL in new window" target="_blank">Open URL</a>';
    }
}]]]];
/**
 * If checkboxes will be needed, comment the following line in.
 * Increase then the array key of columns.
 */
// array_unshift($arr_widget['columns'], ['class' => 'yii\grid\CheckboxColumn']);
$arr_widget['columns'][] = ['class' => 'yii\\grid\\ActionColumn', 'template' => '{delete}', 'buttons' => ['open_url' => function ($url, $model, $key) {
    if ($model->url !== '') {
        return '<a href="' . $model->url . '" title="Open URL in new window" target="_blank">Open URL</a>';
Ejemplo n.º 2
0
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use app\modules\yiipass\controllers\PasswordController;
/* @var $this yii\web\View */
/* @var $model app\models\Password */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => 'Passwords', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
// Make password visible.
$model->password = PasswordController::decrypt($model->password);
$debug = true;
?>
<div class="password-view">

    <h1><?php 
echo Html::encode($this->title);
?>
</h1>

    <p>
        <?php 
echo Html::a('Update', ['update', 'id' => $model->id], ['class' => 'btn btn-primary']);
?>
        <?php 
echo Html::a('Delete', ['delete', 'id' => $model->id], ['class' => 'btn btn-danger', 'data' => ['confirm' => 'Are you sure you want to delete this item?', 'method' => 'post']]);
?>
    </p>

    <?php 
Ejemplo n.º 3
0
    </div>

    <?php 
$arr_widget = ['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\DataColumn', 'attribute' => 'title', 'format' => 'html', 'value' => function (\app\modules\yiipass\models\Password $password) {
    return Html::a($password->title, ['view?id=' . $password->id]);
}], 'group', ['class' => 'yii\\grid\\ActionColumn', 'template' => '{open_url} {copy_username} {copy_password} {update}', 'buttons' => ['open_url' => function ($url, $model, $key) {
    if ($model->url !== '') {
        return '<a href="' . $model->url . '" title="Open URL in new window" target="_blank">Open URL</a>';
    }
}, 'copy_username' => function ($url, $model, $key) {
    if ($model->username !== '') {
        return '<button type="button" class="copy_username copy_button" data-clipboard-text="' . $model->username . '" title="Click to copy me.">Copy Username</button>';
    }
}, 'copy_password' => function ($url, $model, $key) {
    if ($model->password !== '') {
        return '<button type="button" class="copy_password copy_button" data-clipboard-text="' . PasswordController::decrypt($model->password) . '" title="Click to copy me.">Copy Password</button>';
    }
}]]]];
// If user is admin, set checkbox column at the beginning of the columns.
if (Yii::$app->user->identity->is_admin) {
    /**
     * If checkboxes will be needed, comment the following line in.
     * Increase then the array key of columns.
     */
    // array_unshift($arr_widget['columns'], ['class' => 'yii\grid\CheckboxColumn']);
    $arr_widget['columns']['2']['template'] .= '{delete} ';
}
?>

    <?php 
echo CustomGridViewService::widget($arr_widget);