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 r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm
21 r34090 - 2008-04-14 11:15:00 -0700 (Mon, 14 Apr 2008) - dwheeler - 20936: Link field now uses the vardef's default value when creating generated links instead of the database value.
23 r34040 - 2008-04-11 11:48:13 -0700 (Fri, 11 Apr 2008) - dwheeler - Fixed Typo that prevented enum fields from being replaced properly.
25 r33968 - 2008-04-10 11:30:04 -0700 (Thu, 10 Apr 2008) - dwheeler - bug 20936: Added smarty function to find and replace dynamic strings for custom dynamic fields, now handles translating strings for enum variables.
33 * This function will replace fields taken from the fields variable
34 * and insert them into the passed string replacing [variableName]
37 * @param unknown_type $params
38 * @param unknown_type $smarty
41 function smarty_function_sugar_replace_vars($params, &$smarty)
43 if(empty($params['subject'])) {
44 $smarty->trigger_error("sugarvar: missing 'subject' parameter");
47 $fields = $smarty->get_template_vars('fields');
48 $subject = $params['subject'];
50 $count = preg_match_all('/\[([^\]]*)\]/', $subject, $matches);
51 for($i = 0; $i < $count; $i++) {
52 $match = $matches[1][$i];
53 if (!empty($fields[$match]) && isset($fields[$match]['value'])) {
54 $value = $fields[$match]['value'];
55 if (isset($fields[$match]['type']) && $fields[$match]['type']=='enum'
56 && isset($fields[$match]['options']) && isset($fields[$match]['options'][$value]))
58 $subject = str_replace($matches[0][$i], $fields[$match]['options'][$value], $subject);
61 $subject = str_replace($matches[0][$i], $value, $subject);
66 if (!empty($params['assign']))
68 $smarty->assign($params['assign'], $subject);