packages: Smarty/Smarty.spec, Smarty/modifier.mb_truncate.patch (NEW) - cre...

glen glen at pld-linux.org
Fri Nov 19 12:38:42 CET 2010


Author: glen                         Date: Fri Nov 19 11:38:42 2010 GMT
Module: packages                      Tag: HEAD
---- Log message:
- create mb_truncate modifier,
  http://www.guyrutenberg.com/2007/12/04/multibyte-string-truncate-modifier-for-smarty-mb_truncate/
- rel 4

---- Files affected:
packages/Smarty:
   Smarty.spec (1.51 -> 1.52) , modifier.mb_truncate.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: packages/Smarty/Smarty.spec
diff -u packages/Smarty/Smarty.spec:1.51 packages/Smarty/Smarty.spec:1.52
--- packages/Smarty/Smarty.spec:1.51	Fri May 28 13:52:27 2010
+++ packages/Smarty/Smarty.spec	Fri Nov 19 12:38:36 2010
@@ -6,7 +6,7 @@
 Summary(pl.UTF-8):	System szablonów dla PHP
 Name:		Smarty
 Version:	2.6.26
-Release:	3
+Release:	4
 License:	LGPL v2.1+
 Group:		Development/Languages/PHP
 Source0:	http://www.smarty.net/distributions/%{name}-%{version}.tar.gz
@@ -16,6 +16,7 @@
 # Source1-md5:	5123152dd248898a84b96b806f551e78
 Source2:	%{name}-function.html_input_image.php
 Patch0:		path.patch
+Patch1:		modifier.mb_truncate.patch
 URL:		http://www.smarty.net/
 BuildRequires:	rpm-php-pearprov >= 4.4.2-11
 Requires:	php-common >= 4:%{php_min_version}
@@ -58,6 +59,8 @@
 %prep
 %setup -q -a1
 %patch0 -p1
+cp -a libs/plugins/modifier.{,mb_}truncate.php
+%patch1 -p1
 
 %install
 rm -rf $RPM_BUILD_ROOT
@@ -121,6 +124,11 @@
 All persons listed below can be reached at <cvs_login>@pld-linux.org
 
 $Log$
+Revision 1.52  2010/11/19 11:38:36  glen
+- create mb_truncate modifier,
+  http://www.guyrutenberg.com/2007/12/04/multibyte-string-truncate-modifier-for-smarty-mb_truncate/
+- rel 4
+
 Revision 1.51  2010/05/28 11:52:27  glen
 - move Smarty.class.php to include_path; rel 3
 

================================================================
Index: packages/Smarty/modifier.mb_truncate.patch
diff -u /dev/null packages/Smarty/modifier.mb_truncate.patch:1.1
--- /dev/null	Fri Nov 19 12:38:42 2010
+++ packages/Smarty/modifier.mb_truncate.patch	Fri Nov 19 12:38:36 2010
@@ -0,0 +1,46 @@
+--- Smarty-2.6.26/libs/plugins/modifier.mb_truncate.php	2009-06-18 14:46:27.000000000 +0000
++++ Smarty-2.6.26/libs/plugins/modifier.mb_truncate.php	2010-11-19 11:34:18.704932307 +0000
+@@ -10,21 +10,24 @@
+  * Smarty truncate modifier plugin
+  *
+  * Type:     modifier<br>
+- * Name:     truncate<br>
++ * Name:     mb_truncate<br>
+  * Purpose:  Truncate a string to a certain length if necessary,
+  *           optionally splitting in the middle of a word, and
+  *           appending the $etc string or inserting $etc into the middle.
++ *           This version also supports multibyte strings.
+  * @link http://smarty.php.net/manual/en/language.modifier.truncate.php
+  *          truncate (Smarty online manual)
+- * @author   Monte Ohrt <monte at ohrt dot com>
++ * @author   Guy Rutenberg <guyrutenberg at gmail.com> based on the original 
++ *           truncate by Monte Ohrt <monte at ohrt dot com>
+  * @param string
+  * @param integer
+  * @param string
++ * @param string
+  * @param boolean
+  * @param boolean
+  * @return string
+  */
+-function smarty_modifier_truncate($string, $length = 80, $etc = '...',
++function smarty_modifier_mb_truncate($string, $length = 80, $etc = '...', $charset='UTF-8',
+                                   $break_words = false, $middle = false)
+ {
+     if ($length == 0)
+@@ -33,12 +36,12 @@
+     if (strlen($string) > $length) {
+         $length -= min($length, strlen($etc));
+         if (!$break_words && !$middle) {
+-            $string = preg_replace('/\s+?(\S+)?$/', '', substr($string, 0, $length+1));
++            $string = preg_replace('/\s+?(\S+)?$/', '', mb_substr($string, 0, $length+1, $charset));
+         }
+         if(!$middle) {
+-            return substr($string, 0, $length) . $etc;
++            return mb_substr($string, 0, $length, $charset) . $etc;
+         } else {
+-            return substr($string, 0, $length/2) . $etc . substr($string, -$length/2);
++            return mb_substr($string, 0, $length/2, $charset) . $etc . mb_substr($string, -$length/2, $charset);
+         }
+     } else {
+         return $string;
================================================================

---- CVS-web:
    http://cvs.pld-linux.org/cgi-bin/cvsweb.cgi/packages/Smarty/Smarty.spec?r1=1.51&r2=1.52&f=u



More information about the pld-cvs-commit mailing list