Esempio n. 1
0
 public function actionUpdate($id)
 {
     $model = $this->findModel($id);
     if ($video = Yii::$app->request->post()) {
         $files = Fileupload::upload();
         $video['img'] = isset($files[0]) ? $files[0] : $model->img;
         $model->set_video_data($video);
         if ($model->save(false)) {
             return $this->render('update', ['msg' => '更新视频成功!', 'model' => $model]);
         } else {
             return $this->render('update', ['msg' => '更新视频失败,请刷新重试!', 'model' => $model]);
         }
     }
     return $this->render('update', ['model' => $model]);
 }
Esempio n. 2
0
 public function actionUpdate($id)
 {
     $xman = $this->findModel($id);
     if ($post = Yii::$app->request->post()) {
         $files = Fileupload::upload();
         $post['head_img'] = isset($files[0]) ? $files[0] : $xman->head_img;
         $xman->set_xman_data($post);
         if ($xman->save(false)) {
             return $this->render('update', ['msg' => '更新主人公成功!', 'model' => $xman]);
         } else {
             return $this->render('update', ['msg' => '更新主人公失败,请刷新重试!', 'model' => $xman]);
         }
     }
     return $this->render('update', ['model' => $xman]);
 }
Esempio n. 3
0
 public function actionUpdate($id)
 {
     $model = $this->view_data['model'] = $this->findModel($id);
     $xmans = $this->findXmans($id);
     foreach ($xmans as $xman) {
         $this->view_data['selected_xman_ids'][] = $xman['id'];
     }
     $this->view_data['all_xman'] = $this->findAllXmans();
     if ($films = Yii::$app->request->post()) {
         $files = Fileupload::upload();
         $films['img'] = isset($files[0]) ? $files[0] : $model->img;
         $model->set_film_data($films);
         if ($model->save(false) && $this->set_film_xman_rel($model->id, $films['xman'])) {
             $this->view_data['selected_xman_ids'] = $films['xman'];
             $this->view_data['msg'] = '更新电影成功!';
             return $this->render('update', $this->view_data);
         } else {
             $this->view_data['msg'] = '更新电影失败,请刷新重试!';
             return $this->render('update', $this->view_data);
         }
     }
     return $this->render('update', $this->view_data);
 }
 public function actionWeixinArticleUpdate($id)
 {
     $request = Yii::$app->request;
     $weixin_article = WeixinArticle::find()->where("id = {$id}")->one();
     if ($request->isPost) {
         $post = $request->post();
         $files = Fileupload::upload();
         if ($files) {
             $post['img'] = isset($files[0]) ? $files[0] : './img/default.jpg';
         }
         $weixin_article->set_weixin_article($post);
         $weixin_article->save();
         // 获取存储后纪录 id
         $weixin_article_id = $weixin_article->id;
         // 重新建立微信文章和栏目的多对多关系
         $article_type = Article_category_rel::WEIXIN_ARTICLE;
         Article_category_rel::deleteAll("article_id = {$weixin_article_id} and article_type = {$article_type}");
         foreach ($post['category'] as $category_id) {
             $article_category_rel = new Article_category_rel();
             $article_category_rel->category_id = $category_id;
             $article_category_rel->article_id = $weixin_article_id;
             $article_category_rel->article_type = Article_category_rel::WEIXIN_ARTICLE;
             $article_category_rel->save();
         }
         // 重新建立微信文章和标签的多对多关系
         $article_type = Article_tag_rel::WEIXIN_ARTICLE;
         Article_tag_rel::deleteAll("article_id = {$weixin_article_id} and article_type = {$article_type}");
         foreach ($post['tag'] as $tag_id) {
             $article_tag_rel = new Article_tag_rel();
             $article_tag_rel->tag_id = $tag_id;
             $article_tag_rel->article_id = $weixin_article_id;
             $article_tag_rel->article_type = Article_tag_rel::WEIXIN_ARTICLE;
             $article_tag_rel->save();
         }
         $weixin_article->category = Article_category_rel::get_all_category_id_by($id);
         $weixin_article->tag = Article_tag_rel::get_all_tag_id_by($id);
         return $this->render("weixin-article-update", ["msg" => "修改成功", 'weixin_article' => $weixin_article, 'id' => $id]);
     }
     // 查看微信文章
     $weixin_article->category = Article_category_rel::get_all_category_id_by($id);
     $weixin_article->tag = Article_tag_rel::get_all_tag_id_by($id);
     return $this->render('weixin-article-update', ['weixin_article' => $weixin_article, 'id' => $id]);
 }