summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@n0v4.com>2010-11-04 03:10:47 +1100
committerSavetheinternet <savetheinternet@n0v4.com>2010-11-04 03:10:47 +1100
commita2a404f1daca791b0345ce76de3b3fcbd26d3004 (patch)
tree2895a44d87b27609c9ea1e8a3ff4a54e122400c4
parent1e201212242c758a4d797711388aa566542224f4 (diff)
Cleaned functions.
Added room for image aspect ratio. Implemented soon.
-rw-r--r--inc/config.php2
-rw-r--r--inc/display.php71
-rw-r--r--inc/functions.php5
3 files changed, 56 insertions, 22 deletions
diff --git a/inc/config.php b/inc/config.php
index 54180153..44dc60ec 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -62,6 +62,8 @@
define('JPEG_QUALITY', 100);
define('REDRAW_GIF', false);
+ // Display the aspect ratio in a post's file info
+ define('SHOW_RATIO', false);
define('DIR_IMG', 'src/');
define('DIR_THUMB', 'thumb/');
diff --git a/inc/display.php b/inc/display.php
index a1bfd2f5..20e8b16d 100644
--- a/inc/display.php
+++ b/inc/display.php
@@ -38,28 +38,55 @@
$this->filename = $filename;
}
public function build($index=false) {
- $built = '
- <div class="post reply"' . (!$index?' id="reply_' . $this->id . '"':'') . '>
- <p class="intro"' . (!$index?' id="' . $this->id . '"':'') . '>
- <span class="subject">
- '.$this->subject.'
- </span>
- ' . ( !empty($this->email) ? '<a class="email" href="mailto:' . $this->email . '">':'') .
- '<span class="name">'
- . $this->name .
- '</span>' . (!empty($this->trip) ? ' <span class="trip">'.$this->trip.'</span>':'')
- . ( !empty($this->email) ? '</a>':'')
- . ' ' . date('m/d/y (D) H:i:s', $this->time).'
- <a class="post_no"' . ($index?'':' onclick="highlightReply(' . $this->id . ');"') . ' href="' . ROOT . DIR_RES . $this->thread . '.html' . '#' . $this->id . '">No.</a><a class="post_no"' . ($index?'':'onclick="citeReply(' . $this->id . ');"') . 'href="' . ($index?ROOT . DIR_RES . $this->thread . '.html' . '#q' . $this->id:'javascript:void(0);') . '">'.$this->id.'</a>
- </p>
- '.(!empty($this->file)?'<p class="fileinfo">
- File: <a href="' . ROOT . $this->file.'">'.basename($this->file).'</a> <span class="unimportant">('.format_bytes($this->filesize).', '.$this->filex.'x'.$this->filey.', '.$this->filename.')</span>
- </p>
- <a href="' . ROOT . $this->file.'"><img src="' . ROOT . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>':'').'
- <p class="body">
- '.$this->body.'
- </p>
- </div><br class="clear"/>';
+ $built = '<div class="post reply"' . (!$index?' id="reply_' . $this->id . '"':'') . '>' .
+ '<p class="intro"' . (!$index?' id="' . $this->id . '"':'') . '>';
+
+ // Subject
+ $built .= '<span class="subject">' . $this->subject . '</span>';
+ // Email
+ if(!empty($this->email))
+ $built .= '<a class="email" href="mailto:' . $this->email . '">';
+ // Name
+ $built .= '<span class="name">' . $this->name . '</span>'
+ // Trip
+ . (!empty($this->trip) ? ' <span class="trip">'.$this->trip.'</span>':'');
+
+ // End email
+ if(!empty($this->email))
+ $built .= '</a>';
+
+ // Date/time
+ $built .= ' ' . date('m/d/y (D) H:i:s', $this->time);
+
+ $built .= ' <a class="post_no"' .
+ // JavaScript highlight
+ ($index?'':' onclick="highlightReply(' . $this->id . ');"') .
+ ' href="' . ROOT . DIR_RES . $this->thread . '.html' . '#' . $this->id . '">No.</a>' .
+ // JavaScript cite
+ '<a class="post_no"' . ($index?'':'onclick="citeReply(' . $this->id . ');"') . 'href="' . ($index?ROOT . DIR_RES . $this->thread . '.html' . '#q' . $this->id:'javascript:void(0);') . '">'.$this->id.'</a>' .
+ '</p>';
+
+ // File info
+ if(!empty($this->file)) {
+ $built .= '<p class="fileinfo">File: <a href="' . ROOT . $this->file .'">' . basename($this->file) . '</a> <span class="unimportant">(' .
+ // Filesize
+ format_bytes($this->filesize) . ', ' .
+ // File dimensions
+ $this->filex . 'x' . $this->filey;
+ // Aspect Ratio
+ if(SHOW_RATIO) {
+ $fraction = fraction($this->filex, $this->filey, ':');
+ $built .= ', ' . $fraction;
+ }
+ // Filename
+ $built .= ', ' . $this->filename . ')</span></p>' .
+ // Thumbnail
+ '<a href="' . ROOT . $this->file.'"><img src="' . ROOT . $this->thumb.'" style="width:'.$this->thumbx.'px;height:'.$this->thumby.'px;" /></a>';
+ }
+
+ // Body
+ $built .= '<p class="body">' . $this->body . '</p></div><br class="clear"/>';
+
return $built;
}
};
diff --git a/inc/functions.php b/inc/functions.php
index 0c14ee18..1409c7b1 100644
--- a/inc/functions.php
+++ b/inc/functions.php
@@ -222,6 +222,11 @@
return array ( $nameo );
}
}
+
+ function fraction($numerator, $denominator, $sep) {
+ $fraction = Array($numerator, $denominator);
+ return "{$fraction[0]}{$sep}{$fraction[1]}";
+ }
/*********************************************/
/* Fonction: imagecreatefrombmp */