Skip to content

Commit

Permalink
merge big
Browse files Browse the repository at this point in the history
  • Loading branch information
刘俊涛 committed Mar 1, 2017
2 parents 4031b06 + ff9a158 commit 84a3e35
Show file tree
Hide file tree
Showing 139 changed files with 2,549 additions and 1,305 deletions.
3 changes: 0 additions & 3 deletions backend/config/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,6 @@
'id' => 'app-backend',
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'controllerMap'=>[
'upload' => \common\actions\UploadController::className()
],
'components' => [
'request' => [
'csrfParam' => '_csrfBackend'
Expand Down
2 changes: 1 addition & 1 deletion backend/controllers/SuggestController.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public function behaviors()
public function actionIndex()
{
$dataProvider = new ActiveDataProvider([
'query' => Comment::find()->where(['type' => 'suggest']),
'query' => Comment::find()->where(['entity' => 'suggest']),
'sort' => [
'defaultOrder' => [
'id' => SORT_DESC
Expand Down
6 changes: 3 additions & 3 deletions backend/modules/rbac/views/route/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,19 +17,19 @@

<div class="box box-primary">
<div class="box-body">
<div class="col-md-5">
<div class="col-xs-5">
<?= Yii::t('rbac', 'Avaliable') ?>:
<input id="search-avaliable">
<a href="#" id="btn-refresh"><span class="glyphicon glyphicon-refresh"></span></a><br><br>
<select id="list-avaliable" multiple size="20" style="width: 100%">
</select>
</div>
<div class="col-md-1">
<div class="col-xs-1">
<br><br>
<a href="#" id="btn-add" class="btn btn-success btn-flat">&gt;&gt;</a><br>
<a href="#" id="btn-remove" class="btn btn-danger">&lt;&lt;</a>
</div>
<div class="col-md-5">
<div class="col-xs-5">
<?= Yii::t('rbac', 'Assigned') ?>:
<input id="search-assigned"><br><br>
<select id="list-assigned" multiple size="20" style="width: 100%">
Expand Down
3 changes: 2 additions & 1 deletion backend/views/article/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
use yii\helpers\Html;
use common\models\Category;
use common\helpers\Tree;
use common\modules\attachment\widgets\SingleWidget;

/* @var $this yii\web\View */
/* @var $model common\models\Article */
Expand Down Expand Up @@ -47,7 +48,7 @@
'pluginOptions' => ['autoclose' => true]
]
) ?>
<?= $form->field($model, 'cover')->widget(\common\widgets\upload\SingleWidget::className()) ?>
<?= $form->field($model, 'cover')->widget(SingleWidget::className()) ?>

<?= $form->field($model, 'is_top')->checkbox() ?>

Expand Down
2 changes: 1 addition & 1 deletion backend/views/carousel/item/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<div class="col-md-6">
<?php echo $form->errorSummary($model) ?>

<?php echo $form->field($model, 'image')->widget(\common\widgets\upload\SingleWidget::className()) ?>
<?php echo $form->field($model, 'image')->widget(\common\modules\attachment\widgets\SingleWidget::className()) ?>

</div>
<div class="col-md-6">
Expand Down
4 changes: 2 additions & 2 deletions backend/views/comment/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
return $model->user->username;
}
],
'type',
'type_id',
'entity',
'entity_id',
[
'attribute' => 'content',
'options' => ['width' => '40%'],
Expand Down
2 changes: 1 addition & 1 deletion backend/views/module/config.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
use yii\helpers\Html;
use yii\widgets\ActiveForm;

$this->title = '插件设置:' .' '.$model->name;
$this->title = '模块配置:' .' '.$model->name;
$this->params['breadcrumbs'][] = ['label' => '插件', 'url' => ['index']];
$this->params['breadcrumbs'][] = $this->title;
?>
Expand Down
10 changes: 5 additions & 5 deletions backend/views/site/dashboard.php
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<div class="icon">
<i class="fa fa-book"></i>
</div>
<a href="<?= Url::to(['/article/index']) ?>" class="small-box-footer" target="_blank" title="文章列表">更多信息 <i class="fa fa-arrow-circle-right"></i></a>
<a href="<?= Url::to(['/article/index']) ?>" class="small-box-footer" target="_blank">更多信息 <i class="fa fa-arrow-circle-right"></i></a>
</div>
</div><!-- ./col -->
<div class="col-md-3 col-xs-6">
Expand All @@ -32,7 +32,7 @@
<div class="icon">
<i class="fa fa-book"></i>
</div>
<a href="<?= Url::to(['/article/index']) ?>" class="small-box-footer" target="_blank" title="文章列表">更多信息 <i class="fa fa-arrow-circle-right"></i></a>
<a href="<?= Url::to(['/article/index']) ?>" class="small-box-footer" target="_blank">更多信息 <i class="fa fa-arrow-circle-right"></i></a>
</div>
</div><!-- ./col -->
<div class="col-md-3 col-xs-6">
Expand All @@ -45,20 +45,20 @@
<div class="icon">
<i class="fa fa-user"></i>
</div>
<a href="<?= Url::to(['/user/admin/index']) ?>" class="small-box-footer" target="_blank" title="用户管理">更多信息 <i class="fa fa-arrow-circle-right"></i></a>
<a href="<?= Url::to(['/user/admin/index']) ?>" class="small-box-footer" target="_blank">更多信息 <i class="fa fa-arrow-circle-right"></i></a>
</div>
</div><!-- ./col -->
<div class="col-md-3 col-xs-6">
<!-- small box -->
<div class="small-box bg-purple">
<div class="inner">
<h3><?= \common\models\Comment::find()->where(['type' => 'suggest'])->count() ?></h3>
<h3><?= \common\models\Comment::find()->where(['entity' => 'suggest'])->count() ?></h3>
<p>留言</p>
</div>
<div class="icon">
<i class="fa fa-files-o"></i>
</div>
<a href="<?= Url::to(['/suggest/index']) ?>" class="small-box-footer" target="_blank" title="留言板">更多信息 <i class="fa fa-arrow-circle-right"></i></a>
<a href="<?= Url::to(['/suggest/index']) ?>" class="small-box-footer" target="_blank">更多信息 <i class="fa fa-arrow-circle-right"></i></a>
</div>
</div><!-- ./col -->
</div><!-- /.row -->
Expand Down
51 changes: 51 additions & 0 deletions common/behaviors/BaseAttachAttribute.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
<?php

namespace common\behaviors;

use yii\base\Behavior;

class BaseAttachAttribute extends Behavior
{

/**
*
* @var \yii\db\ActiveRecord
*/
public $owner;


/**
* @var string
*/
public $attribute;

/**
*
* @var mixed
*/
protected $value;


public function canGetProperty($name, $checkVars = true)
{
return parent::canGetProperty($name, $checkVars) || $this->attribute == $name;
}

// 根据特性返回这个值
public function __get($name)
{
if ($name != $this->attribute) {
return parent::__get($name);
}
if ($this->value == null) {
$this->value = $this->getValue();
}
return $this->value;
}

protected function getValue()
{

}

}
39 changes: 12 additions & 27 deletions common/behaviors/CommentBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,20 +10,20 @@

use common\models\Comment;
use common\models\CommentInfo;
use common\traits\EntityTrait;
use Yii;
use yii\base\Behavior;
use yii\db\ActiveRecord;
use yii\validators\Validator;

class CommentBehavior extends Behavior
{
use EntityTrait;
/**
* @var \yii\db\ActiveRecord
*/
public $owner;

public $type;

public $defaultStatus = 1;

public function events()
Expand Down Expand Up @@ -55,8 +55,8 @@ public function afterInsert()
return;
}
$model = new CommentInfo();
$model->type = $this->getType();
$model->type_id = $this->getTypeId();
$model->entity = $this->getEntity();
$model->entity_id = $this->getEntityId();
$model->status = $status;
$model->save();
}
Expand All @@ -74,8 +74,8 @@ public function afterUpdate()
return;
}
$model = new CommentInfo();
$model->type = $this->getType();
$model->type_id = $this->getTypeId();
$model->entity = $this->getEntity();
$model->entity_id = $this->getEntityId();
$model->status = $status;
$model->save();
} else {
Expand All @@ -87,32 +87,17 @@ public function afterUpdate()

public function afterDelete()
{
$type = $this->getType();
$type_id = $this->getTypeId();
CommentInfo::deleteAll(['type' => $type, 'type_id' => $type_id]);
Comment::deleteAll(['type' => $type, 'type_id' => $type_id]);
$entity = $this->getEntity();
$entityId = $this->getEntityId();
CommentInfo::deleteAll(['entity' => $entity, 'entity_id' => $entityId]);
Comment::deleteAll(['entity' => $entity, 'entity_id' => $entityId]);
}

public function getCommentInfo()
{
return $this->owner->hasOne(CommentInfo::className(), [
'type_id' => $this->owner->primaryKey()[0]
])->where(["type" => $this->getType()]);
}


public function getType()
{
if ($this->type == null) {
$this->type = $this->owner->className();
}

return ltrim($this->type,"\\");
}

public function getTypeId()
{
return $this->owner->getPrimaryKey();
'entity_id' => $this->owner->primaryKey()[0]
])->where(['entity' => $this->getEntity()]);
}

public function getCommentTotal()
Expand Down
22 changes: 7 additions & 15 deletions common/behaviors/MetaBehavior.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,15 @@


use common\models\Meta;
use common\traits\EntityTrait;
use Yii;
use yii\base\Behavior;
use yii\db\ActiveRecord;

class MetaBehavior extends Behavior
{
public $type;

use EntityTrait;
public function events()
{
return [
Expand Down Expand Up @@ -48,28 +49,19 @@ public function getMetaModel()
$model = $this->owner->meta;
if ($model == null) {
$model = new Meta([
'type' => $this->getType(),
'type_id' => $this->owner->getPrimaryKey()
'entity' => $this->getEntity(),
'entity_id' => $this->getEntityId()
]);
}
return $model;
}
public function getMeta()
{
return $this->owner->hasOne(Meta::className(), [
'type_id' => $this->owner->primaryKey()[0]
'entity_id' => $this->owner->primaryKey()[0]
])->where([
"type" => $this->getType()
"entity" => $this->getEntity()
]);
}

public function getType()
{
if ($this->type == null) {
$this->type = $this->owner->className();
}

return ltrim($this->type,"\\");
}

}
Loading

0 comments on commit 84a3e35

Please sign in to comment.