Пример #1
0
 /**
  * Displays a single Topic model.
  * @param integer $id
  * @return mixed
  * @throws BadRequestHttpException
  * @throws NotFoundHttpException
  * @throws \Exception
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     if ($model->need_login == 1 && Yii::$app->user->isGuest) {
         Yii::$app->getSession()->setFlash('danger', '你访问的主题需要登陆之后才能查看');
         return $this->redirect('/account/login?next=/topic/' . $id);
     }
     if (!empty($model->node->bg) && $model->node->use_bg == 1) {
         $this->bg = $model->node->bg;
     }
     if (!empty($model->node->bg_color)) {
         $this->bg_color = $model->node->bg_color;
     }
     $this->title = $model->title . ' - ' . Yii::$app->name;
     $this->description = $model->node['name'] . ' - ' . $model->user->username . ' - ' . Helper::truncateUtf8String($model->content->content, 200);
     $replyQuery = Reply::find()->where(['topic_id' => $model->id]);
     $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['pageSize'], 'totalCount' => $replyQuery->count()]);
     $replyList = $replyQuery->offset($pagination->offset)->limit($pagination->limit)->all();
     $reply = new Reply();
     if (!Yii::$app->user->isGuest) {
         $model->updateCounters(['click' => 1]);
         $reply = new Reply();
         if ($reply->load(Yii::$app->request->post()) && $reply->save()) {
             $this->redirect('/topic/' . $id . '#Reply');
         }
         return $this->render('view', ['model' => $model, 'reply' => $reply, 'replyList' => $replyList, 'pagination' => $pagination]);
     } else {
         return $this->render('view', ['model' => $model, 'reply' => $reply, 'replyList' => $replyList, 'pagination' => $pagination]);
     }
 }
Пример #2
0
 public function beforeAction($action)
 {
     if (!parent::beforeAction($action)) {
         return false;
     }
     $this->agent = Helper::agent();
     return true;
     // or false to not run the action
 }
 /**
  * Lists all TopicContent models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new TopicContentSearch();
     $dataProvider = $searchModel->search(Yii::$app->request->queryParams);
     $gridColumns[] = ['class' => 'kartik\\grid\\SerialColumn', 'contentOptions' => ['class' => 'kartik-sheet-style'], 'width' => '36px', 'header' => '序号', 'headerOptions' => ['class' => 'kartik-sheet-style']];
     $gridColumns[] = ['attribute' => 'topic_id', 'vAlign' => 'middle', 'width' => '180px', 'value' => function ($searchModel, $key, $index, $widget) {
         return $searchModel->topic->title;
     }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Topic::find()->orderBy('id')->asArray()->all(), 'id', 'title'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => '建议标题'], 'format' => 'raw'];
     $gridColumns[] = ['attribute' => 'content', 'value' => function ($searchModel, $key, $index, $widget) {
         return Helper::truncateUtf8String($searchModel->content, 100);
     }];
     $gridColumns[] = ['class' => 'kartik\\grid\\BooleanColumn', 'attribute' => 'is_append', 'vAlign' => 'middle', 'trueLabel' => '是', 'falseLabel' => '否'];
     $gridColumns[] = ['mergeHeader' => true, 'attribute' => 'created', 'format' => 'datetime'];
     $gridColumns[] = ['class' => '\\kartik\\grid\\ActionColumn', 'template' => '{view} {update}', 'buttons' => ['view' => function ($url, $model) {
         return Html::a('<span class="glyphicon glyphicon-eye-open"></span>', Yii::$app->params['domain'] . '/topic/' . $model->topic_id, ['title' => '查看', 'target' => '_blank']);
     }]];
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'gridColumns' => $gridColumns]);
 }
Пример #4
0
 /**
  * Displays a single Topic model.
  * @param integer $id
  * @return mixed
  * @throws BadRequestHttpException
  * @throws NotFoundHttpException
  * @throws \Exception
  */
 public function actionView($id)
 {
     $model = $this->findModel($id);
     if ($model->need_login == 1 && Yii::$app->user->isGuest) {
         Yii::$app->getSession()->setFlash('danger', '你访问的建议需要登陆之后才能查看');
         return $this->redirect('/account/login?next=/topic/' . $id);
     }
     if (!empty($model->node->bg) && $model->node->use_bg == 1) {
         $this->bg = $model->node->bg;
     }
     if (!empty($model->node->bg_color)) {
         $this->bg_color = $model->node->bg_color;
     }
     $this->title = $model->title . ' - ' . Yii::$app->name;
     if (isset($model->content->content)) {
         $this->description = $model->node->name . ' - ' . $model->user->username . ' - ' . Helper::truncateUtf8String($model->content->content, 200);
     } else {
         $this->description = $model->node->name . ' - ' . $model->user->username . Helper::truncateUtf8String($model->title, 200);
     }
     $this->canonical = Yii::$app->params['domain'] . 'topic/' . $id;
     $replyQuery = (new Query())->select('reply.*, user.username, user.avatar, user.role')->from(Reply::tableName())->leftJoin(User::tableName(), 'user.id = reply.user_id')->where(['reply.topic_id' => $id]);
     $pagination = new Pagination(['defaultPageSize' => Yii::$app->params['ReplyPageSize'], 'totalCount' => $replyQuery->count()]);
     $replyList = $replyQuery->offset($pagination->offset)->limit($pagination->limit)->all();
     $reply = new Reply();
     if (!Yii::$app->user->isGuest) {
         $model->updateCounters(['click' => 1]);
         $reply = new Reply();
         if ($reply->load(Yii::$app->request->post()) && $reply->save()) {
             Yii::$app->cache->delete('ReplyCount');
             $this->redirect('/topic/' . $id . '#Reply');
         }
         return $this->render('view', ['model' => $model, 'reply' => $reply, 'replyList' => $replyList, 'pagination' => $pagination]);
     } else {
         return $this->render('view', ['model' => $model, 'reply' => $reply, 'replyList' => $replyList, 'pagination' => $pagination]);
     }
 }
