コード例 #1
0
ファイル: LawController.php プロジェクト: wuwenhan/huoqiwang
 public function actionLaw()
 {
     $infos = Article::findOne(['title' => '法律服务']);
     $model = UcenterMember::find()->where('id=' . Yii::$app->user->id)->one();
     $infos_rar = $this->Ucenter();
     //用户数据包
     return $this->render('law', compact("infos_rar", "model", "infos"));
 }
コード例 #2
0
ファイル: Article.php プロジェクト: jaybril/www.mimgpotea.com
 public function deleteArticle($id)
 {
     $model = Article::findOne($id);
     if (!$model) {
         return false;
     }
     if ($model->delete()) {
         return true;
     }
     return false;
 }
コード例 #3
0
ファイル: ArticleSearch.php プロジェクト: wuwenhan/huoqiwang
 /**
  * Creates data provider instance with search query applied
  *
  * @param array $params
  *
  * @return ActiveDataProvider
  */
 public function search($params)
 {
     $query = Article::find();
     $dataProvider = new ActiveDataProvider(['query' => $query, 'pagination' => ['pageSize' => 10]]);
     $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, 'user_id' => $this->user_id, 'status' => $this->status, 'category_id' => $this->category_id, 'create_at' => $this->create_at, 'update_at' => $this->update_at]);
     $query->andFilterWhere(['like', 'title', $this->title])->andFilterWhere(['like', 'intro', $this->intro])->andFilterWhere(['like', 'content', $this->content]);
     return $dataProvider;
 }
コード例 #4
0
ファイル: _form.php プロジェクト: wuwenhan/huoqiwang
?>

    <?php 
echo $form->field($model, 'user_id')->dropDownList(ArrayHelper::map(\backend\models\User::find()->asArray()->all(), 'id', 'username'));
?>

    <?php 
echo '<label class="control-label">图片</label>';
echo FileInput::widget(['model' => $model, 'attribute' => 'logo', 'pluginOptions' => ['uploadExtraData' => ['album_id' => 20, 'cat_id' => 'Nature'], 'maxFileCount' => 10, 'initialCaption' => $model->logo, "showUpload" => false]]);
?>

    <?php 
echo $form->field($model, 'category_id')->dropDownList(ArrayHelper::map(\backend\models\Category::get(0, \backend\models\Category::find()->asArray()->all()), 'id', 'str_label'));
?>
    <?php 
echo $form->field($model, 'status')->dropDownList(\backend\models\Article::getArrayStatus());
?>
    <?php 
echo $form->field($model, 'title')->textInput(['maxlength' => true]);
?>

    <?php 
echo $form->field($model, 'intro')->textarea(['rows' => 6]);
?>



    <?php 
//外部TAG
echo Html::tag('script', $model->content, ['id' => Html::getInputId($model, 'content'), 'name' => Html::getInputName($model, 'content'), 'type' => 'text/plain']);
echo Ueditor::widget(['model' => $model, 'attribute' => 'content', 'renderTag' => false, 'jsOptions' => ['serverUrl' => yii\helpers\Url::to(['upload']), 'autoHeightEnable' => true, 'autoFloatEnable' => true]]);
コード例 #5
0
 public function actionAddarticle()
 {
     $user = new AdminUser();
     if (!$user->checkUserIsLogin()) {
         $this->redirect(Variable::$home_url);
         return;
     }
     $req = Yii::$app->request;
     //创建一个请求对象
     $form = new ArticleForm();
     $articleModel = new Article();
     $articleCatModel = ArticleCategory::find()->all();
     //添加
     $form->setScenario('create');
     if ($form->load($req->post()) && $form->validate()) {
         if ($articleModel->addAerticle($form->title, $form->keywords, $form->categoryId, $form->content, $form->status, $form->isTop, $form->description, $form->pic)) {
             $this->redirect(Variable::$articleManger_url);
             return;
         }
     }
     return $this->render(Variable::$addArticle_view, ['model' => $form, 'articleModel' => $articleModel, 'articleCatModel' => $articleCatModel]);
 }
