Beispiel #1
0
 public function getStatusText($status = null)
 {
     if ($status == null) {
         $status = $this->status;
     }
     switch ($status) {
         case self::STATUS_RELEASE:
             return Module::t('articles', 'Release');
         case self::STATUS_EDITING:
             return Module::t('articles', 'Editing');
         default:
             return "Status #{$status}";
     }
 }
Beispiel #2
0
 public function init()
 {
     if (\Yii::$app instanceof \yii\console\Application) {
         $this->controllerNamespace = 'simplator\\articles\\commands';
     }
     parent::init();
     if (!count($this->_plugins)) {
         $this->setPlugins([]);
     }
     if (!strlen($this->title)) {
         $this->title = Module::t('articles', 'Articles');
     }
     //articlesAsset::register($view)->addLanguage($this->language, 'fileinput_locale_');
     $this->breadcrumbs = [];
     // custom initialization code goes here
 }
Beispiel #3
0
<?php

use yii\helpers\Html;
use simplator\articles\Module;
/* @var $this yii\web\View */
/* @var $model simplator\articles\models\Category */
$this->title = Module::t('articles', 'Create category');
$this->params['breadcrumbs'][] = ['label' => Module::t('articles', 'Categories'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="category-create">

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

    <?php 
echo $this->render('_form', ['model' => $model]);
?>

</div>
Beispiel #4
0
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="category-view">

    <h1><?php 
echo $this->title;
?>
</h1>
	<?php 
echo Html::a(Module::t('articles', 'Update'), ['update', 'id' => $model->id], ['class' => 'btn btn-success']);
?>
    
	<h1>Categories</h1>
	<?php 
echo Html::a(Module::t('articles', 'Create category'), ['category/create', 'p' => $model->id], ['class' => 'btn btn-success']);
?>
    <?php 
echo SortableListView::widget(['dataProvider' => $categories, 'itemView' => '_view', 'clientOptions' => ['placeholder' => "ui-state-highlight"]]);
?>
   
    <h1>Articles</h1>
	<?php 
echo Html::a(Module::t('articles', 'Create article'), ['article/create', 'p' => $model->id], ['class' => 'btn btn-success']);
?>
    <?php 
echo SortableListView::widget(['dataProvider' => $articles, 'itemView' => '../article/_view', 'clientOptions' => ['placeholder' => "ui-state-highlight"]]);
?>
   

</div>
Beispiel #5
0
<?php

use yii\helpers\Html;
use simplator\articles\Module;
/* @var $this yii\web\View */
/* @var $model simplator\articles\models\Category */
$this->title = Module::t('articles', 'Update category') . ': ' . $model->title;
$this->params['breadcrumbs'][] = ['label' => Module::t('articles', 'Categories'), 'url' => ['index']];
$this->params['breadcrumbs'][] = ['label' => $model->title, 'url' => ['view', 'id' => $model->id]];
$this->params['breadcrumbs'][] = Module::t('articles', 'Update');
?>
<div class="category-update">

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

    <?php 
echo $this->render('_form', ['model' => $model]);
?>

</div>
Beispiel #6
0
        $url = Url::to(['update', 'id' => $article->id]);
        $msg = Module::t('articles', 'Загружена текущая опубликованная версия, но есть более поздняя версия');
        $this->registerJs("var n = noty({type: 'information', text: '{$msg}', timeout: 15000});", 5);
    } else {
        if ($rev->id == $article->lastVersion->id) {
            $url = Url::to(['update', 'id' => $article->id, 'rev' => 'current']);
            $msg = Module::t('articles', 'Загружена последняя версия. Она имеет отличия от текущей опубликованной');
            $this->registerJs("var n = noty({type: 'information', text: '{$msg}', timeout: 15000});", 5);
        } else {
            if ($rev->role == Revision::ROLE_ARCHIVE) {
                $msg = Module::t('articles', 'Загружена архивная версия');
                $this->registerJs("var n = noty({type: 'information', text: '{$msg}', timeout: 15000});", 5);
            }
        }
    }
}
?>
<div class="article-update">

    <h1><?php 
echo Module::t('articles', 'Update article');
?>
</h1>

    <?php 
echo $this->render('_form', ['rev' => $rev]);
?>

	
</div>
 public function actionRevrestore($id, $rev)
 {
     Yii::$app->response->format = Response::FORMAT_JSON;
     $rev = Revision::findOne($rev);
     if (!$rev || $rev->articleid != intval($id)) {
         throw new NotFoundHttpException(\Yii::t('yii', 'Page not found.'));
     }
     if (!\Yii::$app->user->can('articles.article.update', ['model' => $rev->article])) {
         $this->accessDenied();
     }
     $this->checkLock($rev->article);
     if ($rev->role != Revision::ROLE_DELETED) {
         return ['error' => Module::t('article', 'Version not deleted')];
     }
     $rev->role = Revision::ROLE_SAVE;
     if ($rev->delete()) {
         return ['success' => Module::t('articles', 'Version restored')];
     } else {
         return ['error' => 'Error restore'];
     }
 }
Beispiel #8
0
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']);
}], 'urlCreator' => function ($action, $model, $key, $index) {
    switch ($action) {
        case 'update':
            return Url::to(['update', 'id' => $model->articleid, 'rev' => $model->id]);
        case 'delete':
            return Url::to(['revdel', 'id' => $model->articleid, 'rev' => $model->id]);
        case 'view':
        default:
            return Url::to(['preview', 'id' => $model->articleid, 'rev' => $model->id]);
    }
}]]]);
?>
Beispiel #9
0
echo $form->field($model, 'parentid')->dropDownList(ArrayHelper::merge([0 => Module::t('articles', '- New root -')], $model->allparents));
?>

    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => 256]);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => 128]);
?>

    <?php 
echo $form->field($model, 'thumbnailid')->textInput();
?>

	<?php 
echo $form->errorSummary($model);
?>
	
    <div class="form-group">
        <?php 
echo Html::submitButton($model->isNewRecord ? Module::t('articles', 'Create') : Module::t('articles', 'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']);
?>
    </div>

    <?php 
ActiveForm::end();
?>

</div>
Beispiel #10
0
<?php

use yii\helpers\Html;
use simplator\articles\Module;
/* @var $this yii\web\View */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Module::t('articles', 'Categories');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="category-index">

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

    <?php 
echo yii\widgets\ListView::widget(['dataProvider' => $categories, 'itemView' => '_rootview']);
?>

</div>
Beispiel #11
0
 /**
  * @inheritdoc
  */
 public function attributeLabels()
 {
     return ['id' => Module::t('articles', 'ID'), 'articleid' => Module::t('articles', 'Articleid'), 'title' => Module::t('articles', 'Title'), 'snippet' => Module::t('articles', 'Snippet'), 'status' => Module::t('articles', 'Status'), 'content' => Module::t('articles', 'Content'), 'diff' => Module::t('articles', 'Diff'), 'tags' => Module::t('articles', 'Tags'), 'thumbnailid' => Module::t('articles', 'Thumbnail'), 'authorid' => Module::t('articles', 'Authorid'), 'role' => Module::t('articles', 'Role'), 'roleText' => Module::t('articles', 'Role'), 'updated_at' => Module::t('articles', 'Updated at'), 'published_at' => Module::t('articles', 'Published at'), 'revisions' => Module::t('articles', 'Revisions'), 'options' => Module::t('articles', 'Options')];
 }