示例#1
1
 public function actionIndex()
 {
     $this->title = Yii::$app->name;
     $this->description = 'V2SEX,一个很实在的技术宅的专属社区。在这里交流技术,各种创意点子,聊妹子,聊男人,同性恋,各种兴趣爱好,提问,甚至可以交流AV。';
     $tab = Yii::$app->request->get('tab');
     $sessionTab = Yii::$app->session->get('tab');
     if (Yii::$app->request->get('tab') === null) {
         if (empty($sessionTab)) {
             Yii::$app->session->set('tab', 'tech');
             $tab = 'tech';
         } else {
             $tab = $sessionTab;
         }
     } else {
         if (Tab::findOne(['enname' => $tab]) !== null) {
             Yii::$app->session->set('tab', $tab);
         } else {
             Yii::$app->session->set('tab', 'tech');
             $tab = 'tech';
         }
     }
     $tabModel = Tab::find()->where(['enname' => $tab])->one();
     if (!empty($tabModel->bg) && $tabModel->use_bg == 1) {
         $this->bg = $tabModel->bg;
     }
     if (!empty($tabModel->bg_color)) {
         $this->bg_color = $tabModel->bg_color;
     }
     if ($tab == 'new') {
         $topic = (new Query())->select('topic.*, node.enname, node.name, user.username, user.avatar')->from(Topic::tableName() . ' topic')->leftJoin(Node::tableName() . ' node', 'node.id = topic.node_id')->leftJoin(User::tableName() . ' user', 'user.id = topic.user_id')->where('node.is_hidden = 0')->orderBy(['topic.updated_at' => SORT_DESC])->limit(20)->all();
     } else {
         $topic = (new Query())->select('topic.*, node.enname, node.name, user.username, user.avatar')->from(Topic::tableName() . ' topic')->leftJoin(Node::tableName() . ' node', 'node.id = topic.node_id')->leftJoin(User::tableName() . ' user', 'user.id = topic.user_id')->where('node.is_hidden = 0')->andWhere(['in', 'topic.node_id', Tab::SubNodeId($tab)])->orderBy(['topic.updated_at' => SORT_DESC])->limit(20)->all();
     }
     return $this->render('index', ['topic' => $topic]);
 }
