예제 #1
0
 public function action_delete($article_id)
 {
     $article = Model_Article::find($article_id);
     $article->delete();
     Session::set_flash('notice', 'Article deleted');
     Response::redirect('-admin/articles');
 }
예제 #2
0
 public function action_show($article_id)
 {
     $article = Model_Article::find($this->param('id'));
     $this->title($article->title);
     $this->view = $this->theme->view('articles/show');
     $this->view->set('article', $article);
 }
예제 #3
0
파일: twitter.php 프로젝트: katsuwo/bbs
 function tweet_newArticleBuild($board = null, $article = null)
 {
     if ($board == null || $article == null) {
         return;
     }
     if ($board->type != 3) {
         $longURL = BBS_URL . 'thread' . DS . $board->shortName . DS . $article->id;
         $shortURL = $this->url_shorten_google($longURL);
         if (!$shortURL) {
             $shortURL = $longURL;
         }
         if ($article->commentOf == 0) {
             $text = $shortURL . ' 【' . $board->title . '】にスレッド【' . $article->title . '】が投稿されました。是非ご覧下さい。';
             $this->tweet($text);
         } else {
             $numArray = [1, 10, 30, 50, 100, 300, 500, 1000];
             $th = Model_Article::find($article->commentOf);
             foreach ($numArray as $num) {
                 if ($th->commentCount == $num) {
                     if ($num == 1) {
                         $text = $shortURL . ' おめでとうございます!掲示板' . '【' . $board->title . '】 のスレッド【' . $th->title . '】に初コメントが付きました!。是非御覧ください。';
                     } else {
                         $text = $shortURL . ' おめでとうございます!掲示板' . '【' . $board->title . '】のスレッド【' . $th->title . '】のコメントが' . $th->commentCount . 'になりました!。是非御覧ください。';
                     }
                     $this->tweet($text);
                     break;
                 }
             }
         }
     }
 }
예제 #4
0
 public function action_delete($id = null)
 {
     if ($article = Model_Article::find($id)) {
         $article->delete();
         Session::set_flash('success', 'Deleted article #' . $id);
     } else {
         Session::set_flash('error', 'Could not delete article #' . $id);
     }
     Response::redirect('articles');
 }
예제 #5
0
 /**
  * Дейсвтие-обработчик ПОСТ-запроса на изменения кол-ва комментов ВК
  */
 public function action_change_comments_num()
 {
     if (\Input::method() == 'POST') {
         $id = (int) \Input::post('id');
         $num = (int) \Input::post('num');
         if ($id != 0) {
             $article = \Model_Article::find($id);
             if ($article) {
                 $article->vk_comments_count = $num;
                 $article->save();
                 return \View::forge('empty', array());
             }
         }
     }
 }
예제 #6
0
 function delete_index()
 {
     if (Input::get('id')) {
         $articulo = Model_Article::find(Input::get('id'));
         if ($articulo) {
             $articulo->delete();
             $respuesta = array("success" => "true", "data" => array('msg' => 'Articulo Eliminado'));
             $this->response($respuesta, 200);
         } else {
             $respuesta = array("error" => "true", "msg" => 'id No encontrado, No se pudo borrar');
             $this->response($respuesta, 404);
         }
     } else {
         $respuesta = array("error" => "true", "msg" => 'No encontrado, No se pudo borrar');
         $this->response($respuesta, 404);
     }
 }
예제 #7
0
 /**
  * Display detailed page of Article
  *
  * @param void
  * @access public
  * @author Nguyen Van Hiep
  *
  * @version 1.0
  * @since 1.0
  */
 public function action_view()
 {
     $art_check = Model_Article::get_art_from_slug(Uri::segment(2));
     if (!$art_check) {
         Response::redirect('common/error');
     }
     $uri = explode('-', Uri::string());
     $id = array_pop($uri);
     $art = Model_Article::find($id);
     $cat = Model_Categories::get_cat_from_slug(Uri::segment(1));
     $related_arts = Model_Article::articles_of_cat_limit($cat->id, $this->lang, $id);
     if (!$art) {
         Session::set_flash('error', __('message.art_not_exist'));
         Response::redirect('common/404');
     }
     $art->views = $art->views + 1;
     $art->save();
     if ($cat->display_type == DS_SANPHAM) {
         $this->template = \View::forge('customer/template_sanpham_detail');
         $view = View::forge('customer/article/detail_sp_slide');
     } elseif ($cat->display_type == DS_MONAN) {
         $this->template = \View::forge('customer/template_monan');
         $view = View::forge('customer/article/detail_monan_slide');
     } elseif ($cat->display_type == QUY_TRINH_SX) {
         $view = View::forge('customer/article/detail_quytrinhsx');
     } else {
         $view = View::forge('customer/article/detail');
     }
     $view->art = $art;
     $view->related_arts = $related_arts;
     $view->cat = $cat;
     if (!empty($cat->parent_id)) {
         $view->p_cat = Model_Categories::find($cat->parent_id);
     }
     // data to display menu
     $this->template->cats = Model_Categories::get_cats_home($this->lang);
     $this->template->pepper_arts = Model_Article::pepper_artilces($this->lang);
     $this->template->title = Security::strip_tags($art->title);
     $this->template->content = $view;
 }
