public function getIndex()
 {
     if (Input::get('_request', 'http') == "http") {
         $this->layout->body = View::make('page.all_news');
     } elseif (Input::get('_request', 'http') == "ajax") {
         return News::all()->toJson();
     }
 }
Esempio n. 2
0
 public function index()
 {
     $news = News::all();
     return View::make('admin.pages.news.index')->with(['news' => $news]);
 }
 public function deleteNewsInfo()
 {
     $id = Input::get('id');
     $deleteReserveInfo = News::find($id);
     if ($deleteReserveInfo->delete()) {
         $allNews = News::all();
         foreach ($allNews as $allNew) {
             $response[] = array("ban_id" => $allNew['id'], "ban_title" => $allNew['title'], "ban_content" => $allNew['content']);
         }
     }
     return $response;
 }
Esempio n. 4
0
 public function saveItem()
 {
     $cat_id = Input::get('cat_id');
     $item_id = Input::get('id');
     //获取表单
     if ($cat_id == 0) {
         //新闻编辑
         $title = Input::get('title');
         $content = Input::get('content');
         $abstract = Input::get('abstract');
         $item = News::find($item_id);
     } else {
         if ($cat_id == 1) {
             //项目编辑
             $title = Input::get('title');
             $content = Input::get('content');
             $abstract = Input::get('abstract');
             $begin_time = Input::get('begin_time');
             $end_time = Input::get('end_time');
             $item = Researches::find($item_id);
         } else {
             if ($cat_id == 2) {
                 //通知编辑
                 //
                 $title = Input::get('title');
                 $content = Input::get('content');
                 $item = Notices::find($item_id);
             } else {
                 if ($cat_id == 3) {
                     //课程编辑
                     $course_name = Input::get('course_name');
                     $course_info = Input::get('course_info');
                     $teacher_address = Input::get('teacher_address');
                     $teacher_mail = Input::get('teacher_mail');
                     $TA_name = Input::get('TA_name');
                     $TA_address = Input::get('TA_address');
                     $TA_mail = Input::get('TA_mail');
                     $item = Courses::find($item_id);
                     $homeworks = Courses::find($item_id)->homework;
                     $coursewares = Courses::find($item_id)->courseware;
                     $course_notices = Courses::find($item_id)->comments;
                     foreach ($course_notices as $notice) {
                         $update_notice = Comments::find($notice->id);
                         $update_notice->comment = Input::get('course_notice_content' . $notice->id);
                         $update_notice->updated_at = date("Y-m-d H:i:s");
                         $update_notice->save();
                     }
                     foreach ($homeworks as $homework) {
                         //对已有项进行编辑
                         $delete_or_not = Input::get('homework_delete' . $homework->id);
                         if ($delete_or_not) {
                             //如果标记为删除则将已有作业进行删除
                             $delete_item = Homework::find($homework->id);
                             $delete_item->delete();
                         } else {
                             $update_item = Homework::find($homework->id);
                             $update_item->homework_item = Input::get('homework_label' . $homework->id);
                             $update_item->submit_deadline = Input::get('homework_submit_time' . $homework->id);
                             $update_item->deliver_deadline = Input::get('homework_deliver_time' . $homework->id);
                             $update_item->updated_at = date("Y-m-d H:i:s");
                             $update_item->save();
                         }
                     }
                     foreach ($coursewares as $courseware) {
                         $update_item = Courseware::find($courseware->id);
                         $update_item->label = Input::get('courseware_label' . $courseware->id);
                         $update_file_source = 'courseware_ppt' . $courseware->id;
                         $new_source = HomeController::upload_course($item_id, $update_file_source);
                         if ($new_source != "") {
                             //跟新源的同时将旧的课件删除
                             HomeController::delete_file($update_item->source);
                             $update_item->source = $new_source;
                         } else {
                         }
                         $update_item->updated_at = date("Y-m-d H:i:s");
                         $update_item->save();
                     }
                 }
             }
         }
     }
     //保存数据
     if ($item) {
         //表中已经存在该条目
         if ($cat_id == 0) {
             //新闻编辑
             $item->title = $title;
             $item->content = $content;
             $item->abstract = $abstract;
             $item->save();
             return Redirect::to(URL::to('/news-detail', [$item_id]));
         } else {
             if ($cat_id == 1) {
                 //项目编辑
                 $item->title = $title;
                 $item->content = $content;
                 $item->abstract = $abstract;
                 $item->begin_time = $begin_time;
                 $item->end_time = $end_time;
                 $item->save();
                 return Redirect::to(URL::to('/research-detail', [$item_id]));
             } else {
                 if ($cat_id == 2) {
                     //通知编辑
                     $item->title = $title;
                     $item->content = $content;
                     $item->save();
                     return Redirect::to(URL::to('/notice-detail', [$item_id]));
                 } else {
                     if ($cat_id == 3) {
                         //课程编辑
                         $item->course_name = $course_name;
                         $item->course_info = $course_info;
                         $item->teacher_address = $teacher_address;
                         $item->teacher_mail = $teacher_mail;
                         $item->TA_name = $TA_name;
                         $item->TA_address = $TA_address;
                         $item->TA_mail = $TA_mail;
                         $item->save();
                         $course_notices_add_count = Input::get('course_notice_add_count');
                         if ($course_notices_add_count) {
                             //增加新的通知
                             for ($i = 1; $i <= $course_notices_add_count; $i++) {
                                 $add_or_not = Input::get('course_notice_add_or_not' . $i);
                                 if (!$add_or_not) {
                                     $notice = new Comments();
                                     $notice->course_id = $item_id;
                                     $notice->comment = Input::get('course_notice_add_content' . $i);
                                     $notice->created_at = date("Y-m-d H:i:s");
                                     $notice->updated_at = date("Y-m-d H:i:s");
                                     $notice->save();
                                 }
                             }
                         }
                         $homework_add_count = Input::get('homework_add_count');
                         if ($homework_add_count) {
                             //当添加了新的作业,将其添加到homework数据库中
                             for ($i = 1; $i <= $homework_add_count; $i++) {
                                 $add_or_not = Input::get('homework_add_or_not' . $i);
                                 if (!$add_or_not) {
                                     $homework = new Homework();
                                     $homework->course_id = $item_id;
                                     $homework->homework_item = Input::get('homework_add_item' . $i);
                                     $homework->submit_deadline = Input::get('homework_add_submit_time' . $i);
                                     $homework->deliver_deadline = Input::get('homework_add_deliver_time' . $i);
                                     $homework->created_at = date("Y-m-d H:i:s");
                                     $homework->updated_at = date("Y-m-d H:i:s");
                                     $homework->save();
                                 }
                             }
                         }
                         $courseware_add_count = Input::get('courseware_add_count');
                         if ($courseware_add_count) {
                             //当添加了新的课件,将其添加到courseware表中
                             for ($i = 1; $i <= $courseware_add_count; $i++) {
                                 $courseware = new Courseware();
                                 $courseware->course_id = $item_id;
                                 $courseware->label = Input::get('courseware_add_label' . $i);
                                 //先将课件上传到数据库中
                                 $file_source = 'courseware_add_source' . $i;
                                 $courseware->source = HomeController::upload_course($item_id, $file_source);
                                 $courseware->created_at = date("Y-m-d H:i:s");
                                 $courseware->updated_at = date("Y-m-d H:i:s");
                                 $courseware->save();
                             }
                         }
                         return Redirect::to(URL::to('/course', [$item_id]));
                     }
                 }
             }
         }
     } else {
         //对已有条目进行更新
         if ($cat_id == 0) {
             //新闻条目
             News::insert(['title' => $title, 'abstract' => $abstract, 'content' => $content]);
             $item = News::all()->last();
             return Redirect::to(URL::to('/news-detail', [$item->id]));
         } else {
             if ($cat_id == 1) {
                 //项目条目
                 Researches::insert(['title' => $title, 'abstract' => $abstract, 'content' => $content, 'begin_time' => $begin_time, 'end_time' => $end_time]);
                 $item = Researches::all()->last();
                 return Redirect::to(URL::to('/research-detail', [$item->id]));
             } else {
                 if ($cat_id == 2) {
                     //通知编辑
                     Notices::insert(['title' => $title, 'content' => $content]);
                     $item = Notices::all()->last();
                     return Redirect::to(URL::to('/notice-detail', [$item->id]));
                 } else {
                     if ($cat_id == 3) {
                         Courses::insert(['course_name' => $course_name, 'course_info' => $course_info, 'teacher_address' => $teacher_address, 'TA_name' => $TA_name, 'TA_address' => $TA_address]);
                         $item = Courses::all()->last();
                         return Redirect::to(URL::to('/course', [$item->id]));
                     }
                 }
             }
         }
     }
     //return View::make('/news-detail',[$item_id]);
 }
