Example #1
0
<?php

use yii\helpers\Html;
use yii\grid\GridView;
/* @var $this yii\web\View */
/* @var $searchModel backend\models\search\MessageSearch */
/* @var $dataProvider yii\data\ActiveDataProvider */
$this->title = Yii::t('common', 'Site Messages');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="message-index">

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

	<p>
		<?php 
echo Html::a(Yii::t('backend', 'Create {modelClass}', ['modelClass' => Yii::t('common', 'Site Messages')]), ['create'], ['class' => 'btn btn-success']);
?>
	</p>

	<?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], 'title', ['class' => \common\grid\EnumColumn::className(), 'attribute' => 'receive', 'enum' => \common\models\Message::getReceive()], 'created_at:datetime', ['class' => \common\grid\EnumColumn::className(), 'attribute' => 'status', 'enum' => \common\models\Message::getStatus()], ['class' => 'yii\\grid\\ActionColumn']]]);
?>

</div>
Example #2
0
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use yii\helpers\ArrayHelper;
/* @var $this yii\web\View */
/* @var $model common\models\Message */
$this->title = $model->title;
$this->params['breadcrumbs'][] = ['label' => Yii::t('common', 'Site Messages'), 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
//myVarDump(\common\models\Message::findUnreadMessagesByUserId(3));
//myVarDump(\common\models\Message::removeUnreadByUserId(3, 3));
?>
<div class="message-view">

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

	<?php 
echo DetailView::widget(['model' => $model, 'attributes' => ['title', ['attribute' => 'receive', 'value' => ArrayHelper::getValue(\common\models\Message::getReceive(), $model->receive)], 'unread:ntext', 'sender', 'created_at:datetime', 'updated_at:datetime', ['attribute' => 'status', 'value' => ArrayHelper::getValue(\common\models\Message::getStatus(), $model->status)], 'deleted', 'content:html']]);
?>

</div>
Example #3
0
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>

	<?php 
echo $form->field($model, 'receive')->dropDownList(\common\models\Message::getReceive());
?>

	<?php 
echo $form->field($model, 'content')->widget(\yii\imperavi\Widget::className(), ['plugins' => ['fullscreen', 'fontcolor', 'video', 'fontsize'], 'options' => ['lang' => 'zh', 'minHeight' => 400, 'maxHeight' => 400, 'buttonSource' => true, 'convertDivs' => false, 'removeEmptyTags' => false, 'imageUpload' => Yii::$app->urlManager->createUrl(['/file-storage/upload-imperavi'])]]);
?>

	<?php 
echo $form->field($model, 'sender')->hiddenInput(['value' => Yii::$app->user->identity->username])->label(false);
?>

    <?php 
echo $form->field($model, 'status')->dropDownList(\common\models\Message::getStatus());
?>

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

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

</div>