コード例 #6
0
ファイル: Article.php プロジェクト: jaybril/www.juice.com
 public function updateArticleByService($id, $title, $useId, $keywords, $pic, $content)
 {
     $model = Article::findOne($id);
     if (!$model) {
         return false;
     }
     $model->content = $content;
     $model->title = $title;
     $model->useId = $useId;
     $model->keywords = $keywords;
     $model->pic = $pic;
     $model->content = $content;
     $model->addTime = date('Y-m-d H:i:s', time());
     $model->addUser = Yii::$app->session->get(Variable::$session_userId_str);
     if ($model->save()) {
         return true;
     }
     return false;
 }
コード例 #7
0
ファイル: index.php プロジェクト: wuwenhan/huoqiwang
    <p>
        <?php 
echo Html::a('创建', ['create'], ['class' => 'btn btn-success']);
?>
    </p>

    <?php 
echo GridView::widget(['dataProvider' => $dataProvider, 'filterModel' => $searchModel, 'columns' => [['class' => 'yii\\grid\\SerialColumn'], ['attribute' => 'user_id', 'value' => function ($model) {
    return $model->user ? $model->user->username : '******';
}], ['attribute' => 'category_id', 'value' => function ($model) {
    return $model->category->title;
}, 'filter' => Html::activeDropDownList($searchModel, 'category_id', \backend\models\Article::getArrayCategory(), ['class' => 'form-control', 'prompt' => '请筛选'])], 'title', ['attribute' => 'status', 'format' => 'html', 'value' => function ($model) {
    if ($model->status === Article::STATUS_ACTIVE) {
        $class = 'label-success';
    } elseif ($model->status === Article::STATUS_INACTIVE) {
        $class = 'label-warning';
    } else {
        $class = 'label-danger';
    }
    return '<span class="label ' . $class . '">' . $model->statusLabel . '</span>';
}, 'filter' => Html::activeDropDownList($searchModel, 'status', Article::getArrayStatus(), ['class' => 'form-control', 'prompt' => '请筛选'])], ['class' => 'yii\\grid\\ActionColumn', 'header' => '操作', 'template' => '{preview}{view}{update}{delete}{send}{unsend}', 'buttons' => ['delete' => function ($url, $model, $key) {
    return Html::a('<span class="glyphicon glyphicon-trash"></span>', $url, ['title' => '删除', 'data' => ['confirm' => '你确定要删除吗?', 'method' => 'post']]);
}, 'send' => function ($url, $model, $key) {
    return $model->status == Article::STATUS_INACTIVE ? Html::a('&nbsp;&nbsp;<span class="glyphicon glyphicon-send"></span>', $url, ['title' => '发布']) : '';
}, 'unsend' => function ($url, $model, $key) {
    return $model->status == Article::STATUS_ACTIVE ? Html::a('&nbsp;&nbsp;<span class="glyphicon glyphicon-comment"></span>', $url, ['title' => '取消发布']) : '';
}]]]]);
?>

</div>
コード例 #8
0
 public function actionEditliftobject()
 {
     $user = new AdminUser();
     if (!$user->checkUserIsLogin()) {
         $this->redirect(Variable::$home_url);
         return;
     }
     $req = Yii::$app->request;
     //创建一个请求对象
     $form = new ArticleForm();
     $form->setScenario('editLiftObject');
     $id = trim($req->get('id'));
     if (!is_numeric($id) || $id == 0) {
         $this->redirect(Variable::$liftObject_url);
         return;
     }
     $articleModel = Article::findOne($id);
     $form->categoryId = $articleModel->categoryId;
     //修改
     if ($form->load($req->post()) && $form->validate()) {
         $isSuccess = (new Article())->updateArticleContent($id, $form->content);
         if ($isSuccess) {
             Yii::$app->session->setFlash(Variable::$flash_success, '资料更新成功');
         } else {
             Yii::$app->session->setFlash(Variable::$flash_error, '资料更新失败,请刷新重试');
         }
         //            $this->redirect(Yii::$app->urlManager->createUrl([Variable::$showLiftObject_url,'id'=>$id]));
     }
     $articleModel = Article::findOne($id);
     $form->content = $articleModel->content;
     $form->title = $articleModel->articleCat->name;
     return $this->render(Variable::$editLiftObject_view, ['model' => $form, 'articleModel' => $articleModel]);
 }
