コード例 #1
0
ファイル: _grid.php プロジェクト: bigbrush/yii2-cmf
<?php

/**
 * @link http://www.bigbrush-agency.com/
 * @copyright Copyright (c) 2015 Big Brush Agency ApS
 * @license http://www.bigbrush-agency.com/license/
 */
use yii\helpers\Html;
use yii\grid\GridView;
use yii\bootstrap\Button;
use yii\bootstrap\ButtonGroup;
use bigbrush\cms\widgets\DeleteButton;
?>
<div class="table-responsive">
    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['header' => Yii::t('cms', 'Title'), 'format' => 'raw', 'value' => function ($data) {
    return str_repeat('<i class="fa fa-caret-right tree-indent"></i>', $data->depth - 1) . Html::a($data->title, ['edit', 'id' => $data->id]);
}], ['header' => Yii::t('cms', 'Default'), 'format' => 'raw', 'options' => ['width' => '1%'], 'contentOptions' => ['style' => 'text-align:center; vertical-align:middle;'], 'value' => function ($data) {
    return $data->is_default ? '<i class="fa fa-star"></i>' : '';
}], ['header' => Yii::t('cms', 'Ordering'), 'headerOptions' => ['style' => 'text-align:center; vertical-align:middle;'], 'format' => 'raw', 'options' => ['width' => '10%'], 'contentOptions' => ['style' => 'text-align:center; vertical-align:middle;'], 'value' => function ($data) {
    $options = ['class' => 'btn btn-default changeDirectionBtn', 'data-pid' => $data->id];
    return ButtonGroup::widget(['options' => ['class' => 'btn-group btn-group-xs'], 'buttons' => [Button::widget(['label' => '<i class="fa fa-arrow-up"></i>', 'encodeLabel' => false, 'options' => ['data-direction' => 'up'] + $options]), Button::widget(['label' => '<i class="fa fa-arrow-down"></i>', 'encodeLabel' => false, 'options' => ['data-direction' => 'down'] + $options])]]);
}], ['header' => Yii::t('cms', 'Delete'), 'format' => 'raw', 'options' => ['width' => '1%'], 'contentOptions' => ['style' => 'text-align:center; vertical-align:middle;'], 'value' => function ($data) {
    return DeleteButton::widget(['model' => $data, 'options' => ['class' => 'btn-xs']]);
}]]]);
?>
</div>
コード例 #2
0
ファイル: index.php プロジェクト: bigbrush/yii2-cmf
foreach ($types as $type => $name) {
    $dropdown[] = ['label' => $name, 'url' => ['install', 'type' => $type]];
}
$toolbar = Yii::$app->toolbar;
$toolbar->addButton(ButtonDropdown::widget(['label' => $toolbar->createText('plug', Yii::t('cms', 'Install {0}', Yii::t('cms', 'extension'))), 'options' => ['class' => 'btn btn-default'], 'encodeLabel' => false, 'dropdown' => ['items' => $dropdown]]));
$this->title = Yii::t('cms', 'Extensions');
?>
<div class="row">
    <div class="col-md-12">
        <h1><?php 
echo $this->title;
?>
</h1>
        <div class="table-responsive">
            <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['header' => Yii::t('cms', 'Name'), 'format' => 'raw', 'value' => function ($data) {
    return Html::a($data->name, ['edit', 'id' => $data->id]);
}], ['header' => Yii::t('cms', 'Type'), 'options' => ['width' => '15%'], 'value' => function ($data) {
    return Html::encode($data->getTypeText());
}], ['header' => Yii::t('cms', 'State'), 'options' => ['width' => '5%'], 'value' => function ($data) {
    return Html::encode($data->getStateText());
}], ['header' => Yii::t('cms', 'Delete'), 'format' => 'raw', 'options' => ['width' => '5%'], 'contentOptions' => ['style' => 'text-align:center; vertical-align:middle;'], 'value' => function ($data) {
    $popover = [];
    $popover[] = '<p>' . Yii::t('cms', 'Are you sure to delete this extension?') . '</p>';
    $popover[] = '<p><strong>' . Yii::t('cms', 'All related {type} are removed as well!', ['type' => Yii::t('cms', 'blocks')]) . '</strong></p>';
    return DeleteButton::widget(['model' => $data, 'options' => ['class' => 'btn-xs'], 'content' => implode("\n", $popover)]);
}]]]);
?>
        </div>
    </div>
