]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/Smarty/plugins/function.sugarvar.php
Release 6.5.0
[Github/sugarcrm.git] / include / Smarty / plugins / function.sugarvar.php
1 <?php
2
3 /*
4
5 Modification information for LGPL compliance
6
7 r57851 - 2010-08-20 12:44:11 -0700 (Fri, 20 Aug 2010) - kjing - Author: Jenny Gonsalves <jenny@sugarcrm.com>
8     Merging with maint_6_0_1 revisions 57708:57838
9
10 r56990 - 2010-06-16 13:05:36 -0700 (Wed, 16 Jun 2010) - kjing - snapshot "Mango" svn branch to a new one for GitHub sync
11
12 r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
13
14 r56965 - 2010-06-15 10:57:35 -0700 (Tue, 15 Jun 2010) - jenny - Merging with Windex 56827:56958
15
16 r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
17
18 r52439 - 2009-11-12 17:05:52 -0800 (Thu, 12 Nov 2009) - clee - Updated to allow Rich Text Editor to resize and render HTML content on detailview.
19
20 r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3  tags and updated the build system 
21
22 r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development
23
24 r50375 - 2009-08-24 18:07:43 -0700 (Mon, 24 Aug 2009) - dwong - branch kobe2 from tokyo r50372
25
26 r42807 - 2008-12-29 11:16:59 -0800 (Mon, 29 Dec 2008) - dwong - Branch from trunk/sugarcrm r42806 to branches/tokyo/sugarcrm
27
28 r30629 - 2007-12-26 08:01:12 -0800 (Wed, 26 Dec 2007) - clee - Changed SugarFieldText.php to automatically set the smarty modifier url2html to be true for DetailViews.  Changed function.sugarvar.php to check for this modifier and render the appropriate call to the smarty modifier.
29 Modified:
30 include/SugarFields/Text/SugarFieldText.php
31 include/Smarty/plugins/function.sugarvar.php
32
33 r23083 - 2007-05-24 16:39:44 -0700 (Thu, 24 May 2007) - clee - Code cleanup.
34
35 r22459 - 2007-05-02 04:44:56 -0700 (Wed, 02 May 2007) - majed - adds new field types as well as improving meta data driven ui support
36
37 r22239 - 2007-04-24 17:22:11 -0700 (Tue, 24 Apr 2007) - clee - Support for nested memberName attribute value (for relate fields)
38
39 r22184 - 2007-04-23 17:47:51 -0700 (Mon, 23 Apr 2007) - clee - Latest updates as we continue 5.0 framework development.
40
41 r22175 - 2007-04-23 16:43:00 -0700 (Mon, 23 Apr 2007) - clee - Latest updates as we continue 5.0 framework development.
42
43 r22125 - 2007-04-20 17:02:26 -0700 (Fri, 20 Apr 2007) - majed - makes it so you don't need to pass in as many variables
44
45 r22124 - 2007-04-20 16:54:53 -0700 (Fri, 20 Apr 2007) - clee - 
46
47 */
48
49
50 /**
51  * Smarty plugin
52  * @package Smarty
53  * @subpackage plugins
54  */
55
56
57 /**
58  * Smarty {sugarvar} function plugin
59  *
60  * Type:     function<br>
61  * Name:     sugarvar<br>
62  * Purpose:  creates a smarty variable from the parameters
63  *
64  * @author Wayne Pan {wayne at sugarcrm.com}
65  * @param array
66  * @param Smarty
67  */
68
69 function smarty_function_sugarvar($params, &$smarty)
70 {
71         if(empty($params['key']))  {
72             $smarty->trigger_error("sugarvar: missing 'key' parameter");
73             return;
74         }
75
76         $object = (empty($params['objectName']))?$smarty->get_template_vars('parentFieldArray'): $params['objectName'];
77         $displayParams = $smarty->get_template_vars('displayParams');
78
79
80         if(empty($params['memberName'])){
81                 $member = $smarty->get_template_vars('vardef');
82                 $member = $member['name'];
83         }else{
84                 $members = explode('.', $params['memberName']);
85                 $member =  $smarty->get_template_vars($members[0]);
86                 for($i = 1; $i < count($members); $i++){
87                         $member = $member[$members[$i]];
88                 }
89         }
90
91     $_contents =  '$'. $object . '.' . $member . '.' . $params['key'];
92         if(empty($params['stringFormat']) && empty($params['string'])) {
93                 $_contents = '{' . $_contents;
94                 if(!empty($params['htmlentitydecode'])){
95                     $_contents .= '|escape:\'htmlentitydecode\'';
96                 }
97                 if(!empty($displayParams['htmlescape'])){
98                     $_contents .= '|escape:\'html\'';
99                 }
100                 if(!empty($displayParams['strip_tags'])){
101                         $_contents .= '|strip_tags';
102                 }
103                 if(!empty($displayParams['url2html'])){
104                         $_contents .= '|url2html';
105                 }
106                 if(!empty($displayParams['nl2br'])){
107                         $_contents .= '|nl2br';
108                 }
109
110                 $_contents .= '}';
111     }
112     return $_contents;
113 }
114 ?>