Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Softme #3

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion models/BlogCatalog.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BlogCatalog extends \yii\db\ActiveRecord
*/
public static function tableName()
{
return 'blog_catalog';
return '{{%blog_catalog}}';
}

/**
Expand Down
6 changes: 3 additions & 3 deletions models/BlogComment.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class BlogComment extends \yii\db\ActiveRecord
*/
public static function tableName()
{
return 'blog_comment';
return '{{%blog_comment}}';
}

/**
Expand Down Expand Up @@ -145,8 +145,8 @@ public function getUrl($post=null)
public static function findRecentComments($limit=10)
{
return self::find()->joinWith('blogPost')->where([
'blog_comment.status' => Status::STATUS_ACTIVE,
'blog_post.status' => Status::STATUS_ACTIVE,
Yii::$app->db->tablePrefix.'blog_comment.status' => Status::STATUS_ACTIVE,
Yii::$app->db->tablePrefix .'blog_post.status' => Status::STATUS_ACTIVE,
])->orderBy([
'created_at' => SORT_DESC
])->limit($limit)->all();
Expand Down
2 changes: 1 addition & 1 deletion models/BlogPost.php
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ class BlogPost extends \yii\db\ActiveRecord
*/
public static function tableName()
{
return 'blog_post';
return '{{%blog_post}}';
}

/**
Expand Down
2 changes: 1 addition & 1 deletion models/BlogTag.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class BlogTag extends \yii\db\ActiveRecord
*/
public static function tableName()
{
return 'blog_tag';
return '{{%blog_tag}}';
}

/**
Expand Down
8 changes: 7 additions & 1 deletion views/backend/blog-post/_form.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use yii\helpers\ArrayHelper;
use funson86\blog\models\BlogCatalog;
use kartik\markdown\MarkdownEditor;
use mihaildev\ckeditor\CKEditor;

/* @var $this yii\web\View */
/* @var $model backend\modules\blog\models\BlogPost */
Expand All @@ -20,7 +21,12 @@

<?= $form->field($model, 'title')->textInput(['maxlength' => 128]) ?>

<?= $form->field($model, 'content')->textarea(['rows' => 6]) ?>
<?= $form->field($model, 'content')->widget(CKEditor::className(),[
'editorOptions' => [
'preset' => 'full',
'inline' => false,
],
]); ?>

<?= $form->field($model, 'tags')->textInput(['maxlength' => 128]) ?>

Expand Down
8 changes: 6 additions & 2 deletions views/backend/blog-post/view.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@
'value' => $model->catalog->title,
],
'title',
'content:ntext',
'tags',
'surname',
'click',
Expand All @@ -49,5 +48,10 @@
'updated_at:datetime',
],
]) ?>

</div>
<hr/>
<?php
$parser = new \cebe\markdown\GithubMarkdown();
echo $parser->parse($model->content);
?>

6 changes: 3 additions & 3 deletions widgets/SiteStat.php
Original file line number Diff line number Diff line change
Expand Up @@ -24,14 +24,14 @@ public function run()

$query = new Query();
$res = $query->select('sum(click) as click')
->from('blog_post')->one();
->from(\Yii::$app->db->tablePrefix .'blog_post')->one();
$click = $res['click'];
$str .= '<div class="site-stat">点击数量:'.$click.'</div>';

$postCount = $query->from('blog_post')->count();
$postCount = $query->from(\Yii::$app->db->tablePrefix .'blog_post')->count();
$str .= '<div class="site-stat">文章数量:'.$postCount.'</div>';

$commentCount = $query->from('blog_comment')->count();
$commentCount = $query->from(\Yii::$app->db->tablePrefix .'blog_comment')->count();
$str .= '<div class="site-stat">评论数量:'.$commentCount.'</div>';

return $this->render('portal', [
Expand Down