]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/Smarty/plugins/function.multienum_to_array.php
Release 6.5.0
[Github/sugarcrm.git] / include / Smarty / plugins / function.multienum_to_array.php
1 <?php
2
3 /*
4
5 Modification information for LGPL compliance
6
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
8
9 r56989 - 2010-06-16 13:01:33 -0700 (Wed, 16 Jun 2010) - kjing - defunt "Mango" svn dev branch before github cutover
10
11 r55980 - 2010-04-19 13:31:28 -0700 (Mon, 19 Apr 2010) - kjing - create Mango (6.1) based on windex
12
13 r53116 - 2009-12-09 17:24:37 -0800 (Wed, 09 Dec 2009) - mitani - Merge Kobe into Windex Revision 51633 to 53087
14
15 r51719 - 2009-10-22 10:18:00 -0700 (Thu, 22 Oct 2009) - mitani - Converted to Build 3  tags and updated the build system 
16
17 r51634 - 2009-10-19 13:32:22 -0700 (Mon, 19 Oct 2009) - mitani - Windex is the branch for Sugar Sales 1.0 development
18
19 r50983 - 2009-09-21 13:45:37 -0700 (Mon, 21 Sep 2009) - ajay - Merged code from branches/tokyo version 50739 thru 50982
20
21 r50883 - 2009-09-16 15:54:43 -0700 (Wed, 16 Sep 2009) - dwheeler - 30563,21574: Multienum values are now stored in the db with leading '^' characters to allow for simplified searching on multienums. To facilitate this, un/encodeMultiEnum functions have been added  and all calls to convert multienums to strings now go through those two functions. multienum_to_array is now a smarty function rather than modifier due to the fact that the way that smarty handles modifiers called on array values was breaking the detection of double calls to multienum_to_array.
22
23 r46872 - 2009-05-05 01:37:39 -0700 (Tue, 05 May 2009) - jchi - #27426 - Reverse the order of two conditions in modifier.multienum_to_array::smarty_modifier_multienum_to_array.
24 We should judge the empty string firstly.
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 r39146 - 2008-08-26 17:16:04 -0700 (Tue, 26 Aug 2008) - awu - Merging pre_5_1_0 to trunk
29
30 r35784 - 2008-05-20 14:31:40 -0700 (Tue, 20 May 2008) - dwheeler - 21475: Converted multiselect DynamicField default value to be a multiselect. 
31
32 r26565 - 2007-09-11 11:09:20 -0700 (Tue, 11 Sep 2007) - clee - Changed to just use explode function.  It is safer than split using commas because values themselves could have commas.
33
34 r26564 - 2007-09-11 11:03:41 -0700 (Tue, 11 Sep 2007) - clee - Fixed issues with multienum custom type.  
35 Added:
36 trunk/include/SugarFields/Fields/MultiEnum/DetailView.tpl
37 trunk/include/Smarty/plugins/modifier.multienum_to_array.php
38 Touched:
39 trunk/include/SugarFields/Fields/MultiEnum/EditView.tpl
40 trunk/include/SugarFields/Fields/MultiEnum/SugarFieldMultiEnum.php
41 trunk/modules/DynamicFields/DynamicField.php (changed saving of default/empty values)
42 trunk/include/EditView/EditView2.php (removed comments)
43
44
45 */
46
47
48 /**
49  * Smarty plugin
50  * @package Smarty
51  * @subpackage plugins
52  */
53
54
55 /**
56  * Smarty modifier to convert multienum separated value to Array
57  *
58  * Type:     function<br>
59  * Name:     multienum_to_array<br>
60  * Purpose:  Utility to transform multienum String to Array format
61  * @author   Collin Lee <clee at sugarcrm dot com>
62  * @param string The multienum field's value(s) as a String
63  * @param default The multienum field's default value
64  * @return Array
65  */
66 function smarty_function_multienum_to_array($params, &$smarty)
67 {
68         $ret = "";
69         if(empty($params['string'])) {
70         if (empty($params['default']))
71             $ret = array();
72         else if(is_array($params['default']))
73             $ret = $params['default'];
74         else
75            $ret = unencodeMultienum($params['default']);
76     } else {
77         if (is_array($params['string']))
78           $ret = $params['string'];
79         else
80           $ret = unencodeMultienum($params['string']);
81     }
82         
83     
84         if (!empty($params['assign']))
85         {
86                 $smarty->assign($params['assign'], $ret);
87                 return "";
88         }
89         
90         return ($ret);
91 }
92
93 ?>