コード例 #9
0
 /**
  * Finds the Article model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return Article the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = Article::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
コード例 #10
0
ファイル: help_left.php プロジェクト: wuwenhan/huoqiwang
        $has_parent_id = Category::find()->where(['parent_id' => $V['id'], 'status' => 1])->asArray()->all();
        //var_dump($has_parent_id);exit;
        $left_second = array();
        if ($has_parent_id) {
            foreach ($has_parent_id as $K1 => $V1) {
                $left_second[] = Category::find()->where(['id' => $V1['id'], 'status' => 1])->asArray()->all();
            }
        }
        if (count($left_second) > 0) {
            $temp = Article::find()->where(['category_id' => $V['id'], 'status' => 1])->asArray()->all();
            foreach ($left_second as $K_slice => $V_slice) {
                $temp = array_merge($temp, $left_second[$K_slice]);
            }
            $left[] = $temp;
        } else {
            $left[] = Article::find()->where(['category_id' => $V['id'], 'status' => 1])->asArray()->all();
        }
    }
} catch (ErrorException $e) {
    $left = array();
}
?>
<style>
	body{
	 background:#fff;
	}
	 #header {
	  border-bottom: 1px solid #dcdcdc;
    }
</style>
コード例 #11
0
ファイル: AloneMethod.php プロジェクト: wuwenhan/huoqiwang
 /**
  * 根据分类查找文章列表
  * @param $title
  * @return array|\yii\db\ActiveRecord[]
  */
 public static function get_category_article($title)
 {
     $category = Category::find()->where(['title' => $title, 'status' => Category::STATUS_ACTIVE])->one();
     if ($category !== null) {
         $cid = $category->id;
         $articles = Article::find()->select(['title', 'intro', 'content', 'logo', 'create_at'])->where(['category_id' => $cid, 'status' => 1])->asArray()->all();
         if ($articles !== null) {
             $data = array('list' => $articles);
             $return_array = array('errorNum' => '0', 'errorMsg' => 'success', 'data' => $data);
             return $return_array;
         } else {
             $return_array = array('errorNum' => '1', 'errorMsg' => '暂无数据', 'data' => null);
             return $return_array;
         }
     } else {
         $return_array = array('errorNum' => '1', 'errorMsg' => '分类信息不存在', 'data' => null);
         return $return_array;
     }
 }
コード例 #12
0
 public function actionEditservice()
 {
     $user = new AdminUser();
     if (!$user->checkUserIsLogin()) {
         $this->redirect(Variable::$home_url);
         return;
     }
     $req = Yii::$app->request;
     //创建一个请求对象
     $form = new ArticleForm();
     $form->setScenario('service');
     $id = trim($req->get('id'));
     if (!is_numeric($id) || $id == 0) {
         $this->redirect(Variable::$employIndex_url);
         return;
     }
     //修改
     if ($form->load($req->post()) && $form->validate()) {
         $isSuccess = (new Article())->updateArticleByService($id, $form->title, $form->useId, $form->keywords, $form->pic, $form->content);
         //            $isSuccess = (new Employ())->updateEmploy($id,$form->department,$form->employName,$form->address,$form->employCode,$form->group,$form->count,$form->money,$form->type,$form->category,$form->description,$form->sendEmail,$form->status);
         if ($isSuccess) {
             Yii::$app->session->setFlash(Variable::$flash_success, '服务项修改成功');
             $this->redirect(Variable::$serviceIndex_url);
             return;
         } else {
             Yii::$app->session->setFlash(Variable::$flash_error, '服务项修改失败,请重试');
             return;
         }
     }
     $articleModel = Article::findOne($id);
     $form->title = $articleModel->title;
     $form->keywords = $articleModel->keywords;
     $form->pic = $articleModel->pic;
     $form->useId = $articleModel->useId;
     $form->content = $articleModel->content;
     return $this->render(Variable::$editService_view, ['model' => $form, 'articleModel' => $articleModel]);
 }
コード例 #13
0
ファイル: AloneMethod.php プロジェクト: wuwenhan/huoqiwang
 /**
  * 判定用户是否有未读消息
  * @param $uid
  * @return array
  */
 public static function is_exit_msg($uid)
 {
     $all_num = Article::find()->select(['id'])->where(['category_id' => '49', 'status' => Article::STATUS_ACTIVE])->asArray()->all();
     $msg_arr = array();
     if ($all_num) {
         foreach ($all_num as $key => $value) {
             $msg_arr[$key] = $value['id'];
         }
     }
     return self::is_msg($msg_arr, $uid);
 }