Esempio n. 5
0
          </div>
          <div class="input-group">
            <span class="input-group-addon" id="basic-addon1">Content</span>
            <input type="text" class="form-control" id= "content" name= "content" placeholder="content" aria-describedby="basic-addon1">
          </div>
          <button type="submit" id="saveInfo" class="btn btn-info">Save Information</button> 
          <button type="button" id="updateInfo"class="btn btn-warning">Update Information</button>    
      </div>
      <div class="col-md-8">
        <div class="list-group">
          <a href="#" class="list-group-item active">
           News
          </a>
          <div id="guest_list">
            <?php 
$allNews = News::all();
?>
            @if(!empty($allNews))
              @foreach($allNews as $allNew)
  	            <div class="input-group" id="reserve{{$allNew['id']}}">
  	            <a href="javascript:void(0)" class="list-group-item">{{$allNew['title']}}</a>
  	            <span class="input-group-addon" data-type="edit" data-id="{{$allNew['id']}}" style="cursor:pointer">Edit</span>
  	            <span class="input-group-addon" data-type="delete" data-id="{{$allNew['id']}}" style="cursor:pointer">Delete</span>
  	            </div>
              @endforeach
            @endif
          <div>
        </div>
      </div>
    </div>
  </div>
Esempio n. 6
0
 public function showAll()
 {
     $news = News::all();
     return View::make('news.show-all')->with('news', $news)->with('page_title', 'News');
 }
