public static function afterTopicInsert($tc) { $editor = new \app\lib\Editor(['editor' => Yii::$app->params['settings']['editor']]); $content = $editor->parse($tc->content); $pa = new PhpAnalysis(); $pa->SetSource($tc->topic->title . strip_tags($content)); $pa->resultType = 2; $pa->differMax = true; $pa->StartAnalysis(); $tagNames = $pa->GetFinallyKeywords(3); $tagNames = explode(',', $tagNames); $tags = static::find()->select(['id', 'name'])->where(['in', 'name', $tagNames])->indexBy('name')->all(); foreach ($tagNames as $tn) { if (!empty($tags) && !empty($tags[$tn])) { $tag = $tags[$tn]; $tagTopic = new TagTopic(['tag_id' => $tag->id, 'topic_id' => $tc->topic_id]); $tagTopic->save(false); $tag->updateCounters(['topic_count' => 1]); } else { $tag = new static(['name' => $tn, 'topic_count' => 1]); $tag->save(false); $tagTopic = new TagTopic(['tag_id' => $tag->id, 'topic_id' => $tc->topic_id]); $tagTopic->save(false); } } }
<?php /** * @link http://www.simpleforum.org/ * @copyright Copyright (c) 2015 Simple Forum * @author Jiandong Yu admin@simpleforum.org */ use yii\helpers\Html; use yii\widgets\ActiveForm; use app\models\Node; $settings = Yii::$app->params['settings']; $this->registerAssetBundle('app\\assets\\Select2Asset'); $this->registerJs('$(".nodes-select2").select2({placeholder:"请选择一个节点",allowClear: true});'); $editor = new \app\lib\Editor(['editor' => $settings['editor']]); $editor->registerAsset($this); $editor->registerTagItAsset($this); $this->title = '创建新主题'; ?> <div class="row"> <div class="col-md-8 sf-left"> <div class="panel panel-default sf-box"> <div class="panel-heading"> <?php echo Html::a('首页', ['topic/index']), ' / ', $this->title; ?> </div> <div class="panel-body"> <?php $form = ActiveForm::begin();
<?php /** * @link http://www.simpleforum.org/ * @copyright Copyright (c) 2015 Simple Forum * @author Jiandong Yu admin@simpleforum.org */ use yii\helpers\Html; use yii\bootstrap\Alert; use app\models\Favorite; use app\models\User; $this->title = Html::encode($user['username']); $settings = Yii::$app->params['settings']; $editor = new \app\lib\Editor(['editor' => $settings['editor']]); $whiteWrapClass = $settings['editor'] == 'smd' ? 'white-wrap' : ''; $fomatter = Yii::$app->getFormatter(); $isGuest = Yii::$app->getUser()->getIsGuest(); if (!$isGuest) { $me = Yii::$app->getUser()->getIdentity(); } if (!$isGuest && $me->isActive() && $me->id != $user['id']) { $follow = Favorite::checkFollow($me->id, Favorite::TYPE_USER, $user['id']) ? Html::a('取消特别关注', ['favorite/cancel', 'type' => 'user', 'id' => $user['id']], ['class' => 'btn btn-sm btn-default', 'data' => ['method' => 'post']]) : Html::a('加入特别关注', ['favorite/add', 'type' => 'user', 'id' => $user['id']], ['class' => 'btn btn-sm btn-primary']); } else { $follow = ''; } if (!$isGuest && $me->isAdmin() && $me->id != $user['id']) { $manage = Html::a('管理', ['admin/user/info', 'id' => $user['id']], ['class' => 'btn btn-sm btn-primary']); } else { $manage = ''; } ?>
/** * @link http://www.simpleforum.org/ * @copyright Copyright (c) 2015 Simple Forum * @author Jiandong Yu admin@simpleforum.org */ use yii\helpers\Html; use yii\widgets\LinkPager; use yii\bootstrap\ActiveForm; use yii\bootstrap\Alert; use app\lib\Util; use app\models\User; use app\models\Favorite; $settings = Yii::$app->params['settings']; $request = Yii::$app->getRequest(); $formatter = Yii::$app->getFormatter(); $editor = new \app\lib\Editor(['editor' => $settings['editor']]); $editor->registerAsset($this); $indexPage = intval($request->get('ip', 0)); $nodePage = intval($request->get('np', 0)); $indexUrl = ['topic/index']; $nodeUrl = ['topic/node', 'name' => $topic['node']['ename']]; $topicUrl = ['topic/edit', 'id' => $topic['id']]; if ($indexPage > 0) { if ($indexPage > 1) { $indexUrl['p'] = $indexPage; } $topicUrl['ip'] = $indexPage; } else { if ($nodePage > 0) { if ($nodePage > 1) { $nodeUrl['p'] = $nodePage;
<?php /** * @link http://www.simpleforum.org/ * @copyright Copyright (c) 2015 Simple Forum * @author Jiandong Yu admin@simpleforum.org */ use yii\helpers\Html; use yii\widgets\ActiveForm; $editor = new \app\lib\Editor(['editor' => Yii::$app->params['settings']['editor']]); $editor->registerAsset($this); ?> <?php $form = ActiveForm::begin(); ?> <?php if ($action === 'edit' && Yii::$app->getUser()->getIdentity()->isAdmin()) { echo $form->field($model, 'invisible')->dropDownList(['公开主题', '隐藏主题'])->label(false); echo $form->field($model, 'comment_closed')->dropDownList(['开放评论', '关闭评论'])->label(false); } ?> <p>主题标题 <span class="gray">( 如果标题能够表达完整内容,主题内容可为空 )</span></p> <?php echo $form->field($model, 'title')->textArea(['rows' => '4', 'maxlength' => 120])->label(false); ?> <p>主题内容</p> <?php echo $form->field($content, 'content')->textArea(['id' => 'editor', 'maxlength' => 30000])->label(false); ?> <div class="form-group">
/** * @link http://www.simpleforum.org/ * @copyright Copyright (c) 2015 Simple Forum * @author Jiandong Yu admin@simpleforum.org */ use yii\helpers\Html; use yii\widgets\LinkPager; use yii\bootstrap\ActiveForm; use yii\bootstrap\Alert; use app\lib\Util; use app\models\User; use app\models\Favorite; $settings = Yii::$app->params['settings']; $request = Yii::$app->getRequest(); $formatter = Yii::$app->getFormatter(); $editor = new \app\lib\Editor(['editor' => $settings['editor']]); $editor->registerAsset($this); $whiteWrapClass = $settings['editor'] == 'smd' ? 'white-wrap' : ''; $indexPage = intval($request->get('ip', 0)); $nodePage = intval($request->get('np', 0)); $indexUrl = ['topic/index']; $nodeUrl = ['topic/node', 'name' => $topic['node']['ename']]; $topicUrl = ['topic/edit', 'id' => $topic['id']]; if ($indexPage > 0) { if ($indexPage > 1) { $indexUrl['p'] = $indexPage; } $topicUrl['ip'] = $indexPage; } else { if ($nodePage > 0) { if ($nodePage > 1) {