Commit 1a7272ce by jomon

code review changes

parent 71b55384
......@@ -12,38 +12,34 @@ use yii\widgets\ActiveForm;
<?php $form = ActiveForm::begin(); ?>
<div id="myTabContent" class="tab-content">
<div class="tab-pane fade in active" id="info">
<div class="page-header">
<h3>Info</h3>
</div>
<div class="row">
<div class="col-md-6">
<?php echo $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class="row">
<div class="col-md-6">
<?php echo $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class="row">
<div class="col-md-3">
<?= $form->field($model, 'status')->dropDownList($model::statuses()) ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend',
'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<div class="row">
<div class="col-md-6">
<?= $form->field($model, 'name')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class="row">
<div class="col-md-6">
<?= $form->field($model, 'slug')->textInput(['maxlength' => true]) ?>
</div>
</div>
<div class="row">
<div class="col-md-3">
<?= $form->field($model, 'status')->dropDownList($model::statuses()) ?>
</div>
</div>
<div class="form-group">
<?= Html::submitButton($model->isNewRecord ? Yii::t('backend', 'Create') : Yii::t('backend',
'Update'), ['class' => $model->isNewRecord ? 'btn btn-success' : 'btn btn-primary']) ?>
</div>
<?php ActiveForm::end(); ?>
</div>
......@@ -10,6 +10,7 @@ use yii\grid\GridView;
$this->title = Yii::t('backend', 'States');
$this->params['breadcrumbs'][] = $this->title;
?>
<div class="state-index">
<h1><?= Html::encode($this->title) ?></h1>
......@@ -18,6 +19,7 @@ $this->params['breadcrumbs'][] = $this->title;
<p>
<?= Html::a(Yii::t('backend', 'Create State'), ['create'], ['class' => 'btn btn-success']) ?>
</p>
<?= GridView::widget([
'dataProvider' => $dataProvider,
'filterModel' => $searchModel,
......@@ -41,4 +43,5 @@ $this->params['breadcrumbs'][] = $this->title;
['class' => 'yii\grid\ActionColumn'],
],
]); ?>
</div>
......@@ -48,13 +48,17 @@ $bundle = BackendAsset::register($this);
</span>
</a>
<ul class="dropdown-menu">
<li class="header"><?= Yii::t('backend', 'You have {num} log items', ['num' => \backend\models\SystemLog::find()->count()]) ?></li>
<li class="header"><?= Yii::t('backend', 'You have {num} log items',
['num' => \backend\models\SystemLog::find()->count()]) ?></li>
<li>
<!-- inner menu: contains the actual data -->
<ul class="menu">
<?php foreach (\backend\models\SystemLog::find()->orderBy(['log_time' => SORT_DESC])->limit(5)->all() as $logEntry): ?>
<li>
<a href="<?= Yii::$app->urlManager->createUrl(['/log/view', 'id' => $logEntry->id]) ?>">
<a href="<?= Yii::$app->urlManager->createUrl([
'/log/view',
'id' => $logEntry->id
]) ?>">
<i class="fa fa-warning <?= $logEntry->level == \yii\log\Logger::LEVEL_ERROR ? 'text-red' : 'text-yellow' ?>"></i>
<?= $logEntry->category ?>
</a>
......@@ -71,7 +75,8 @@ $bundle = BackendAsset::register($this);
<li class="dropdown user user-menu">
<a href="#" class="dropdown-toggle" data-toggle="dropdown">
<img
src="<?= Yii::$app->user->identity->userProfile->getAvatar($this->assetManager->getAssetUrl($bundle, 'img/anonymous.jpg')) ?>"
src="<?= Yii::$app->user->identity->userProfile->getAvatar($this->assetManager->getAssetUrl($bundle,
'img/anonymous.jpg')) ?>"
class="user-image">
<span><?= Yii::$app->user->identity->username ?> <i class="caret"></i></span>
</a>
......@@ -79,24 +84,29 @@ $bundle = BackendAsset::register($this);
<!-- User image -->
<li class="user-header light-blue">
<img
src="<?= Yii::$app->user->identity->userProfile->getAvatar($this->assetManager->getAssetUrl($bundle, 'img/anonymous.jpg')) ?>"
src="<?= Yii::$app->user->identity->userProfile->getAvatar($this->assetManager->getAssetUrl($bundle,
'img/anonymous.jpg')) ?>"
class="img-circle" alt="User Image"/>
<p>
<?= Yii::$app->user->identity->username ?>
<small>
<?= Yii::t('backend', 'Member since {0, date, short}', Yii::$app->user->identity->created_at) ?>
<?= Yii::t('backend', 'Member since {0, date, short}',
Yii::$app->user->identity->created_at) ?>
</small>
</li>
<!-- Menu Footer-->
<li class="user-footer">
<div class="pull-left">
<?= Html::a(Yii::t('backend', 'Profile'), ['/sign-in/profile'], ['class' => 'btn btn-default btn-flat']) ?>
<?= Html::a(Yii::t('backend', 'Profile'), ['/sign-in/profile'],
['class' => 'btn btn-default btn-flat']) ?>
</div>
<div class="pull-left">
<?= Html::a(Yii::t('backend', 'Account'), ['/sign-in/account'], ['class' => 'btn btn-default btn-flat']) ?>
<?= Html::a(Yii::t('backend', 'Account'), ['/sign-in/account'],
['class' => 'btn btn-default btn-flat']) ?>
</div>
<div class="pull-right">
<?= Html::a(Yii::t('backend', 'Logout'), ['/sign-in/logout'], ['class' => 'btn btn-default btn-flat', 'data-method' => 'post']) ?>
<?= Html::a(Yii::t('backend', 'Logout'), ['/sign-in/logout'],
['class' => 'btn btn-default btn-flat', 'data-method' => 'post']) ?>
</div>
</li>
</ul>
......@@ -116,11 +126,13 @@ $bundle = BackendAsset::register($this);
<div class="user-panel">
<div class="pull-left image">
<img
src="<?= Yii::$app->user->identity->userProfile->getAvatar($this->assetManager->getAssetUrl($bundle, 'img/anonymous.jpg')) ?>"
src="<?= Yii::$app->user->identity->userProfile->getAvatar($this->assetManager->getAssetUrl($bundle,
'img/anonymous.jpg')) ?>"
class="img-circle"/>
</div>
<div class="pull-left info">
<p><?= Yii::t('backend', 'Hello, {username}', ['username' => Yii::$app->user->identity->getPublicIdentity()]) ?></p>
<p><?= Yii::t('backend', 'Hello, {username}',
['username' => Yii::$app->user->identity->getPublicIdentity()]) ?></p>
<a href="<?= Url::to(['/sign-in/profile']) ?>">
<i class="fa fa-circle text-success"></i>
<?= Yii::$app->formatter->asDatetime(time()) ?>
......@@ -151,12 +163,36 @@ $bundle = BackendAsset::register($this);
'icon' => '<i class="fa fa-edit"></i>',
'options' => ['class' => 'treeview'],
'items' => [
['label' => Yii::t('backend', 'Static pages'), 'url' => ['/page/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'],
['label' => Yii::t('backend', 'Articles'), 'url' => ['/article/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'],
['label' => Yii::t('backend', 'Article Categories'), 'url' => ['/article-category/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'],
['label' => Yii::t('backend', 'Text Widgets'), 'url' => ['/widget-text/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'],
['label' => Yii::t('backend', 'Menu Widgets'), 'url' => ['/widget-menu/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'],
['label' => Yii::t('backend', 'Carousel Widgets'), 'url' => ['/widget-carousel/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'],
[
'label' => Yii::t('backend', 'Static pages'),
'url' => ['/page/index'],
'icon' => '<i class="fa fa-angle-double-right"></i>'
],
[
'label' => Yii::t('backend', 'Articles'),
'url' => ['/article/index'],
'icon' => '<i class="fa fa-angle-double-right"></i>'
],
[
'label' => Yii::t('backend', 'Article Categories'),
'url' => ['/article-category/index'],
'icon' => '<i class="fa fa-angle-double-right"></i>'
],
[
'label' => Yii::t('backend', 'Text Widgets'),
'url' => ['/widget-text/index'],
'icon' => '<i class="fa fa-angle-double-right"></i>'
],
[
'label' => Yii::t('backend', 'Menu Widgets'),
'url' => ['/widget-menu/index'],
'icon' => '<i class="fa fa-angle-double-right"></i>'
],
[
'label' => Yii::t('backend', 'Carousel Widgets'),
'url' => ['/widget-carousel/index'],
'icon' => '<i class="fa fa-angle-double-right"></i>'
],
]
],
[
......@@ -182,8 +218,16 @@ $bundle = BackendAsset::register($this);
'visible' => Yii::$app->user->can('administrator'),
'options' => ['class' => 'treeview'],
'items' => [
['label' => Yii::t('backend', 'State'), 'url' => ['/location/state'], 'icon' => '<i class="fa fa-angle-double-right"></i>'],
['label' => Yii::t('backend', 'District'), 'url' => ['/location/district'], 'icon' => '<i class="fa fa-angle-double-right"></i>'],
[
'label' => Yii::t('backend', 'State'),
'url' => ['/location/state'],
'icon' => '<i class="fa fa-angle-double-right"></i>'
],
[
'label' => Yii::t('backend', 'District'),
'url' => ['/location/district'],
'icon' => '<i class="fa fa-angle-double-right"></i>'
],
]
],
[
......@@ -204,14 +248,38 @@ $bundle = BackendAsset::register($this);
'icon' => '<i class="fa fa-flag"></i>',
'options' => ['class' => 'treeview'],
'items' => [
['label' => Yii::t('backend', 'i18n Source Message'), 'url' => ['/i18n/i18n-source-message/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'],
['label' => Yii::t('backend', 'i18n Message'), 'url' => ['/i18n/i18n-message/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'],
[
'label' => Yii::t('backend', 'i18n Source Message'),
'url' => ['/i18n/i18n-source-message/index'],
'icon' => '<i class="fa fa-angle-double-right"></i>'
],
[
'label' => Yii::t('backend', 'i18n Message'),
'url' => ['/i18n/i18n-message/index'],
'icon' => '<i class="fa fa-angle-double-right"></i>'
],
]
],
['label' => Yii::t('backend', 'Key-Value Storage'), 'url' => ['/key-storage/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'],
['label' => Yii::t('backend', 'File Storage'), 'url' => ['/file-storage/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'],
['label' => Yii::t('backend', 'Cache'), 'url' => ['/cache/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'],
['label' => Yii::t('backend', 'File Manager'), 'url' => ['/file-manager/index'], 'icon' => '<i class="fa fa-angle-double-right"></i>'],
[
'label' => Yii::t('backend', 'Key-Value Storage'),
'url' => ['/key-storage/index'],
'icon' => '<i class="fa fa-angle-double-right"></i>'
],
[
'label' => Yii::t('backend', 'File Storage'),
'url' => ['/file-storage/index'],
'icon' => '<i class="fa fa-angle-double-right"></i>'
],
[
'label' => Yii::t('backend', 'Cache'),
'url' => ['/cache/index'],
'icon' => '<i class="fa fa-angle-double-right"></i>'
],
[
'label' => Yii::t('backend', 'File Manager'),
'url' => ['/file-manager/index'],
'icon' => '<i class="fa fa-angle-double-right"></i>'
],
[
'label' => Yii::t('backend', 'System Information'),
'url' => ['/system-information/index'],
......@@ -243,15 +311,19 @@ $bundle = BackendAsset::register($this);
<?php endif; ?>
</h1>
<?= Breadcrumbs::widget(['tag' => 'ol',
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],]) ?>
<?= Breadcrumbs::widget([
'tag' => 'ol',
'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : [],
]) ?>
</section>
<!-- Main content -->
<section class="content">
<?php if (Yii::$app->session->hasFlash('alert')): ?>
<?= \yii\bootstrap\Alert::widget(['body' => ArrayHelper::getValue(Yii::$app->session->getFlash('alert'), 'body'),
'options' => ArrayHelper::getValue(Yii::$app->session->getFlash('alert'), 'options'),]) ?>
<?= \yii\bootstrap\Alert::widget([
'body' => ArrayHelper::getValue(Yii::$app->session->getFlash('alert'), 'body'),
'options' => ArrayHelper::getValue(Yii::$app->session->getFlash('alert'), 'options'),
]) ?>
<?php endif; ?>
<?= $content ?>
</section><!-- /.content -->
......
......@@ -37,7 +37,6 @@ class State extends \yii\db\ActiveRecord
[
'class' => SluggableBehavior::className(),
'attribute' => 'name',
'immutable' => true
],
[
'class' => TimestampBehavior::className(),
......@@ -91,6 +90,10 @@ class State extends \yii\db\ActiveRecord
return new \common\models\query\StateQuery(get_called_class());
}
/**
* List all status
* @return array
*/
public static function statuses()
{
return [
......
......@@ -2,6 +2,8 @@
namespace common\models\query;
use common\models\State;
/**
* This is the ActiveQuery class for [[\common\models\State]].
*
......@@ -31,4 +33,9 @@ class StateQuery extends \yii\db\ActiveQuery
{
return parent::one($db);
}
public function active()
{
return $this->andWhere(['status' => State::STATUS_ACTIVE]);
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment