/**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $topics = Topic::all();
     $markdown = new Markdown();
     $transfer_count = 0;
     $convert_count = 0;
     foreach ($topics as $topic) {
         if (empty($topic->body_original)) {
             // store the original data
             $topic->body_original = $topic->body;
             // convert to markdown
             $topic->body = $markdown->convertMarkdownToHtml($topic->body);
             $topic->save();
             $transfer_count++;
         } else {
             // convert to markdown
             $topic->body = $markdown->convertMarkdownToHtml($topic->body_original);
             $topic->save();
             $convert_count++;
         }
     }
     $this->info("Transfer old data count: " . $transfer_count);
     $this->info("Convert original to body count: " . $convert_count);
     $this->info("It's Done, have a good day.");
 }
Beispiel #2
0
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     // get all the nerds
     $topics = Topic::all();
     // load the view and pass the nerds
     return View::make('topics.index')->with('topics', $topics);
 }
Beispiel #3
0
 /**
  * Список тем
  */
 public function forum($id)
 {
     if (!($forum = Forum::find_by_id($id))) {
         App::abort('default', 'Данного раздела не существует!');
     }
     $total = Topic::count(['conditions' => ['forum_id = ?', $id]]);
     $page = App::paginate(Setting::get('topics_per_page'), $total);
     $topics = Topic::all(['conditions' => ['forum_id = ?', $id], 'offset' => $page['offset'], 'limit' => $page['limit'], 'order' => 'updated_at desc', 'include' => ['forum', 'post_count', 'post_last' => ['user']]]);
     /*		$topics = Topic::all([
     			'select' => 't.*, p.user_id post_user, p.created_at post_created',
     			'from' => 'topics as t',
     			'conditions' => ['t.forum_id = ?', $id],
     			'joins' => ['LEFT JOIN (
     					SELECT topic_id, MAX(created_at) AS max FROM posts
     					GROUP BY topic_id
     				) AS latest ON t.id = latest.topic_id
     				LEFT JOIN posts p ON p.created_at = latest.max
     				AND p.topic_id = latest.topic_id'],
     			'offset' => $page['offset'],
     			'limit' => $page['limit'],
     			'order' => 't.updated_at desc',
     			'include' => [
     				'forum',
     				'post_count',
     			],*/
     $crumbs = ['/forum' => 'Форум', $forum->title];
     if ($forum->parent_id) {
         $crumbs = ['/forum' => 'Форум', '/forum/' . $forum->parent_id => $forum->parent()->title, $forum->title];
     }
     App::view('forums.forum', compact('forum', 'topics', 'page', 'crumbs'));
 }
Beispiel #4
0
 public function forumget($page)
 {
     if (Topic::all()->count() > ($page - 1) * 20) {
         $topics = Topic::take(20)->skip(($page - 1) * 20)->orderBy("sn", "desc")->get();
         for ($i = 0; $i < count($topics); $i++) {
             $writer = Student::find($topics[$i]->stu_id);
             $export[] = array("id" => urlencode($topics[$i]->id), "title" => urlencode(str_replace("\\'", "'", addslashes($topics[$i]->title))), "writer" => urlencode(str_replace("\\'", "'", addslashes($writer->nick))), "body" => urlencode(str_replace("\\'", "'", base64_encode($topics[$i]->body))), "file" => urlencode(str_replace("\\'", "'", addslashes($topics[$i]->file))), "date" => $topics[$i]->day, "view" => $topics[$i]->view);
         }
     } else {
         $export[] = array("id" => " ", "title" => " ", "writer" => " ", "body" => " ", "file" => " ", "date" => " ", "view" => " ");
     }
     return urldecode(json_encode($export));
 }
 /**
  * Execute the console command.
  *
  * @return mixed
  */
 public function fire()
 {
     $topics = Topic::all();
     $transfer_count = 0;
     foreach ($topics as $topic) {
         if (empty($topic->excerpt)) {
             $topic->excerpt = Topic::makeExcerpt($topic->body);
             $topic->save();
             $transfer_count++;
         }
     }
     $this->info("Transfer old data count: " . $transfer_count);
     $this->info("It's Done, have a good day.");
 }
