예제 #1
0
<?php

use yii\helpers\Url;
use yii\helpers\Html;
use yii\grid\GridView;
use simplator\articles\Module;
use simplator\base\components\LinkColumn;
/* @var $this yii\web\View */
/* @var $revisions yii\data\ActiveDataProvider */
?>
<div class="article-revisions">

    <?php 
echo GridView::widget(['dataProvider' => $revisions, 'formatter' => ['class' => 'yii\\i18n\\Formatter', 'nullDisplay' => ''], 'columns' => ['id', ['class' => LinkColumn::className(), 'attribute' => 'roleText', 'url' => ['update'], 'params' => ['id' => 'articleid', 'rev' => 'id']], 'updated_at:datetime', ['attribute' => 'published_at', 'format' => 'datetime'], ['class' => LinkColumn::className(), 'attribute' => 'author.username', 'url' => ['/user/profile/show'], 'params' => ['id' => 'authorid']], ['label' => Module::t('articles', 'Diff'), 'format' => 'raw', 'value' => function ($data) {
    $r = Html::tag('b', intval($data->diff['c']), ['style' => 'color: black']) . ' ';
    $r .= Html::tag('b', '=' . intval($data->diff['=']), ['style' => 'color: black']) . ' ';
    $r .= Html::tag('b', '~' . intval($data->diff['~']), ['style' => 'color: blue']) . ' ';
    $r .= Html::tag('b', '+' . intval($data->diff['+']), ['style' => 'color: green']) . ' ';
    $r .= Html::tag('b', '-' . intval($data->diff['-']), ['style' => 'color: red']);
    $tt = Module::t('articles', 'Total words') . ': ' . intval($data->diff['c']) . "\n";
    $tt .= Module::t('articles', 'Unchanged') . ': ' . intval($data->diff['=']) . "\n";
    $tt .= Module::t('articles', 'Replaced') . ': ' . intval($data->diff['~']) . "\n";
    $tt .= Module::t('articles', 'Added') . ': ' . intval($data->diff['+']) . "\n";
    $tt .= Module::t('articles', 'Removed') . ': ' . intval($data->diff['-']);
    return Html::tag('span', $r, ['class' => 'diff', 'title' => $tt]);
}], ['class' => 'yii\\grid\\ActionColumn', 'template' => '{view} {diff} {update} {delete}', 'buttons' => ['view' => function ($url, $model) {
    return \yii\helpers\Html::a('<span class="glyphicon glyphicon-eye-open"></span>', $url, ['title' => Module::t('articles', 'Preview'), 'target' => '_blank']);
}, 'diff' => function ($url, $model) {
    return \yii\helpers\Html::a('<span class="glyphicon glyphicon-duplicate"></span>', $url, ['title' => Module::t('articles', 'Compare'), 'target' => '_blank']);
}, 'delete' => function ($url, $model) {
    return \yii\helpers\Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['title' => Yii::t('yii', 'Delete'), 'data-revdel' => '0']);
예제 #2
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
use simplator\articles\Module;
use simplator\base\components\LinkColumn;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('app', 'Articles');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="article-index">

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

    <p>
        <?php 
echo Html::a(Module::t('articles', 'Create Article'), ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'columns' => ['id', ['class' => LinkColumn::className(), 'attribute' => 'title', 'url' => ['/articles/article/view'], 'params' => ['id' => 'id']], 'snippet:ntext', 'authorid', 'status', 'updated_at:datetime', ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>