From dc5ebee5f2b37e417f9c73fae0dee56c00e69d81 Mon Sep 17 00:00:00 2001 From: jim Date: Fri, 13 Oct 2006 20:59:04 +0000 Subject: [PATCH] updated handling of long filenames in icons views of "simple" and "slik" templates, and modified output functions in exec/output.exec.php. git-svn-id: file:///Users/jimeh/Desktop/dlist/trunk@28 a5845835-ea0f-0410-a762-dd0bfe9bfde8 --- exec/output.exec.php | 30 +++++++++++++++++------------- templates/simple/_icons.phtml | 2 +- templates/simple/settings.php | 4 ++++ templates/slik/_icons.phtml | 2 +- templates/slik/settings.php | 4 +++- 5 files changed, 26 insertions(+), 16 deletions(-) diff --git a/exec/output.exec.php b/exec/output.exec.php index b929d52..4670b8b 100644 --- a/exec/output.exec.php +++ b/exec/output.exec.php @@ -86,21 +86,25 @@ class Path { return $r_files; } } - - //>Section> path_wordwrap - function wordbreak ($input, $length, $break=" ") { - if (preg_match("/(.*)\.(.*)/", $input, $preg) ) { - $words = explode(' ', $preg[1]); - $ext = '.'.$preg[2]; - } else { - $words = explode(' ', $input); - $ext = ''; + //>Section> path_breakFilename + function breakFilename ($input, $maxlength, $wordbreak = 16) { + + if ( $wordbreak != false ) { + if (preg_match("/(.*)\.(.*)/", $input, $preg) ) { + $words = explode(' ', $preg[1]); + $ext = '.'.$preg[2]; + } else { + $words = explode(' ', $input); + $ext = ''; + } + foreach( $words as $key => $value ) { + $words[$key] = wordwrap($value, $wordbreak, ' ', 1); + } + $input = implode(' ', $words).$ext; } - foreach( $words as $key => $value ) { - $words[$key] = wordwrap($value, $length, $break, 1); - } - return implode(' ', $words).$ext; + if ( strlen($input) > $maxlength ) return rtrim(substr($input, 0, $maxlength)).'...'; + return $input; } //>Section> path_class.end diff --git a/templates/simple/_icons.phtml b/templates/simple/_icons.phtml index fa5f31b..7f449b1 100644 --- a/templates/simple/_icons.phtml +++ b/templates/simple/_icons.phtml @@ -10,7 +10,7 @@
  • ..

    parent_dir?>

  • list as $key => $item): $info = ($item['type'] == 'file') ? $item['size'] : $item['mtime'] ;?> -
  • +
  • tpl_file_maxlength, $config->tpl_wordbreak)?>

  • \ No newline at end of file diff --git a/templates/simple/settings.php b/templates/simple/settings.php index 1b6d935..8e11d83 100644 --- a/templates/simple/settings.php +++ b/templates/simple/settings.php @@ -5,6 +5,10 @@ # default mode 'mode' => 'icons', + # icon mode filename handling + 'file_maxlength' => 32, + 'wordbreak' => 16, + # available modes 'modes' => array( 'details' => '_details.phtml', diff --git a/templates/slik/_icons.phtml b/templates/slik/_icons.phtml index 0c8b62e..9ca28e9 100644 --- a/templates/slik/_icons.phtml +++ b/templates/slik/_icons.phtml @@ -21,7 +21,7 @@ group_id?>:

    -

    tpl_wordbreak, "\n", 1)?>

    +

    tpl_file_maxlength, $config->tpl_wordbreak)?>

    diff --git a/templates/slik/settings.php b/templates/slik/settings.php index c64971a..25c987e 100644 --- a/templates/slik/settings.php +++ b/templates/slik/settings.php @@ -8,7 +8,9 @@ // Icons view settings 'file_info' => 'size', 'folder_info' => 'mtime', - 'wordbreak' => 18, + 'file_maxlength' => 32, + 'wordbreak' => 16, + 'preview_width' => 175, 'preview_height' => 175,