5 Modification information for LGPL compliance
7 r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync
9 r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
11 r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
13 r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3 tags and updated the build system
15 r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development
17 r50375 - 2009-08-24 18:07:43 -0700 (Mon, 24 Aug 2009) - dwong - branch kobe2 from tokyo r50372
19 r46793 - 2009-05-03 17:13:58 -0700 (Sun, 03 May 2009) - wdong - 28604, merge from maint520_hermosa
21 r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm
23 r37314 - 2008-06-26 13:37:54 -0700 (Thu, 26 Jun 2008) - roger - bug: 23141 - seems is there is a $ in the value then when we do some regex to replace a placeholder it does not work properly for textareas. I took code from latest smarty download and replaced. 2.6.19
25 r34228 - 2008-04-16 09:41:19 -0700 (Wed, 16 Apr 2008) - jmertic - Bug 21141: Change smarty_outputfilter_trimwhitespace_replace from using substr_replace to preg_replace since the latter is mb safe.
27 - include/Smarty/plugins/outputfilter.trimwhitespace.php
29 r8230 - 2005-10-03 17:47:19 -0700 (Mon, 03 Oct 2005) - majed - Added Sugar_Smarty to the code tree.
42 * Smarty trimwhitespace outputfilter plugin
44 * File: outputfilter.trimwhitespace.php<br>
45 * Type: outputfilter<br>
46 * Name: trimwhitespace<br>
47 * Date: Jan 25, 2003<br>
48 * Purpose: trim leading white space and blank lines from
49 * template source after it gets interpreted, cleaning
50 * up code and saving bandwidth. Does not affect
51 * <<PRE>></PRE> and <SCRIPT></SCRIPT> blocks.<br>
52 * Install: Drop into the plugin directory, call
53 * <code>$smarty->load_filter('output','trimwhitespace');</code>
55 * @author Monte Ohrt <monte at ohrt dot com>
56 * @author Contributions from Lars Noschinski <lars@usenet.noschinski.de>
61 function smarty_outputfilter_trimwhitespace($source, &$smarty)
63 // Pull out the script blocks
64 preg_match_all("!<script[^>]+>.*?</script>!is", $source, $match);
65 $_script_blocks = $match[0];
66 $source = preg_replace("!<script[^>]+>.*?</script>!is",
67 '@@@SMARTY:TRIM:SCRIPT@@@', $source);
69 // Pull out the pre blocks
70 preg_match_all("!<pre>.*?</pre>!is", $source, $match);
71 $_pre_blocks = $match[0];
72 $source = preg_replace("!<pre>.*?</pre>!is",
73 '@@@SMARTY:TRIM:PRE@@@', $source);
75 // Pull out the textarea blocks
76 preg_match_all("!<textarea[^>]+>.*?</textarea>!is", $source, $match);
77 $_textarea_blocks = $match[0];
78 $source = preg_replace("!<textarea[^>]+>.*?</textarea>!is",
79 '@@@SMARTY:TRIM:TEXTAREA@@@', $source);
81 // remove all leading spaces, tabs and carriage returns NOT
82 // preceeded by a php close tag.
83 $source = trim(preg_replace('/((?<!\?>)\n)[\s]+/m', '\1', $source));
85 // replace script blocks
86 smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:SCRIPT@@@",$_script_blocks, $source);
89 smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:PRE@@@",$_pre_blocks, $source);
91 // replace textarea blocks
92 smarty_outputfilter_trimwhitespace_replace("@@@SMARTY:TRIM:TEXTAREA@@@",$_textarea_blocks, $source);
97 function smarty_outputfilter_trimwhitespace_replace($search_str, $replace, &$subject) {
98 $_len = strlen($search_str);
100 for ($_i=0, $_count=count($replace); $_i<$_count; $_i++)
101 if (($_pos=strpos($subject, $search_str, $_pos))!==false)
102 $subject = substr($subject, 0, $_pos) . $replace[$_i] . substr($subject, $_pos+$_len);