예제 #8
0
 /**
  * Delete Slider Image
  *
  * @param int $id Image ID
  *
  * @author Nguyen Van Hiep
  * @access public
  *
  * @version 1.0
  * @since 1.0
  */
 public function action_delete($id = null, $current_cat_view = '', $current_lang_view = '')
 {
     if ($current_cat_view != 'cat' and $current_lang_view != 'lang') {
         $current_cat_view = "cat={$current_cat_view}&lang={$current_lang_view}";
     } elseif ($current_cat_view != 'cat') {
         $current_cat_view = "cat={$current_cat_view}&lang=";
     } elseif ($current_lang_view != 'lang') {
         $current_cat_view = "cat=&lang={$current_lang_view}";
     } else {
         $current_cat_view = "cat=&lang=";
     }
     $a = Model_Article::find($id);
     if (!$a) {
         Session::set_flash('error', __('message.art_not_exists'));
         Response::redirect("admin/article?{$current_cat_view}");
     }
     // Delete image
     if (Fuel\Core\File::exists($this->dir . $a->thumb)) {
         File::delete($this->dir . $a->thumb);
     }
     Model_ArtCat::del_art_cat($id);
     if ($a->delete()) {
         Session::set_flash('success', __('message.art_deleted'));
         Response::redirect("admin/article?{$current_cat_view}");
     } else {
         Session::set_flash('error', __('message.cannot_del_art'));
     }
 }
예제 #9
0
 /**
  * Удаление статьи
  */
 public function action_delete($id = null)
 {
     is_null($id) and \Response::redirect('admin/articles');
     if ($article = \Model_Article::find($id)) {
         $article->delete();
         \Session::set_flash('success', 'Статья успешно удалена');
     } else {
         \Session::set_flash('error', e('Could not delete articles_i18n #' . $id));
     }
     \Response::redirect('admin/articles');
 }
예제 #10
0
파일: article__.php 프로젝트: sajans/cms
 public function action_remove_pic()
 {
     $article_id = Input::post('article_id');
     $img_name = Input::post('image');
     $upload_id = Input::post('upload_id');
     $type_id = Input::post('type_id');
     if ($upload_id && $type_id) {
         if ($img_name) {
             $article = Model_Article::find($article_id);
             $uploads = $article->getUploads(7, 1);
             $uploads->removeFiles();
             unset($article->uploads[$uploads->id]);
             $article->save();
             //$model = new Model_Upload();
             //$output = $model->removeProfileLogo($img_name, $upload_id, $type_id);
             $xx["msg"] = "photo_deleted_successfully";
             $xx["status"] = "success";
         } else {
             $xx["msg"] = "Delete Fail";
             $xx["status"] = "fail";
         }
         $data['response'] = json_encode($xx);
     } else {
         $xx["msg"] = "Upload id or upload type not found";
         $xx["status"] = "false";
         $data['response'] = json_encode($xx);
     }
     return Response::forge(View::forge('response', $data, false));
 }
예제 #11
0
파일: article.php 프로젝트: sajans/cms
 public function action_edit($id = null)
 {
     is_null($id) and Response::redirect('article');
     if (!($article = Model_Article::find($id))) {
         Session::set_flash('error', 'Could not find article #' . $id);
         Response::redirect('article');
     }
     $val = Model_Article::validate('edit');
     if ($val->run()) {
         $article->category_id = Input::post('category_id');
         $article->name = Input::post('name');
         $article->url_title = str_replace(" ", "-", strtolower(Input::post('name')));
         $article->description = Input::post('description');
         $article->keywords = Input::post('keywords');
         $article->image = Input::post('image');
         $article->editor_id = $this->current_user->id;
         if ($article->save()) {
             Session::set_flash('success', 'Updated article #' . $id);
             Response::redirect('admin/article');
         } else {
             Session::set_flash('error', 'Could not update article #' . $id);
         }
     } else {
         if (Input::method() == 'POST') {
             $article->category_id = $val->validated('category_id');
             $article->name = $val->validated('name');
             $article->description = $val->validated('description');
             $article->keywords = $val->validated('keywords');
             $article->image = $val->validated('image');
             Session::set_flash('error', $val->error());
         }
         $this->template->set_global('article', $article, false);
     }
     $this->template->title = "Articles";
     $data['categories'] = Model_Category::getSelectList();
     $this->template->content = View::forge('admin/article/create', $data);
 }
예제 #12
0
파일: bbs.php 프로젝트: katsuwo/bbs
 /**
  * 書き込みを削除
  * @param type $ar 書き込み
  */
 public function deleteArticle($ar)
 {
     //書き込み本体
     $articleId = $ar->id;
     $commentOf = $ar->commentOf;
     $this->deleteAttach($ar);
     $ar->delete();
     //スレッド元の総コメント数修正
     if ($commentOf != 0) {
         $masterPost = Model_Article::find($commentOf);
         if ($masterPost != null) {
             $masterPost->commentCount--;
             $masterPost->save();
         }
     }
     //レス
     $query = Model_Article::query()->where('commentOf', $articleId);
     $comments = $query->get();
     foreach ($comments as $comment) {
         $this->deleteAttach($comment);
         $comment->delete();
     }
 }
예제 #13
0
파일: article.php 프로젝트: sajans/cms
 public function action_upload_pic()
 {
     $article = Model_Article::find(Input::get('object_id'));
     $output = $article->uploadPicture();
     $data['response'] = json_encode($output);
     return Response::forge(View::forge('response', $data, false));
 }