예제 #1
0
파일: Search.php 프로젝트: bstats/b-stats
 public function __construct(Board $board, array $path)
 {
     parent::__construct($board);
     $topLinks = div('', 'topLinks')->append('[' . a('Home', '/index') . ']')->append(' [' . a('Return', '/' . $this->board->getName() . '/') . ']');
     if (!$board->isSwfBoard()) {
         $topLinks->append(' [' . a('Catalog', '/' . $this->board->getName() . '/catalog') . ']');
     }
     $this->appendToBody($topLinks);
     $this->appendToBody(el('h2', 'Board Search'));
     try {
         $method = $path[3] ?? "";
         if (method_exists(self::class, $method)) {
             $this->perPage = (int) get('perpage', 250);
             $this->page = (int) get('page', 0);
             $this->start = $this->perPage * $this->page;
             $result = $this->{$path[3]}($path[4] ?? NULL);
             $this->appendToBody(div($result->count . ' results.', 'centertext'));
             $pages = $this->makePageSelector($result->count);
             $this->appendToBody($pages);
             $i = $this->start + 1;
             foreach ($result->result as $post) {
                 $this->appendToBody(div($i++ . " >>", 'sideArrows') . PostRenderer::renderPost($post));
             }
             $this->appendToBody($pages);
         } else {
             $this->appendToBody("<h3>Invalid search parameter '{$method}' provided</h3>");
         }
     } catch (Exception $e) {
         $this->appendToBody("<h3>Error: {$e->getMessage()}</h3>");
     }
     $this->appendToBody('<hr>' . $topLinks);
 }
예제 #2
0
파일: Catalog.php 프로젝트: bstats/b-stats
 public function __construct(ImageBoard\Board $board)
 {
     parent::__construct($board);
     if ($board->isSwfBoard()) {
         //throw new Exception("Catalogs don't work on upload boards");
     }
     $this->addToHead("<link rel='stylesheet' href='/css/bstats-catalog.css' type='text/css'>");
     $catalog = OldModel::getCatalog($board, false);
     $this->appendToBody(div('', 'topLinks navLinks')->append('[' . a('Home', '/index') . ']')->append(' [' . a('Return', '/' . $board->getName() . '/') . ']') . '<br/><br/>');
     $html = div('', 'extended-small')->set('id', 'threads');
     while ($thread = $catalog->fetch_assoc()) {
         $post = new Post($thread, $board);
         $html->append(PostRenderer::renderPost($post, PostRenderer::DISPLAY_CATALOG));
     }
     $this->appendToBody($html);
 }
예제 #3
0
 public function __construct(Post $p)
 {
     parent::__construct($p->board);
     $this->appendToBody(el('h2', 'Orphaned Post') . div('This post was found, but its thread is nowhere to be seen!', 'centertext'));
     $this->appendToBody(div('>>', 'sideArrows') . PostRenderer::renderPost($p));
 }
예제 #4
0
파일: Thread.php 프로젝트: bstats/b-stats
 /**
  * <code>Thread::displayThread</code> displays all the posts in a thread in 4chan style
  *
  * @return string Thread in HTML form
  */
 function displayThread()
 {
     $ret = "<div class='thread' id='t" . $this->threadId . "'>";
     $op = array_shift($this->posts);
     $ret .= PostRenderer::renderPost($op, PostRenderer::DISPLAY_OP, $this->sticky, $this->closed);
     foreach ($this->posts as $p) {
         $ret .= "<div class='sideArrows'>&gt;&gt;</div>" . PostRenderer::renderPost($p);
     }
     $ret .= "</div>";
     return $ret;
 }
예제 #5
0
 public static function post(array $path) : array
 {
     if (count($path) < 5) {
         throw new InvalidRequestURIException();
     }
     $board = strtolower(alphanum($path[3]));
     $id = $path[4];
     $model = Model::get();
     $post = $model->getPost($model->getBoard($board), $id);
     if (count($path) === 6 && $path[5] == 'html') {
         $content = PostRenderer::renderPost($post);
         return ["html" => $content];
     }
     return $post->asArray();
 }