示例#2
0
 /**
  * Lists all TabAd models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new TabAdSearch();
     $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' => 'id', 'vAlign' => 'middle'];
     $gridColumns[] = ['attribute' => 'tab_id', 'vAlign' => 'middle', 'width' => '180px', 'value' => function ($searchModel, $key, $index, $widget) {
         return empty($searchModel->tab->name) ? null : $searchModel->tab->name;
     }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Tab::find()->orderBy('name')->asArray()->all(), 'id', 'name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'tab'], 'format' => 'raw'];
     $gridColumns[] = 'content';
     $gridColumns[] = ['class' => 'kartik\\grid\\BooleanColumn', 'attribute' => 'status', 'width' => '100px', 'vAlign' => 'middle', 'trueLabel' => '启用', 'falseLabel' => '禁用'];
     $gridColumns[] = ['class' => '\\kartik\\grid\\ActionColumn', 'template' => '{view} {update} {delete}'];
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'gridColumns' => $gridColumns]);
 }
示例#3
0
文件: TabSearch.php 项目: npk/v2sex
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Tab::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'sort' => ['defaultOrder' => ['id' => SORT_DESC]]]);
     $this->load($params);
     if (!$this->validate()) {
         // uncomment the following line if you do not want to return any records when validation fails
         // $query->where('0=1');
         return $dataProvider;
     }
     $query->andFilterWhere(['id' => $this->id, 'sort' => $this->sort]);
     $query->andFilterWhere(['like', 'name', $this->name])->andFilterWhere(['like', 'enname', $this->enname]);
     return $dataProvider;
 }
示例#4
0
 /**
  * Lists all Node models.
  * @return mixed
  */
 public function actionIndex()
 {
     $searchModel = new NodeSearch();
     $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[] = ['mergeHeader' => true, 'attribute' => 'logo24Show', 'header' => '图片', 'format' => 'html'];
     $gridColumns[] = ['attribute' => 'id', 'vAlign' => 'middle'];
     $gridColumns[] = ['attribute' => 'name', 'vAlign' => 'middle'];
     $gridColumns[] = ['attribute' => 'tab_id', 'vAlign' => 'middle', 'width' => '180px', 'value' => function ($searchModel, $key, $index, $widget) {
         return empty($searchModel->tab->name) ? null : $searchModel->tab->name;
     }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Tab::find()->orderBy('name')->asArray()->all(), 'id', 'name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => 'tab'], 'format' => 'raw'];
     $gridColumns[] = ['attribute' => 'enname', 'vAlign' => 'middle'];
     $gridColumns[] = ['attribute' => 'parent_id', 'vAlign' => 'middle', 'width' => '180px', 'value' => function ($searchModel, $key, $index, $widget) {
         return empty($searchModel->parent->name) ? null : $searchModel->parent->name;
     }, 'filterType' => GridView::FILTER_SELECT2, 'filter' => ArrayHelper::map(Node::find()->orderBy('name')->asArray()->all(), 'id', 'name'), 'filterWidgetOptions' => ['pluginOptions' => ['allowClear' => true]], 'filterInputOptions' => ['placeholder' => '父节点'], 'format' => 'raw'];
     $gridColumns[] = ['attribute' => 'desc', 'vAlign' => 'middle'];
     $gridColumns[] = ['class' => 'kartik\\grid\\BooleanColumn', 'attribute' => 'is_hidden', 'width' => '100px', 'vAlign' => 'middle', 'trueLabel' => '是', 'falseLabel' => '否'];
     $gridColumns[] = ['class' => 'kartik\\grid\\BooleanColumn', 'attribute' => 'need_login', 'width' => '100px', 'vAlign' => 'middle', 'trueLabel' => '是', 'falseLabel' => '否'];
     $gridColumns[] = ['attribute' => 'sort', 'vAlign' => 'middle'];
     $gridColumns[] = ['mergeHeader' => true, 'attribute' => 'created', 'format' => 'datetime'];
     $gridColumns[] = ['class' => '\\kartik\\grid\\ActionColumn'];
     return $this->render('index', ['searchModel' => $searchModel, 'dataProvider' => $dataProvider, 'gridColumns' => $gridColumns]);
 }
示例#5
0
 /**
  * 获取节点的子节点,有缓存就获取缓存,用于主tab下面的子tab显示
  * @return array|\yii\db\ActiveRecord[]
  */
 static function SubTab($enname)
 {
     if (!($SubTab = Yii::$app->cache->get('SubTab' . $enname))) {
         $SubTab = Tab::find()->where(['enname' => $enname])->with('tabRight')->with('nodes')->asArray()->one();
         Yii::$app->cache->set('SubTab' . $enname, $SubTab, 0);
     }
     return $SubTab;
 }
示例#6
0
<?php

use common\models\Tab;
$tab = Tab::Tab();
$tabActive = Yii::$app->session->get('tab');
$subtab = Tab::SubTab($tabActive);
$agent = \common\components\Helper::agent();
?>

<?php 
if ($agent == 'is_iphone' || $agent == 'is_android') {
    ?>

<ul id="Tabs" class="tab nav-pills nav no-sub-nav" style="padding:10px 10px;">
<?php 
    foreach ($tab as $t) {
        ?>
    <li<?php 
        if ($t['enname'] == $tabActive) {
            echo ' class="active"';
        }
        ?>
><a href="?tab=<?php 
        echo $t['enname'];
        ?>
" style="padding:5px 6px;margin:0  0"><?php 
        echo $t['name'];
        ?>
</a></li>
<?php 
    }
示例#7
0
 /**
  * Finds the Tab model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Tab the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Tab::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#8
0
use yii\helpers\Html;
use yii\widgets\ActiveForm;
/* @var $this yii\web\View */
/* @var $model common\models\TabNav */
/* @var $form yii\widgets\ActiveForm */
?>

<div class="tab-nav-form">

    <?php 
$form = ActiveForm::begin();
?>

    <?php 
echo $form->field($model, 'tab_id')->widget(\kartik\select2\Select2::classname(), ['data' => \yii\helpers\ArrayHelper::map(\common\models\Tab::find()->all(), 'id', 'name'), 'options' => ['placeholder' => 'TAB'], 'pluginOptions' => ['allowClear' => true]]);
?>

    <?php 
echo $form->field($model, 'name')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'link')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'sort')->textInput();
?>

    <div class="form-group">