Beispiel #6
0
 public function extractData()
 {
     $gifts = Gift::all();
     //礼品
     $topics = Topic::all();
     // 话题
     $gift_posters = GiftPoster::all();
     //礼品海报
     $gift_photo_intros = GiftPhotoIntro::all();
     //图文介绍
     // fwrite(fopen(app_path().'\storage\mysq.txt', 'w'), 'man');
     file_put_contents(app_path() . '/storage/gifts.txt', json_encode($gifts));
     file_put_contents(app_path() . '/storage/topics.txt', json_encode($topics));
     file_put_contents(app_path() . '/storage/gift_posters.txt', json_encode($gift_posters));
     file_put_contents(app_path() . '/storage/gift_photo_intros.txt', json_encode($gift_photo_intros));
     return 0;
 }
 public function show($tid = 'all')
 {
     if ($tid == 'all') {
         if (Input::has('answers')) {
             $topics = Topic::with('answers')->get()->toArray();
         } else {
             $topics = Topic::all();
         }
         return Response::make(['success' => true, 'data' => $topics]);
     } else {
         try {
             $topic = Topic::findOrFail($tid);
             $topic->answers = $topic->answers->toArray();
             return Response::make(['success' => true, 'data' => $topic]);
         } catch (Exception $e) {
             return Response::make(['error' => true, 'message' => 'Sorry but that topic cannot be found!', 'data' => null], 404);
         }
     }
 }
Beispiel #8
0
 public function Welcome()
 {
     $lastHolText = Setting::where('item', '=', 'lastHolText')->first()->value;
     $lastHolDate = Setting::where('item', '=', 'lastHolDate')->first()->value;
     $export[] = array("id" => " ", "title" => $lastHolText, "day" => $lastHolDate, "writer" => " ", "body" => " ", "file" => " ", "image" => " ", "link" => " ", "view" => " ");
     if (Newsstu::all()->count() > 0) {
         $newsstu = Newsstu::take(2)->orderBy("id", "desc")->get();
         for ($i = 0; $i < count($newsstu); $i++) {
             $export[] = array("id" => " ", "title" => urlencode(trim($newsstu[$i]->web_main_top_title)), "day" => urlencode(trim($newsstu[$i]->web_main_top_day)), "writer" => urlencode(trim($newsstu[$i]->web_main_where)), "body" => urlencode(base64_encode($newsstu[$i]->web_main_data)), "file" => urlencode(trim($newsstu[$i]->web_main_link)), "image" => urlencode(trim($newsstu[$i]->web_main_file)), "link" => urlencode(trim($newsstu[$i]->web_main_outside_link)), "view" => " ");
         }
     }
     if (Topic::all()->count() > 0) {
         $topics = Topic::take(2)->orderBy("sn", "desc")->get();
         for ($i = 0; $i < count($topics); $i++) {
             $writer = Student::find($topics[$i]->stu_id);
             $export[] = array("id" => urlencode($topics[$i]->id), "title" => urlencode(addslashes($topics[$i]->title)), "day" => " ", "writer" => urlencode(addslashes($writer->nick)), "body" => urlencode(base64_encode($topics[$i]->body)), "file" => urlencode(addslashes($topics[$i]->file)), "image" => " ", "link" => " ", "view" => urlencode($topics[$i]->view));
         }
     }
     return urldecode(json_encode($export));
 }
Beispiel #9
0
 public static function count()
 {
     return Topic::all()->count();
 }
 /**
  * Display a listing of the resource.
  *
  * @return Response
  */
 public function index()
 {
     $topics = Topic::all();
     $categories = Category::all();
     return View::make('forum')->with(array('topics' => $topics, 'categories' => $categories));
 }
Beispiel #11
0
<?php

/*
|--------------------------------------------------------------------------
| Application Routes
|--------------------------------------------------------------------------
|
| Here is where you can register all of the routes for an application.
| It's a breeze. Simply tell Laravel the URIs it should respond to
| and give it the Closure to execute when that URI is requested.
|
*/
Route::get('/', function () {
    return View::make('index')->with("topics", Topic::all());
});
Route::get('topics/{id}', function ($id) {
    $oTopic = Topic::find($id);
    return View::make('topic')->with('topic', $oTopic);
});
Route::get('posts/{id}', function ($id) {
    $oPost = Post::find($id);
    return View::make('post')->with('post', $oPost);
});
Route::get('users/new', function () {
    return View::make('newUserForm');
});
Route::get('users/{id}/edit', function ($id) {
    $oUser = User::find($id);
    return View::make('editUserForm')->with('user', $oUser);
});
Route::put('users/{id}', function ($id) {
 public function home()
 {
     $scriptures = Scripture::all();
     $topics = Topic::all();
     require_once 'views/scripture/home.php';
 }