Exemple #1
0
 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);
         }
     }
 }
Exemple #2
0
</h1>
		<small class="gray">
		<?php 
echo 'by ', Html::a(Html::encode($topic['author']['username']), ['user/view', 'username' => Html::encode($topic['author']['username'])]), '  •  ', $formatter->asRelativeTime($topic['created_at']), '  •  ', $topic['views'], ' 次点击';
if (!$isGuest && !empty($topicOp)) {
    echo '  •  ', implode(' | ', $topicOp);
}
?>
</small>
	</div>
	<div class="cell topic-content link-external white-space">
		<?php 
if ($topic['invisible'] == 1 || $topic['author']['status'] == User::STATUS_BANNED) {
    echo '<p class="bg-danger">此主题已被屏蔽</p>';
    if (!$isGuest && $me->isAdmin()) {
        echo $editor->parse($topic['content']['content']);
    }
} else {
    echo $editor->parse($topic['content']['content']);
}
?>
	</div>
</div>

<?php 
if (intval($topic['comment_count']) === 0) {
    if (!empty($topic['tags'])) {
        ?>
<div class="box topic-comments">
	<div class="inner">
<?php 
Exemple #3
0
		回复了 <?php 
    echo Html::encode($comment['topic']['author']['username']);
    ?>
 创建的主题 › <?php 
    echo Html::a(Html::encode($comment['topic']['title']), ['topic/view', 'id' => $comment['topic_id']]);
    ?>
	</li>
	<li class="list-group-item word-wrap <?php 
    echo $whiteWrapClass;
    ?>
">
	<?php 
    if ($comment['invisible'] == 1 || $user['status'] == User::STATUS_BANNED) {
        echo Alert::widget(['options' => ['class' => 'alert-warning'], 'closeButton' => false, 'body' => '此回复已被屏蔽']);
        if (!$isGuest && $me->isAdmin()) {
            echo $editor->parse($comment['content']);
        }
    } else {
        echo $editor->parse($comment['content']);
    }
    ?>
	</li>
<?php 
}
?>
	<li class="list-group-item">
		» <?php 
echo Html::a(Html::encode($user['username']) . '的更多回复', ['comments', 'username' => Html::encode($user['username'])]);
?>
	</li>
</ul>
Exemple #4
0
?>
</small>
	</div>
<?php 
if (!empty($topic['content']['content']) || !empty($topic['tags'])) {
    ?>
	<div class="panel-body content link-external word-wrap <?php 
    echo $whiteWrapClass;
    ?>
">
		<?php 
    if (!empty($topic['content']['content'])) {
        if ($topic['invisible'] == 1 || $topic['author']['status'] == User::STATUS_BANNED) {
            echo '<p class="bg-danger">此主题已被屏蔽</p>';
            if (!$isGuest && $me->isAdmin()) {
                echo $editor->parse($topic['content']['content']);
            }
        } else {
            echo $editor->parse($topic['content']['content']);
        }
    }
    if (!empty($topic['tags'])) {
        echo '<div class="top10">';
        $tags = explode(',', strtolower($topic['tags']));
        foreach ($tags as $tag) {
            echo Html::a(Html::encode($tag), ['tag/index', 'name' => $tag], ['class' => 'btn btn-default btn-sm tag']);
        }
        echo '</div>';
    }
    ?>
	</div>