示例#9
0
文件: Node.php 项目: npk/v2sex
 public function create()
 {
     $this->created = time();
     if ($this->validate()) {
         $this->logo = UploadedFile::getInstance($this, 'logo');
         if ($this->logo != null) {
             $filename = date('Ymdhis') . rand(1000, 9999);
             $this->logo->saveAs(Yii::getAlias('@node') . '/origin/' . $filename . '.' . $this->logo->extension);
             $extension = $this->logo->extension;
             $this->logo = $filename . '.' . $extension;
             Image::thumbnail(Yii::getAlias('@node') . '/origin/' . $filename . '.' . $extension, 80, 80)->save(Yii::getAlias('@node') . '/80/' . $filename . '.' . $extension, ['quality' => 80]);
             Image::thumbnail(Yii::getAlias('@node') . '/origin/' . $filename . '.' . $extension, 48, 48)->save(Yii::getAlias('@node') . '/48/' . $filename . '.' . $extension, ['quality' => 80]);
             Image::thumbnail(Yii::getAlias('@node') . '/origin/' . $filename . '.' . $extension, 24, 24)->save(Yii::getAlias('@node') . '/24/' . $filename . '.' . $extension, ['quality' => 80]);
         } else {
             $this->addError('logo', 'logo不能为空');
             return false;
         }
         $this->bg = UploadedFile::getInstance($this, 'bg');
         if ($this->bg != null) {
             $filename = date('Ymdhis') . rand(1000, 9999);
             $this->bg->saveAs(Yii::getAlias('@bg') . '/' . $filename . '.' . $this->bg->extension);
             $extension = $this->bg->extension;
             $this->bg = $filename . '.' . $extension;
         }
         if (!empty($this->tab_id)) {
             Yii::$app->cache->delete('subnodeid' . Tab::findOne($this->tab_id)->enname);
         }
         return $this->save();
     }
     return false;
 }
示例#10
0
 public function actionIndex()
 {
     $this->title = Yii::$app->name;
     $this->description = '云建议,一个收集建议的地方。';
     $tab = Yii::$app->request->get('tab');
     $sessionTab = Yii::$app->session->get('tab');
     if (Yii::$app->request->get('tab') === null) {
         if (empty($sessionTab)) {
             Yii::$app->session->set('tab', 'new');
             $tab = 'new';
         } else {
             $tab = $sessionTab;
         }
     } else {
         if (Tab::Info($tab) !== null) {
             Yii::$app->session->set('tab', $tab);
         } else {
             Yii::$app->session->set('tab', 'new');
             $tab = 'new';
         }
     }
     $tabModel = Tab::Info($tab);
     if (!empty($tabModel['bg']) && $tabModel['use_bg'] == 1) {
         $this->bg = $tabModel['bg'];
     }
     if (!empty($tabModel['bg_color'])) {
         $this->bg_color = $tabModel['bg_color'];
     }
     $this->canonical = Yii::$app->params['domain'] . '?tab=' . $tab;
     if ($tab == 'new') {
         $topic = (new Query())->select('topic.*, node.enname, node.name, user.username, user.avatar')->from(Topic::tableName() . ' topic')->leftJoin(Node::tableName() . ' node', 'node.id = topic.node_id')->leftJoin(User::tableName() . ' user', 'user.id = topic.user_id')->where(['node.is_hidden' => 0])->orderBy(['topic.updated_at' => SORT_DESC])->limit(Yii::$app->params['pageSize'])->all();
     } else {
         $topic = (new Query())->select('topic.*, node.enname, node.name, user.username, user.avatar')->from(Topic::tableName())->leftJoin(Node::tableName(), 'node.id = topic.node_id')->leftJoin(User::tableName(), 'user.id = topic.user_id')->where(['in', 'topic.node_id', Tab::SubNodeId($tab)])->orderBy(['topic.updated_at' => SORT_DESC])->limit(Yii::$app->params['pageSize'])->all();
     }
     return $this->render('index', ['topic' => $topic]);
 }
示例#11
-1
文件: TabAd.php 项目: boxcore/v2sex
 static function TabAd($tab)
 {
     if (!($TabAd = Yii::$app->cache->get('TabAd' . $tab))) {
         $TabModel = Tab::findOne(['enname' => $tab]);
         if (!empty($TabModel->id)) {
             $TabAd = TabAd::find()->where(['tab_id' => $TabModel->id])->asArray()->all();
             Yii::$app->cache->set('TabAd' . $tab, $TabAd, 0);
         } else {
             return null;
         }
     }
     return $TabAd;
 }