summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSavetheinternet <savetheinternet@tinyboard.org>2011-10-01 22:12:31 +1000
committerSavetheinternet <savetheinternet@tinyboard.org>2011-10-01 22:12:31 +1000
commit339853e5de9a1fb63116e0bd2014df3ecc6e32aa (patch)
tree1b531791ca641fde275dc8ebb62a30705915e118
parentd62f0ee046f130befb5cc63d813129156553ab9c (diff)
Show full filename on mouseover.
-rw-r--r--inc/config.php4
-rw-r--r--inc/display.php18
-rw-r--r--install.php11
-rw-r--r--install.sql2
-rw-r--r--post.php4
-rw-r--r--templates/posts.sql2
6 files changed, 32 insertions, 9 deletions
diff --git a/inc/config.php b/inc/config.php
index e167da15..4c2d5812 100644
--- a/inc/config.php
+++ b/inc/config.php
@@ -120,6 +120,10 @@
$config['body_truncate'] = 15;
// Amount of characters to show on the index page
$config['body_truncate_char'] = 2500;
+ // Maximum filename length (will be truncated)
+ $config['max_filename_len'] = 255;
+ // Maximum filename length to display (the rest can be viewed upon mouseover)
+ $config['max_filename_display'] = 30;
$config['threads_per_page'] = 10;
$config['max_pages'] = 10;
diff --git a/inc/display.php b/inc/display.php
index 620e0b56..88c52a38 100644
--- a/inc/display.php
+++ b/inc/display.php
@@ -352,7 +352,14 @@
}
if($config['show_filename']) {
// Filename
- $built .= ', ' . $this->filename;
+ $built .= ', ' .
+ (strlen($this->filename) > $config['max_filename_display'] ?
+ '<span title="' . $this->filename . '">' .
+ substr($this->filename, 0, $config['max_filename_display']) . '&hellip;' .
+ '</span>'
+ :
+ $this->filename
+ );
}
$built .= ')</span></p>' .
@@ -511,7 +518,14 @@
}
if($config['show_filename']) {
// Filename
- $built .= ', ' . $this->filename;
+ $built .= ', ' .
+ (strlen($this->filename) > $config['max_filename_display'] ?
+ '<span title="' . $this->filename . '">' .
+ substr($this->filename, 0, $config['max_filename_display']) . '&hellip;' .
+ '</span>'
+ :
+ $this->filename
+ );
}
$built .= ')</span></p>' .
diff --git a/install.php b/install.php
index 160492cd..b701c6d3 100644
--- a/install.php
+++ b/install.php
@@ -1,6 +1,6 @@
<?php
// Installation/upgrade file
- define('VERSION', 'v0.9.3-dev-7');
+ define('VERSION', 'v0.9.3-dev-8');
require 'inc/functions.php';
require 'inc/display.php';
@@ -102,8 +102,13 @@
}
foreach($tables as &$table) {
- query("ALTER TABLE `{$table}` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci");
- }
+ query("ALTER TABLE `{$table}` ENGINE = MYISAM DEFAULT CHARACTER SET utf8 COLLATE utf8_general_ci") or error(db_error());
+ }
+ case 'v0.9.3-dev-7':
+ $boards = listBoards();
+ foreach($boards as &$board) {
+ query(sprintf("ALTER TABLE `posts_%s` CHANGE `filename` `filename` TEXT CHARACTER SET utf8 COLLATE utf8_general_ci NULL DEFAULT NULL", $board['uri'])) or error(db_error());
+ }
case false:
// Update version number
file_write($config['has_installed'], VERSION);
diff --git a/install.sql b/install.sql
index 60a756b9..af5b3f29 100644
--- a/install.sql
+++ b/install.sql
@@ -202,7 +202,7 @@ CREATE TABLE IF NOT EXISTS `posts_b` (
`filewidth` int(11) DEFAULT NULL,
`fileheight` int(11) DEFAULT NULL,
`filesize` int(11) DEFAULT NULL,
- `filename` varchar(30) DEFAULT NULL,
+ `filename` text DEFAULT NULL,
`filehash` text DEFAULT NULL,
`password` varchar(20) DEFAULT NULL,
`ip` varchar(45) NOT NULL,
diff --git a/post.php b/post.php
index 5c9f23ea..57d11a0e 100644
--- a/post.php
+++ b/post.php
@@ -413,8 +413,8 @@
$is_an_image = !in_array($post['extension'], $config['allowed_ext_files']);
- // Just trim the filename if it's too long
- if(strlen($post['filename']) > 30) $post['filename'] = substr($post['filename'], 0, 27).'…';
+ // Truncate filename if it is too long
+ $post['filename'] = substr($post['filename'], 0, $config['max_filename_len']);
// Move the uploaded file
if(!@move_uploaded_file($_FILES['file']['tmp_name'], $post['file'])) error($config['error']['nomove']);
diff --git a/templates/posts.sql b/templates/posts.sql
index 5c507799..917398bd 100644
--- a/templates/posts.sql
+++ b/templates/posts.sql
@@ -16,7 +16,7 @@ CREATE TABLE IF NOT EXISTS `posts_{board}` (
`filewidth` int(11) DEFAULT NULL,
`fileheight` int(11) DEFAULT NULL,
`filesize` int(11) DEFAULT NULL,
- `filename` varchar(30) DEFAULT NULL,
+ `filename` text DEFAULT NULL,
`filehash` text DEFAULT NULL,
`password` varchar(20) DEFAULT NULL,
`ip` varchar(45) NOT NULL,