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
This commit is contained in:
jim
2006-10-13 20:59:04 +00:00
parent 86f5c6a93d
commit dc5ebee5f2
5 changed files with 26 additions and 16 deletions

View File

@@ -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

View File

@@ -10,7 +10,7 @@
<li><a href="../"><p class="icon"><img src="<?=Icon::get_parent('large')?>" alt="" /></p><p class="name">..</p><p class="info"><?=$lang->parent_dir?></p></a></li>
<? endif ?>
<? foreach ($dlist->list as $key => $item): $info = ($item['type'] == 'file') ? $item['size'] : $item['mtime'] ;?>
<li><a href="<?=rawurlencode($item['name'])?><? if($item['type'] == 'dir') echo '/'; ?>"><p class="icon"><img src="<?=Icon::get_url($item['name'], 'large', $item['type'], true)?>" alt="" /></p><p class="name"><?=Path::wordbreak($item['name'], 24, "\n", 1)?></p><p class="info"><?=$info?></p></a></li>
<li><a href="<?=urlencode($item['name'])?><? if($item['type'] == 'dir') echo '/'; ?>" title="<?=$item['name']?>"><p class="icon"><img src="<?=Icon::get_url($item['name'], 'large', $item['type'], true)?>" alt="" /></p><p class="name"><?=Path::breakFilename($item['name'], $config->tpl_file_maxlength, $config->tpl_wordbreak)?></p><p class="info"><?=$info?></p></a></li>
<? endforeach ?>
</ul>
</td></tr></table>

View File

@@ -5,6 +5,10 @@
# default mode
'mode' => 'icons',
# icon mode filename handling
'file_maxlength' => 32,
'wordbreak' => 16,
# available modes
'modes' => array(
'details' => '_details.phtml',

View File

@@ -21,7 +21,7 @@
<?=$lang->group_id?>: <?=$item['group_id']?><br /><? endif; ?>
</span>
<p class="p"><img src="<?=Icon::get_url($item['name'], 'large', $item['type'], true)?>" alt="" /></p>
<p class="n"><?=Path::wordbreak($item['name'], $config->tpl_wordbreak, "\n", 1)?></p>
<p class="n"><?=Path::breakFilename($item['name'], $config->tpl_file_maxlength, $config->tpl_wordbreak)?></p>
<p class="i"><?=$info?></p>
</a>
</li><? $n++; endforeach; ?>

View File

@@ -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,