Пример #5
0
<?php

use yii\helpers\Html;
use yii\widgets\DetailView;
use common\models\User;
/* @var $this yii\web\View */
/* @var $user common\models\User */
/* @var $profile common\models\UserProfile */
$this->title = 'User Profile';
$this->params['breadcrumbs'][] = ['label' => 'User'];
?>
<div class="user-view">

    <p>
        <?php 
if (\Yii::$app->user->id === $user->id) {
    echo Html::a('Update', 'update', ['class' => 'btn btn-primary']);
}
?>
    </p>

    <?php 
echo DetailView::widget(['model' => $user, 'attributes' => ['username', 'email:email', 'userProfile.nicename', ['attribute' => 'phone', 'label' => 'Phone', 'format' => 'raw', 'value' => isset($user->userProfile->phone) ? \common\components\Helper::tel($user->userProfile->phone) : '<span class="not-set">(not set)</span>'], 'userProfile.skype', ['attribute' => 'status', 'label' => 'Status', 'value' => $user->userStatus], 'created_at:datetime', 'updated_at:datetime']]);
?>

</div>
Пример #6
0
<?php

$this->params['breadcrumbs'][] = '搜索';
$this->params['breadcrumbs'][] = $keyword;
$agent = \common\components\Helper::agent();
?>
    <div class="row">
        <div class="col-md-9">
            <section>
                <?php 
echo yii\widgets\Breadcrumbs::widget(['options' => ['class' => 'breadcrumb mb0'], 'links' => isset($this->params['breadcrumbs']) ? $this->params['breadcrumbs'] : []]);
?>
                <?php 
foreach ($topic as $t) {
    ?>
                    <?php 
    $topicInfo = \common\models\Topic::Info($t['topic_id']);
    ?>
                    <?php 
    $userInfo = \common\models\User::Info($topicInfo['user_id']);
    ?>
                    <?php 
    $lastReplyUser = \common\models\User::Info($topicInfo['last_reply_user']);
    ?>
                <article class="item">
                    <table cellpadding="0" cellspacing="0" border="0" width="100%">
                        <tbody><tr>
                            <?php 
    if ($agent == 'is_iphone' || $agent == 'is_android') {
        ?>
                                <td width="24" valign="middle" align="center"><a href="/member/<?php 
Пример #7
0
"><?php 
    echo $c['username'];
    ?>
</a> 提的建议 <a href="/topic/<?php 
    echo $c['topic_id'];
    ?>
"> <?php 
    echo $c['title'];
    ?>
</a> &nbsp;&nbsp;<?php 
    echo Yii::$app->formatter->asRelativeTime($c['created']);
    ?>
</small></aside>
                        </div>
                        <div class="mt10 markdown-content"><?php 
    echo \common\components\Helper::autoLink(\yii\helpers\HtmlPurifier::process(\yii\helpers\Markdown::process($c['content'], 'gfm-comment')));
    ?>
</div>
                        <div class="clearfix"></div>
                    </div>
                </article>
            <?php 
}
?>
            <div class="block-footer"><a href="/member/<?php 
echo $model->username;
?>
/reply"><?php 
echo $model->username;
?>
 的更多回复</a></div>
Пример #8
0
 /**
  * Displays a single Topic Preview.
  * @param integer $id
  * @return mixed
  * @throws BadRequestHttpException
  * @throws NotFoundHttpException
  * @throws \Exception
  */
 public function actionPreview()
 {
     $content = Yii::$app->request->post('content');
     if (Yii::$app->user->isGuest || $content == null) {
         return false;
     } else {
         Yii::$app->response->format = Response::FORMAT_JSON;
         return Helper::autoLink(HtmlPurifier::process(Markdown::process($content, 'gfm-comment')));
     }
 }
Пример #9
0
use yii\bootstrap\Html;
use common\components\Helper;
$this->title = 'Edit user';
?>

<div class="page__content">
    <div class="page__content-title">General</div>
    <div class="page__content-inner">
        <?php 
$form = ActiveForm::begin(['type' => ActiveForm::TYPE_HORIZONTAL, 'fullSpan' => 7, 'formConfig' => ['labelSpan' => 2, 'deviceSize' => ActiveForm::SIZE_SMALL]]);
?>
        <?php 
echo $form->field($model, 'created')->staticInput();
?>
        <?php 
echo $form->field($model, 'status')->label()->radioButtonGroup(Helper::array_column($model::getStatuses(), 'label', true), ['class' => 'btn-group-sm', 'itemOptions' => ['labelOptions' => ['class' => 'btn btn-success']]]);
?>
        <?php 
echo $form->field($model, 'email');
?>
        <div class="form-group">
            <div class="col-sm-offset-2 col-sm-10">
                <?php 
echo Html::submitButton('Save', ['class' => 'btn btn-success']);
?>
            </div>
        </div>
        <?php 
ActiveForm::end();
?>
    </div>
Пример #10
0
Файл: view.php Проект: npk/v2sex
            ?>
 <span><small><a href="javascript:;" class="reply_link" data_id="<?php 
            echo $userInfo['username'];
            ?>
"><i class="glyphicon glyphicon-share-alt"></i></a></small></span><?php 
        }
        ?>
                            <span class="badge"><?php 
        echo $floor;
        ?>
