diff options
| author | Michael Foster <savetheinternet@tinyboard.org> | 2013-08-16 21:08:01 +1000 |
|---|---|---|
| committer | Michael Foster <savetheinternet@tinyboard.org> | 2013-08-16 21:08:01 +1000 |
| commit | b666886416f793074669a7e2bc1d7cc3c2b4746a (patch) | |
| tree | e5f69f4279621ce72747707e164aa358354b084c /inc/display.php | |
| parent | 88dff2a683ea580930b95ffa33cccdf648d89cab (diff) | |
A few modifications:
1. Finally, clean up some of the crappy code in inc/display.php; no more extreme clutter. new Thread() and new Post() take an array as the first parameter now.
2. Poster country flags. Currently requires the "geoip" extension.
3. Give post images a classname. This was also long-overdue.
Diffstat (limited to 'inc/display.php')
| -rw-r--r-- | inc/display.php | 72 |
1 files changed, 24 insertions, 48 deletions
diff --git a/inc/display.php b/inc/display.php index af0ee89f..ee600ed3 100644 --- a/inc/display.php +++ b/inc/display.php @@ -270,36 +270,25 @@ function embed_html($link) { } class Post { - public function __construct($id, $thread, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $embed, $root=null, $mod=false) { + public function __construct($post, $root=null, $mod=false) { global $config; if (!isset($root)) $root = &$config['root']; - $this->id = $id; - $this->thread = $thread; - $this->subject = utf8tohtml($subject); - $this->email = $email; - $this->name = utf8tohtml($name); - $this->trip = $trip; - $this->capcode = $capcode; - $this->body = $body; - $this->time = $time; - $this->thumb = $thumb; - $this->thumbx = $thumbx; - $this->thumby = $thumby; - $this->file = $file; - $this->filex = $filex; - $this->filey = $filey; - $this->filesize = $filesize; - $this->filename = $filename; - $this->ip = $ip; - $this->embed = $embed; - $this->root = $root; + foreach ($post as $key => $value) { + $this->{$key} = $value; + } + + $this->subject = utf8tohtml($this->subject); + $this->name = utf8tohtml($this->name); $this->mod = $mod; + $this->root = $root; if ($this->embed) $this->embed = embed_html($this->embed); + $this->modifiers = extract_modifiers($this->body_nomarkup); + if ($this->mod) // Fix internal links // Very complicated regex @@ -367,42 +356,29 @@ class Post { }; class Thread { - public function __construct($id, $subject, $email, $name, $trip, $capcode, $body, $time, $thumb, $thumbx, $thumby, $file, $filex, $filey, $filesize, $filename, $ip, $sticky, $locked, $bumplocked, $embed, $root=null, $mod=false, $hr=true) { + public function __construct($post, $root = null, $mod = false, $hr = true) { global $config; if (!isset($root)) $root = &$config['root']; - $this->id = $id; - $this->subject = utf8tohtml($subject); - $this->email = $email; - $this->name = utf8tohtml($name); - $this->trip = $trip; - $this->capcode = $capcode; - $this->body = $body; - $this->time = $time; - $this->thumb = $thumb; - $this->thumbx = $thumbx; - $this->thumby = $thumby; - $this->file = $file; - $this->filex = $filex; - $this->filey = $filey; - $this->filesize = $filesize; - $this->filename = $filename; + foreach ($post as $key => $value) { + $this->{$key} = $value; + } + + $this->subject = utf8tohtml($this->subject); + $this->name = utf8tohtml($this->name); + $this->mod = $mod; + $this->root = $root; + + $this->posts = array(); $this->omitted = 0; $this->omitted_images = 0; - $this->posts = array(); - $this->ip = $ip; - $this->sticky = $sticky; - $this->locked = $locked; - $this->bumplocked = $bumplocked; - $this->embed = $embed; - $this->root = $root; - $this->mod = $mod; - $this->hr = $hr; if ($this->embed) $this->embed = embed_html($this->embed); + $this->modifiers = extract_modifiers($this->body_nomarkup); + if ($this->mod) // Fix internal links // Very complicated regex @@ -462,7 +438,7 @@ class Thread { $built .= ' <a title="'._('Make thread sticky').'" href="?/' . secure_link($board['dir'] . 'sticky/' . $this->id) . '">' . $config['mod']['link_sticky'] . '</a>'; if (hasPermission($config['mod']['bumplock'], $board['uri'], $this->mod)) - if ($this->bumplocked) + if ($this->sage) $built .= ' <a title="'._('Allow thread to be bumped').'" href="?/' . secure_link($board['dir'] . 'bumpunlock/' . $this->id) . '">' . $config['mod']['link_bumpunlock'] . '</a>'; else $built .= ' <a title="'._('Prevent thread from being bumped').'" href="?/' . secure_link($board['dir'] . 'bumplock/' . $this->id) . '">' . $config['mod']['link_bumplock'] . '</a>'; |
