예제 #1
0
파일: Chan.php 프로젝트: procod3R/FoolFuuka
 protected function thread($num = 0, $options = [])
 {
     $this->profiler->log('Controller Chan::thread Start');
     $num = str_replace('S', '', $num);
     try {
         $board = Board::forge($this->getContext())->getThread($num)->setRadix($this->radix)->setOptions($options);
         // get the current status of the thread
         $thread_status = $board->getThreadStatus();
         $last_modified = $thread_status['last_modified'];
         $this->setLastModified($last_modified);
         if (!$this->response->isNotModified($this->request)) {
             $this->response = new StreamedResponse();
             $this->setLastModified($last_modified);
             // execute in case there's more exceptions to handle
             $thread = $board->getComments();
             // get the latest doc_id and latest timestamp for realtime stuff
             $latest_doc_id = $board->getHighest('doc_id')->comment->doc_id;
             $latest_timestamp = $board->getHighest('timestamp')->comment->timestamp;
             $this->builder->getProps()->addTitle(_i('Thread') . ' #' . $num);
             $this->param_manager->setParams(['thread_id' => $num, 'is_thread' => true, 'disable_image_upload' => $thread_status['disable_image_upload'], 'thread_dead' => $thread_status['dead'], 'latest_doc_id' => $latest_doc_id, 'latest_timestamp' => $latest_timestamp, 'thread_op_data' => $thread[$num]['op']]);
             $this->builder->createPartial('body', 'board')->getParamManager()->setParams(['board' => $board->getComments()]);
             $backend_vars = $this->param_manager->getParam('backend_vars');
             $backend_vars['thread_id'] = $num;
             $backend_vars['latest_timestamp'] = $latest_timestamp;
             $backend_vars['latest_doc_id'] = $latest_doc_id;
             $backend_vars['board_shortname'] = $this->radix->shortname;
             if (isset($options['last_limit']) && $options['last_limit']) {
                 $this->param_manager->setParam('controller_method', 'last/' . $options['last_limit']);
                 $backend_vars['last_limit'] = $options['last_limit'];
             }
             $this->param_manager->setParam('backend_vars', $backend_vars);
             if (!$thread_status['closed']) {
                 $this->builder->createPartial('tools_reply_box', 'tools_reply_box');
             }
             $this->profiler->logMem('Controller Chan $this', $this);
             $this->profiler->log('Controller Chan::thread End');
             $this->response->setCallback(function () {
                 $this->builder->stream();
             });
         }
     } catch (\Foolz\Foolfuuka\Model\BoardThreadNotFoundException $e) {
         $this->profiler->log('Controller Chan::thread End Prematurely');
         return $this->error($e->getMessage(), 404);
     } catch (\Foolz\Foolfuuka\Model\BoardException $e) {
         $this->profiler->log('Controller Chan::thread End Prematurely');
         return $this->error($e->getMessage());
     }
     return $this->response;
 }