</span>
                        </div>
                        </aside>
                    </div>
                    <div class="mt3"><p><?php 
        echo Helper::autoLinkReply(nl2br($c->content));
        ?>
</p></div>
                    <div class="clearfix"></div>
                </div>
            </article>
                <?php 
        $floor++;
        ?>
            <?php 
    }
    ?>
            <article>
                <?php 
    echo \yii\widgets\LinkPager::widget(['pagination' => $pagination]);
    ?>
Пример #11
0
/* @var $this yii\web\View */
/* @var $form yii\bootstrap\ActiveForm */
/* @var $model \common\models\LoginForm */
$this->title = 'Login';
$fieldOptions1 = ['options' => ['class' => 'form-group has-feedback'], 'inputTemplate' => "{input}<span class='glyphicon glyphicon-user form-control-feedback'></span>"];
$fieldOptions2 = ['options' => ['class' => 'form-group has-feedback'], 'inputTemplate' => "{input}<span class='glyphicon glyphicon-lock form-control-feedback'></span>"];
?>

<div class="login-box">
    <div class="login-logo">
        <span style="vertical-align: middle;"><strong>Admin</strong></span>
    </div>
    <!-- /.login-logo -->

    <?php 
echo \common\components\Helper::renderFlashMessages();
?>

    <div class="login-box-body">
        <p class="login-box-msg">Login to your admin dashboard.</p>

        <?php 
$form = ActiveForm::begin(['id' => 'login-form', 'enableClientValidation' => false]);
?>

        <?php 
echo $form->field($model, 'username', $fieldOptions1)->label(false)->textInput(['placeholder' => $model->getAttributeLabel('username'), 'autofocus' => true]);
?>

        <?php 
echo $form->field($model, 'password', $fieldOptions2)->label(false)->passwordInput(['placeholder' => $model->getAttributeLabel('password')]);
Пример #12
0
 public function afterFind()
 {
     $this->content = Helper::autoLink(HtmlPurifier::process(Markdown::process($this->content, 'gfm-comment')));
     parent::afterFind();
 }
Пример #13
0
</strong></a> 在回复 <a href="/topic/<?php 
        echo $n->topic_id;
        ?>
"><?php 
        echo $topicInfo['title'];
        ?>
</a> 时提到了你</span> &nbsp; <?php 
        echo Yii::$app->formatter->asRelativeTime($n->created);
        ?>
</small> <a href="/account/notice-delete/?id=<?php 
        echo $n->id;
        ?>
" class="node">删除</a>
                                    <div class="mt10"></div>
                                    <div class="notice-content"><?php 
        echo Helper::autoLinkReply(nl2br($n->msg));
        ?>
</div>
                                </td>
                            </tr>
                            </tbody>
                        </table>
                    </article>
                <?php 
    }
    ?>

            <?php 
}
?>
            <article>
Пример #14
0
                <div class="mt10"></div>
                <?php 
    if (!empty($model->homepage)) {
        ?>
                    <p><a href="<?php 
        echo $model->homepage;
        ?>
" target="_blank" rel="nofollow"><?php 
        echo $model->homepage;
        ?>
</a></p>
                <?php 
    }
    ?>
                <p><?php 
    echo \common\components\Helper::autoLink(\yii\helpers\HtmlPurifier::process(\yii\helpers\Markdown::process($model->desc, 'gfm-comment')));
    ?>
</p>
            </article>
            <?php 
}
?>
        </section>

        <section>
            <div class="block-header"><?php 
echo $model->username;
?>
 最近发布的主题</div>
            <?php 
foreach ($model->topicList as $t) {