Add new directory structure. Tags will contain current and past releases, and stable will contain any bug fixes to the current stable release so users won't have to get the potentially broken trunk build to fix a screwup in stable.
Trunk updated to 0.9 git-svn-id: http://kusabax.cultnet.net/svn/repo/stable@176 73d99b7e-4f53-4972-b7b7-2ecd3c4d89ee
This commit is contained in:
commit
88bacfad9c
316 files changed
+79806
No files matched your search
@@ -0,0 +1,45 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Truncates a string at the given length
|
||||
* <pre>
|
||||
* * value : text to truncate
|
||||
* * length : the maximum length for the string
|
||||
* * etc : the characters that are added to show that the string was cut off
|
||||
* * break : if true, the string will be cut off at the exact length, instead of cutting at the nearest space
|
||||
* * middle : if true, the string will contain the beginning and the end, and the extra characters will be removed from the middle
|
||||
* </pre>
|
||||
* This software is provided 'as-is', without any express or implied warranty.
|
||||
* In no event will the authors be held liable for any damages arising from the use of this software.
|
||||
*
|
||||
* @author Jordi Boggiano <j.boggiano@seld.be>
|
||||
* @copyright Copyright (c) 2008, Jordi Boggiano
|
||||
* @license http://dwoo.org/LICENSE Modified BSD License
|
||||
* @link http://dwoo.org/
|
||||
* @version 1.0.0
|
||||
* @date 2008-10-23
|
||||
* @package Dwoo
|
||||
*/
|
||||
function Dwoo_Plugin_truncate(Dwoo $dwoo, $value, $length=80, $etc='...', $break=false, $middle=false)
|
||||
{
|
||||
if ($length == 0) {
|
||||
return '';
|
||||
}
|
||||
|
||||
$value = (string) $value;
|
||||
$etc = (string) $etc;
|
||||
$length = (int) $length;
|
||||
|
||||
if (strlen($value) < $length) {
|
||||
return $value;
|
||||
}
|
||||
|
||||
$length = max($length - strlen($etc), 0);
|
||||
if ($break === false && $middle === false) {
|
||||
$value = preg_replace('#\s*(\S*)?$#', '', substr($value, 0, $length+1));
|
||||
}
|
||||
if ($middle === false) {
|
||||
return substr($value, 0, $length) . $etc;
|
||||
}
|
||||
return substr($value, 0, ceil($length/2)) . $etc . substr($value, -floor($length/2));
|
||||
}
|
||||
Reference in new issue
Block a user