</div>
コード例 #3
0
ファイル: config.php プロジェクト: bigbrush/yii2-cmf
?>

<div class="row">
    <div class="col-md-12">
        <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'tableOptions' => ['class' => 'table'], 'columns' => [['header' => Yii::t('cms', 'Name'), 'format' => 'raw', 'options' => ['style' => 'width: 20%;'], 'value' => function ($data) {
    return Html::input('text', '', $data['id'], ['class' => 'form-control input-sm', 'readonly' => 'readonly']);
}], ['header' => Yii::t('cms', 'Value'), 'format' => 'raw', 'value' => function ($data) {
    $icon = '<i class="fa fa-save"></i>';
    $html = Html::beginForm(['update', 'id' => $data['id'], 'section' => $data['section']]);
    $html .= '<div class="input-group">';
    $html .= '<span class="input-group-btn">';
    $html .= Html::submitButton($icon, ['class' => 'btn btn-default btn-sm']);
    $html .= '</span>';
    $html .= Html::input('text', 'Config[value]', $data['value'], ['class' => 'form-control input-sm']);
    $html .= '</div>';
    $html .= Html::hiddenInput('Config[id]', $data['id']);
    $html .= Html::hiddenInput('Config[section]', $data['section']);
    $html .= Html::endForm();
    return $html;
}], ['header' => Yii::t('cms', 'Delete'), 'options' => ['style' => 'width: 5%;'], 'format' => 'raw', 'value' => function ($data) {
    $fields = [];
    $fields[] = Html::hiddenInput('Config[id]', $data['id']);
    $fields[] = Html::hiddenInput('Config[value]', $data['value']);
    $fields[] = Html::hiddenInput('Config[section]', $data['section']);
    return DeleteButton::widget(['action' => ['delete', 'id' => $data['id'], 'section' => $data['section']], 'content' => implode("\n", $fields), 'options' => ['class' => 'btn btn-default btn-sm']]);
}]]]);
?>
    </div>
</div>
コード例 #4
0
ファイル: index.php プロジェクト: bigbrush/yii2-cmf
use yii\helpers\Html;
use yii\grid\GridView;
use bigbrush\cms\widgets\DeleteButton;
Yii::$app->toolbar->add();
$this->title = Yii::t('cms', 'Menus');
?>
<div class="row">
    <div class="col-md-12">
        <h1><?php 
echo $this->title;
?>
</h1>
    </div>
</div>
<div class="row">
    <div class="col-md-12">
        <div class="table-responsive">
            <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => [['header' => Yii::t('cms', 'Title'), 'format' => 'raw', 'value' => function ($data) {
    return Html::a($data->title, ['edit', 'id' => $data->id]);
}], ['header' => Yii::t('cms', 'Delete'), 'format' => 'raw', 'options' => ['width' => '1%'], 'contentOptions' => ['style' => 'text-align:center; vertical-align:middle;'], 'value' => function ($data) {
    $popover = [];
    $popover[] = '<p>' . Yii::t('cms', 'Are you sure to delete this menu?') . '</p>';
    $popover[] = '<p><strong>' . Yii::t('cms', 'All menu items are removed as well!') . '</strong></p>';
    return DeleteButton::widget(['model' => $data, 'options' => ['class' => 'btn-xs'], 'title' => '<div style="text-align: center;"><strong>' . Yii::t('cms', 'Are you sure?') . '</strong></div>', 'content' => implode("\n", $popover)]);
}]]]);
?>
        </div>
    </div>
</div>