From 0629bf68f7eee1fd88d9227124b93a984c1868b9 Mon Sep 17 00:00:00 2001 From: Savetheinternet Date: Wed, 5 Oct 2011 23:53:43 +1100 Subject: use template files instead of hardcoded HTML for generating psots --- inc/display.php | 290 ++++---------------------------------------------------- 1 file changed, 21 insertions(+), 269 deletions(-) (limited to 'inc/display.php') diff --git a/inc/display.php b/inc/display.php index fc15c152..f544b88c 100644 --- a/inc/display.php +++ b/inc/display.php @@ -266,144 +266,9 @@ } public function build($index=false) { - global $board, $config, $memcached, $debug; - - if(!$this->mod && $config['memcached']['enabled']) { - if($built = $memcached->get($this->memcached_key($index))) { - if($config['debug']) { - $debug['memcached'][] = $this->memcached_key($index); - } - return $built; - } - } - - $built = '
' . - '

' . - // Delete - '' - - // Poster ID - . ($config['poster_ids'] ? - ' ID: ' . poster_id($this->ip, $this->thread) - : '') - - . ' No.' . - // JavaScript cite - ''.$this->id.'' . - '

'; - - if($this->embed) { - // Embedded video (or something else; doesn't have to be a video really) - $built .= - // Actual embedding - $this->embed; - } elseif(!empty($this->file) && $this->file != 'deleted') { - // File info - $built .= '

' . - 'File: ' . $this->file . ' ' . - '(' . - ($this->thumb == 'spoiler' ? - 'Spoiler Image, ' - : '') . - // Filesize - format_bytes($this->filesize) . - // File dimensions - ($this->filex && $this->filey ? - ', ' . $this->filex . 'x' . $this->filey - : '' ); - // Aspect Ratio - if($config['show_ratio'] && $this->filex && $this->filey) { - $fraction = fraction($this->filex, $this->filey, ':'); - $built .= ', ' . $fraction; - } - if($config['show_filename']) { - // Filename - $built .= ', ' . - (strlen($this->filename) > $config['max_filename_display'] ? - '' . - substr($this->filename, 0, $config['max_filename_display']) . '…' . - '' - : - $this->filename - ); - } - - $ext = explode('.', $this->file); - $ext = $ext[1]; - $built .= ')

' . - - // Thumbnail - 'thumb == 'file' ? ' class="file"' : '') . - '>'; - } elseif($this->file == 'deleted') { - $built .= ''; - } - - $built .= $this->postControls(); - - // Body - $built .= '

' . ($index ? truncate($this->body, $this->link()) : $this->body) . '


'; - - if(!$this->mod && $config['memcached']['enabled']) { - $memcached->set($this->memcached_key($index), $built, time() + $config['memcached']['timeout']); - } + global $board, $config; - return $built; - } - - function memcached_key($index) { - global $board; - return 'post_' . md5($this->body) . '_' . ($this->file ? $this->file : '-') . '_' . ($index ? 'index_' : '') . $board['uri'] . '_' . $this->id; + return Element('post_reply.html', Array('config' => $config, 'board' => $board, 'post' => &$this, 'index' => $index)); } }; @@ -502,147 +367,34 @@ return $built; } + public function ratio() { + return fraction($this->filex, $this->filey, ':'); + } + public function build($index=false) { - global $board, $config; + global $board, $config, $memcached, $debug; - if($this->embed) { - // Embedded video (or something else; doesn't have to be a video really) - $built = - // Actual embedding - $this->embed; - } elseif(!empty($this->file) && $this->file != 'deleted') { - // File info - $built = '

' . - 'File: ' . $this->file . ' ' . - '(' . - ($this->thumb == 'spoiler' ? - 'Spoiler Image, ' - : '') . - // Filesize - format_bytes($this->filesize) . - // File dimensions - ($this->filex && $this->filey ? - ', ' . $this->filex . 'x' . $this->filey - : '' ); - // Aspect Ratio - if($config['show_ratio'] && $this->filex && $this->filey) { - $fraction = fraction($this->filex, $this->filey, ':'); - $built .= ', ' . $fraction; - } - if($config['show_filename']) { - // Filename - $built .= ', ' . - (strlen($this->filename) > $config['max_filename_display'] ? - '' . - substr($this->filename, 0, $config['max_filename_display']) . '…' . - '' - : - $this->filename - ); + if(!$this->mod && $config['memcached']['enabled']) { + if($built = $memcached->get($this->memcached_key($index))) { + if($config['debug']) { + $debug['memcached'][] = $this->memcached_key($index); + } + return $built; } - - $ext = explode('.', $this->file); - $ext = $ext[1]; - $built .= ')

' . - - // Thumbnail - 'thumb == 'file' ? ' class="file"' : '') . - '>'; - } elseif($this->file == 'deleted') { - $built = ''; - } - - $built .= '

'; - - // Delete - $built .= '' - - // Poster ID - . ($config['poster_ids'] ? - ' ID: ' . poster_id($this->ip, $this->id) - : '') - - . ' No.' . - // JavaScript cite - ''.$this->id.'' . - // Sticky - ($this->sticky ? 'Sticky' : '') . - // Locked - ($this->locked ? 'Locked' : '') . - // [Reply] - ($index ? '[Reply]' : '') . - - // Mod controls - $this->postControls() . - '

'; - - // Body - $built .= '

' . ($index ? truncate($this->body, $this->link()) : $this->body) . '

' . + $built = Element('post_thread.html', Array('config' => $config, 'board' => $board, 'post' => &$this, 'index' => $index)); - // Omitted posts - ($this->omitted || $this->omitted_images? '' . - ($this->omitted ? - $this->omitted . ' post' . ($this->omitted==1?'':'s') . - ($this->omitted_images ? ' and ' : '') - :'') . - ($this->omitted_images ? - $this->omitted_images . ' image repl' . ($this->omitted_images==1?'y':'ies') - :'') . - ' omitted. Click reply to view.':'') . - - // End - '
'; - - // Replies - foreach($this->posts as &$post) { - $built .= $post->build($index); + if(!$this->mod && $config['memcached']['enabled']) { + $memcached->set($this->memcached_key($index), $built, time() + $config['memcached']['timeout']); } - $built .= '
' . ($this->hr ? '
' : ''); return $built; } + function memcached_key($index) { + global $board; + + return 'thread_' . ($index ? 'index_' : '') . $board['uri'] . '_' . $this->id; + } }; ?> -- cgit v1.3