mage-enhanced-admin-grids
mage-enhanced-admin-grids copied to clipboard
Some idea to replace ETC with TruncateAt character (sort of split)
in class BL_CustomGrid_Helper_String extends Mage_Core_Helper_Abstract
public function truncateText($string, $truncateLength = 80, $truncateAt = '', &$remainder = '', $breakWords = true)
{
$remainder = '';
/** @var $helper Mage_Core_Helper_String */
$helper = Mage::helper('core/string');
// Change etc to work as truncate At character
if (!empty($truncateAt)) {
$truncPos = strrpos($string, $truncateAt);
if ($truncPos != false) {
$truncateLength = $truncPos;
}
}
if ($truncateLength == 0) {
return '';
}
$originalLength = $helper->strlen($string);
if ($originalLength > $truncateLength) {
// remove // $truncateLength -= $helper->strlen($etc);
if ($truncateLength <= 0) {
return '';
}
$preparedString = $string;
$preparedLength = $truncateLength;
if (!$breakWords) {
$preparedString = preg_replace('/\s+?(\S+)?$/u', '', $this->substr($string, 0, $truncateLength + 1));
$preparedLength = $this->strlen($preparedString);
}
$remainder = $helper->substr($string, $preparedLength, $originalLength);
return $helper->substr($preparedString, 0, $truncateLength);
}
return $string;
}