]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/DynamicFields/templates/Fields/Forms/enum2.php
Release 6.5.0
[Github/sugarcrm.git] / modules / DynamicFields / templates / Fields / Forms / enum2.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
5  * 
6  * This program is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU Affero General Public License version 3 as published by the
8  * Free Software Foundation with the addition of the following permission added
9  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
10  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
11  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
12  * 
13  * This program is distributed in the hope that it will be useful, but WITHOUT
14  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
16  * details.
17  * 
18  * You should have received a copy of the GNU Affero General Public License along with
19  * this program; if not, see http://www.gnu.org/licenses or write to the Free
20  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
21  * 02110-1301 USA.
22  * 
23  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
24  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
25  * 
26  * The interactive user interfaces in modified source and object code versions
27  * of this program must display Appropriate Legal Notices, as required under
28  * Section 5 of the GNU Affero General Public License version 3.
29  * 
30  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
31  * these Appropriate Legal Notices must retain the display of the "Powered by
32  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
33  * technical reasons, the Appropriate Legal Notices must display the words
34  * "Powered by SugarCRM".
35  ********************************************************************************/
36
37 /*
38  * Created on Jul 18, 2007
39  *
40  * To change the template for this generated file go to
41  * Window - Preferences - PHPeclipse - PHP - Code Templates
42  */
43  function get_body(&$ss, $vardef){
44         $multi = false;
45     $radio = false;
46         if (isset ($vardef['type']) && $vardef['type'] == 'multienum')
47                 $multi = true;
48                 
49         $selected_options = "";
50         if ($multi && !empty($vardef['default'])) {
51                 $selected_options = unencodeMultienum( $vardef['default']);
52         } else if (isset($vardef['default'])){
53                 $selected_options = $vardef['default'];
54         }
55
56     $edit_mod_strings = return_module_language($GLOBALS['current_language'], 'EditCustomFields');
57
58         if(!empty($_REQUEST['type']) && $_REQUEST['type'] == 'radioenum'){
59                 $edit_mod_strings['LBL_DROP_DOWN_LIST'] = $edit_mod_strings['LBL_RADIO_FIELDS'];
60         $radio = true;
61         }
62         $package_strings = array();
63         if(!empty($_REQUEST['view_package'])){
64                 $view_package = $_REQUEST['view_package'];
65                 if($view_package != 'studio') {
66                         require_once('modules/ModuleBuilder/MB/ModuleBuilder.php');
67                         $mb = new ModuleBuilder();
68                         $module =& $mb->getPackageModule($view_package, $_REQUEST['view_module']);
69                         $lang = $GLOBALS['current_language'];
70                         //require_once($package->getPackageDir()."/include/language/$lang.lang.php");
71                         $module->mblanguage->generateAppStrings(false);
72                         $package_strings = $module->mblanguage->appListStrings[$lang.'.lang.php'];
73                 }
74         }
75         
76         global $app_list_strings;
77         $my_list_strings = $app_list_strings;
78         $my_list_strings = array_merge($my_list_strings, $package_strings);
79         foreach($my_list_strings as $key=>$value){
80                 if(!is_array($value)){
81                         unset($my_list_strings[$key]);
82                 }
83         }
84         $dropdowns = array_keys($my_list_strings);
85         sort($dropdowns);
86     $default_dropdowns = array();
87     if(!empty($vardef['options']) && !empty($my_list_strings[$vardef['options']])){
88                 $default_dropdowns = $my_list_strings[$vardef['options']];
89     }else{
90         //since we do not have a default value then we should assign the first one.
91         $key = $dropdowns[0];
92         $default_dropdowns = $my_list_strings[$key];
93     }
94     
95     $selected_dropdown = '';
96     if(!empty($vardef['options'])){
97         $selected_dropdown = $vardef['options'];
98
99     }
100     $show = true;
101         if(!empty($_REQUEST['refresh_dropdown']))
102                 $show = false;
103
104         $ss->assign('dropdowns', $dropdowns);
105         $ss->assign('default_dropdowns', $default_dropdowns);
106         $ss->assign('selected_dropdown', $selected_dropdown);
107         $ss->assign('show', $show);
108         $ss->assign('selected_options', $selected_options);
109         $ss->assign('multi', isset($multi) ? $multi: false);
110     $ss->assign('radio', isset($radio) ? $radio: false);
111         $ss->assign('dropdown_name',(!empty($vardef['options']) ? $vardef['options'] : ''));
112
113         require_once('include/JSON.php');
114         $json = new JSON(JSON_LOOSE_TYPE);
115         $ss->assign('app_list_strings', "''");
116         return $ss->fetch('modules/DynamicFields/templates/Fields/Forms/enum.tpl');
117  }
118 ?>