Skip to content

Commit

Permalink
fix conflict
Browse files Browse the repository at this point in the history
  • Loading branch information
刘俊涛 committed Mar 1, 2017
2 parents e0b87a4 + 1d0f9a4 commit b8f624b
Show file tree
Hide file tree
Showing 119 changed files with 8,286 additions and 612 deletions.
11 changes: 0 additions & 11 deletions backend/config/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,6 @@
'basePath' => dirname(__DIR__),
'controllerNamespace' => 'backend\controllers',
'controllerMap'=>[
'file-manager-elfinder' => [
'class' => 'mihaildev\elfinder\Controller',
'disabledCommands' => ['netmount'],
'roots' => [
[
'baseUrl' => '@storageUrl',
'basePath' => '@storagePath',
'path' => '/',
]
]
],
'upload' => \common\actions\UploadController::className()
],
'components' => [
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
19 changes: 16 additions & 3 deletions backend/models/MediaItem.php
Original file line number Diff line number Diff line change
@@ -1,9 +1,23 @@
<?php

namespace backend\models;

/**
* HassCMS (http:https://www.hassium.org/)
*
* @link http:https://github.com/hasscms for the canonical source repository
* @copyright Copyright (c) 2016-2099 Hassium Software LLC.
* @license http:https://opensource.org/licenses/gpl-license.php GNU Public License
*/
namespace backend\models;
use common\models\Attachment;

/**
*
* @package hass\package_name
* @author zhepama <[email protected]>
* @since 0.1.0
*
*/
class MediaItem
{
const TYPE_FILE = 'file';
Expand Down Expand Up @@ -72,8 +86,7 @@ public function __construct($path, $size, $lastModified, $type, $publicUrl)
*/
public static function createFromAttachment($attachment)
{
$file = $attachment->getFile();
$item = new static($attachment->getAbsolutePath(),$file->getSize(),$file->getTimestamp(),$file->getType(),$attachment->url);
$item = new static($attachment->path,$attachment->size, $attachment->updated_at, 'file', $attachment->url);
return $item;
}

Expand Down
11 changes: 11 additions & 0 deletions backend/views/layouts/main.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,16 @@
<?php $this->beginBody() ?>
<style>
.content-wrapper, .right-side, .main-footer {margin-left:0!important;}
.btn-refresh {
position: fixed;
bottom: 100px;
right: 2px;
padding: 3px 8px;
font-size: 24px;
border:1px solid #ccc;
border-radius:4px;
cursor: pointer;
}
</style>
<div class="content-wrapper">
<section class="content-header">
Expand Down Expand Up @@ -52,6 +62,7 @@
<?= $content ?>
</section>
</div>
<?= Html::a(Html::icon('refresh'), 'javascript:;', ['class' => 'btn btn-success btn-refresh', 'onclick' => 'location.reload()']) ?>
<?php $this->endBody() ?>
<?php if (isset($this->blocks['js'])): ?>
<?= $this->blocks['js'] ?>
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 b8f624b

Please sign in to comment.