Changeset 988

Show
Ignore:
Timestamp:
06/15/08 15:31:07 (6 months ago)
Author:
bastnic
Message:

fixed #511 : resolved memory exhausted errors in truncate modifier,p=Torgan

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • branches/1.0.x/lib/jelix/CREDITS

    r956 r988  
    9797 - Contribution on jResponseRss and jResponseAtom 
    9898 - jdb driver for Intuition 
     99 - resolved memory exhausted errors in truncate modifier (#511) 
    99100 
    100101Kévin Lepeltier (aka Lipki) 
  • branches/1.0.x/lib/jelix/CREDITS

    r956 r988  
    9797 - Contribution on jResponseRss and jResponseAtom 
    9898 - jdb driver for Intuition 
     99 - resolved memory exhausted errors in truncate modifier (#511) 
    99100 
    100101Kévin Lepeltier (aka Lipki) 
  • branches/1.0.x/lib/jelix/CREDITS

    r956 r988  
    9797 - Contribution on jResponseRss and jResponseAtom 
    9898 - jdb driver for Intuition 
     99 - resolved memory exhausted errors in truncate modifier (#511) 
    99100 
    100101Kévin Lepeltier (aka Lipki) 
  • branches/1.0.x/lib/jelix/CREDITS

    r956 r988  
    9797 - Contribution on jResponseRss and jResponseAtom 
    9898 - jdb driver for Intuition 
     99 - resolved memory exhausted errors in truncate modifier (#511) 
    99100 
    100101Kévin Lepeltier (aka Lipki) 
  • branches/1.0.x/lib/jelix/plugins/tpl/common/modifier.truncate.php

    r506 r988  
    66 * @author 
    77 * @contributor Laurent Jouanneau (utf8 compliance) 
     8 * @contributor Yannick Le Guédart 
    89 * @copyright  2001-2003 ispi of Lincoln, Inc., 2007 Laurent Jouanneau 
     10 * @copyright 2008 Yannick Le Guédart 
    911 * @link http://smarty.php.net/ 
    1012 * @link http://jelix.org/ 
     
    2931 */ 
    3032function jtpl_modifier_common_truncate($string, $length = 80, $etc = '...', 
    31                                   $break_words = false) 
     33                                                                  $break_words = false) 
    3234{ 
    33     if ($length == 0) 
     35    if (function_exists ('mb_strlen')) { 
     36        $f_strlen = 'mb_strlen'; 
     37    } 
     38    else { 
     39        $f_strlen = 'iconv_strlen'; 
     40    } 
     41 
     42    if (function_exists ('mb_substr')) { 
     43        $f_substr = 'mb_substr'; 
     44    } 
     45    else { 
     46        $f_substr = 'iconv_substr'; 
     47    } 
     48 
     49    if($length == 0) 
    3450        return ''; 
    3551    $charset = jTpl::getEncoding(); 
    36     if (iconv_strlen($string,$charset) > $length) { 
    37         $length -= iconv_strlen($etc,$charset); 
    38         if (!$break_words) 
    39             $string = preg_replace('/\s+?(\S+)?$/', '', iconv_substr($string, 0, $length+1,$charset)); 
    4052 
    41         return iconv_substr($string, 0, $length,$charset).$etc; 
     53    if($f_strlen ($string,$charset) > $length) { 
     54        $length -= $f_strlen($etc,$charset); 
     55        if(!$break_words) 
     56            $string = preg_replace('/\s+?(\S+)?$/', '', $f_substr($string, 0, $length+1,$charset)); 
     57        return $f_substr($string, 0, $length,$charset).$etc; 
    4258    } else 
    4359        return $string; 
    4460} 
     61 
    4562?> 
  • branches/1.0.x/lib/jelix/plugins/tpl/common/modifier.truncate.php

    r506 r988  
    66 * @author 
    77 * @contributor Laurent Jouanneau (utf8 compliance) 
     8 * @contributor Yannick Le Guédart 
    89 * @copyright  2001-2003 ispi of Lincoln, Inc., 2007 Laurent Jouanneau 
     10 * @copyright 2008 Yannick Le Guédart 
    911 * @link http://smarty.php.net/ 
    1012 * @link http://jelix.org/ 
     
    2931 */ 
    3032function jtpl_modifier_common_truncate($string, $length = 80, $etc = '...', 
    31                                   $break_words = false) 
     33                                                                  $break_words = false) 
    3234{ 
    33     if ($length == 0) 
     35    if (function_exists ('mb_strlen')) { 
     36        $f_strlen = 'mb_strlen'; 
     37    } 
     38    else { 
     39        $f_strlen = 'iconv_strlen'; 
     40    } 
     41 
     42    if (function_exists ('mb_substr')) { 
     43        $f_substr = 'mb_substr'; 
     44    } 
     45    else { 
     46        $f_substr = 'iconv_substr'; 
     47    } 
     48 
     49    if($length == 0) 
    3450        return ''; 
    3551    $charset = jTpl::getEncoding(); 
    36     if (iconv_strlen($string,$charset) > $length) { 
    37         $length -= iconv_strlen($etc,$charset); 
    38         if (!$break_words) 
    39             $string = preg_replace('/\s+?(\S+)?$/', '', iconv_substr($string, 0, $length+1,$charset)); 
    4052 
    41         return iconv_substr($string, 0, $length,$charset).$etc; 
     53    if($f_strlen ($string,$charset) > $length) { 
     54        $length -= $f_strlen($etc,$charset); 
     55        if(!$break_words) 
     56            $string = preg_replace('/\s+?(\S+)?$/', '', $f_substr($string, 0, $length+1,$charset)); 
     57        return $f_substr($string, 0, $length,$charset).$etc; 
    4258    } else 
    4359        return $string; 
    4460} 
     61 
    4562?> 
  • branches/1.0.x/lib/jelix/plugins/tpl/common/modifier.truncate.php

    r506 r988  
    66 * @author 
    77 * @contributor Laurent Jouanneau (utf8 compliance) 
     8 * @contributor Yannick Le Guédart 
    89 * @copyright  2001-2003 ispi of Lincoln, Inc., 2007 Laurent Jouanneau 
     10 * @copyright 2008 Yannick Le Guédart 
    911 * @link http://smarty.php.net/ 
    1012 * @link http://jelix.org/ 
     
    2931 */ 
    3032function jtpl_modifier_common_truncate($string, $length = 80, $etc = '...', 
    31                                   $break_words = false) 
     33                                                                  $break_words = false) 
    3234{ 
    33     if ($length == 0) 
     35    if (function_exists ('mb_strlen')) { 
     36        $f_strlen = 'mb_strlen'; 
     37    } 
     38    else { 
     39        $f_strlen = 'iconv_strlen'; 
     40    } 
     41 
     42    if (function_exists ('mb_substr')) { 
     43        $f_substr = 'mb_substr'; 
     44    } 
     45    else { 
     46        $f_substr = 'iconv_substr'; 
     47    } 
     48 
     49    if($length == 0) 
    3450        return ''; 
    3551    $charset = jTpl::getEncoding(); 
    36     if (iconv_strlen($string,$charset) > $length) { 
    37         $length -= iconv_strlen($etc,$charset); 
    38         if (!$break_words) 
    39             $string = preg_replace('/\s+?(\S+)?$/', '', iconv_substr($string, 0, $length+1,$charset)); 
    4052 
    41         return iconv_substr($string, 0, $length,$charset).$etc; 
     53    if($f_strlen ($string,$charset) > $length) { 
     54        $length -= $f_strlen($etc,$charset); 
     55        if(!$break_words) 
     56            $string = preg_replace('/\s+?(\S+)?$/', '', $f_substr($string, 0, $length+1,$charset)); 
     57        return $f_substr($string, 0, $length,$charset).$etc; 
    4258    } else 
    4359        return $string; 
    4460} 
     61 
    4562?> 
  • branches/1.0.x/lib/jelix/plugins/tpl/common/modifier.truncate.php

    r506 r988  
    66 * @author 
    77 * @contributor Laurent Jouanneau (utf8 compliance) 
     8 * @contributor Yannick Le Guédart 
    89 * @copyright  2001-2003 ispi of Lincoln, Inc., 2007 Laurent Jouanneau 
     10 * @copyright 2008 Yannick Le Guédart 
    911 * @link http://smarty.php.net/ 
    1012 * @link http://jelix.org/ 
     
    2931 */ 
    3032function jtpl_modifier_common_truncate($string, $length = 80, $etc = '...', 
    31                                   $break_words = false) 
     33                                                                  $break_words = false) 
    3234{ 
    33     if ($length == 0) 
     35    if (function_exists ('mb_strlen')) { 
     36        $f_strlen = 'mb_strlen'; 
     37    } 
     38    else { 
     39        $f_strlen = 'iconv_strlen'; 
     40    } 
     41 
     42    if (function_exists ('mb_substr')) { 
     43        $f_substr = 'mb_substr'; 
     44    } 
     45    else { 
     46        $f_substr = 'iconv_substr'; 
     47    } 
     48 
     49    if($length == 0) 
    3450        return ''; 
    3551    $charset = jTpl::getEncoding(); 
    36     if (iconv_strlen($string,$charset) > $length) { 
    37         $length -= iconv_strlen($etc,$charset); 
    38         if (!$break_words) 
    39             $string = preg_replace('/\s+?(\S+)?$/', '', iconv_substr($string, 0, $length+1,$charset)); 
    4052 
    41         return iconv_substr($string, 0, $length,$charset).$etc; 
     53    if($f_strlen ($string,$charset) > $length) { 
     54        $length -= $f_strlen($etc,$charset); 
     55        if(!$break_words) 
     56            $string = preg_replace('/\s+?(\S+)?$/', '', $f_substr($string, 0, $length+1,$charset)); 
     57        return $f_substr($string, 0, $length,$charset).$etc; 
    4258    } else 
    4359        return $string; 
    4460} 
     61 
    4562?> 
Download in other formats: Unified Diff Zip Archive