Esempio n. 7
0
 /**
  * RSS лента
  */
 public function rss()
 {
     $news_list = News::all(['limit' => 15, 'order' => 'created_at desc', 'include' => ['user']]);
     header("Content-type:application/rss+xml; charset=utf-8");
     App::view('news.rss', compact('news_list'));
 }
@include('layout.master')
<div class="container" style="margin-top:80px;text-align:center">
<h1>FPP News</h1>
<?php 
$news = News::all();
foreach ($news as $article) {
    ?>
<div class="panel panel-default" style="margin-top:40px;">
	<div class="panel-heading">
	    <h3 class="panel-title">{{$article->title}}</h3>
	  </div>
	  <div class="panel-body">
	   {{ str_limit($article->content, $limit = 300, $end = '...') }}
	   @if(strlen($article->content) > 300)<br><br><a href="/news/{{$article->slug}}">Read More</a>@endif
	  </div>
</div>
<?php 
}
?>
</div>
@include('layout.footer')
 /**
  * Display a listing of news
  *
  * @return Response
  */
 public function index()
 {
     $news = News::all();
     return View::make('news.index', compact('news'));
 }
 /**
  * Display the list of the news
  *
  * @return Response
  */
 public function list_news()
 {
     $news = News::all();
     return View::make('admin.news', ['news' => $news]);
 }
Esempio n. 11
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $message = Session::get('message');
     $news = News::all();
     return View::make('news', ['news' => $news, 'message' => $message]);
 }