]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/DynamicFields/templates/Fields/Forms/enum2.php
Release 6.2.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-2011 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         if (isset ($vardef['type']) && $vardef['type'] == 'multienum')
46                 $multi = true;
47                 
48         $selected_options = "";
49         if ($multi && !empty($vardef['default'])) {
50                 $selected_options = unencodeMultienum( $vardef['default']);
51         } else if (isset($vardef['default'])){
52                 $selected_options = $vardef['default'];
53         }
54
55     $edit_mod_strings = return_module_language($GLOBALS['current_language'], 'EditCustomFields');
56
57         if(!empty($_REQUEST['type']) && $_REQUEST['type'] == 'radioenum'){
58                 $edit_mod_strings['LBL_DROP_DOWN_LIST'] = $edit_mod_strings['LBL_RADIO_FIELDS'];
59         }
60         $package_strings = array();
61         if(!empty($_REQUEST['view_package'])){
62                 $view_package = $_REQUEST['view_package'];
63                 if($view_package != 'studio') {
64                         require_once('modules/ModuleBuilder/MB/ModuleBuilder.php');
65                         $mb = new ModuleBuilder();
66                         $module =& $mb->getPackageModule($view_package, $_REQUEST['view_module']);
67                         $lang = $GLOBALS['current_language'];
68                         //require_once($package->getPackageDir()."/include/language/$lang.lang.php");
69                         $module->mblanguage->generateAppStrings(false);
70                         $package_strings = $module->mblanguage->appListStrings[$lang.'.lang.php'];
71                 }
72         }
73         
74         global $app_list_strings;
75         $my_list_strings = $app_list_strings;
76         $my_list_strings = array_merge($my_list_strings, $package_strings);
77         foreach($my_list_strings as $key=>$value){
78                 if(!is_array($value)){
79                         unset($my_list_strings[$key]);
80                 }
81         }
82         $dropdowns = array_keys($my_list_strings);
83         sort($dropdowns);
84     $default_dropdowns = array();
85     if(!empty($vardef['options']) && !empty($my_list_strings[$vardef['options']])){
86                 $default_dropdowns = $my_list_strings[$vardef['options']];
87     }else{
88         //since we do not have a default value then we should assign the first one.
89         $key = $dropdowns[0];
90         $default_dropdowns = $my_list_strings[$key];
91     }
92     
93     $selected_dropdown = '';
94     if(!empty($vardef['options'])){
95         $selected_dropdown = $vardef['options'];
96
97     }
98     $show = true;
99         if(!empty($_REQUEST['refresh_dropdown']))
100                 $show = false;
101
102         $ss->assign('dropdowns', $dropdowns);
103         $ss->assign('default_dropdowns', $default_dropdowns);
104         $ss->assign('selected_dropdown', $selected_dropdown);
105         $ss->assign('show', $show);
106         $ss->assign('selected_options', $selected_options);
107         $ss->assign('multi', isset($multi) ? $multi: false);
108         $ss->assign('dropdown_name',(!empty($vardef['options']) ? $vardef['options'] : ''));
109
110         require_once('include/JSON.php');
111         $json = new JSON(JSON_LOOSE_TYPE);
112         $ss->assign('app_list_strings', "''");
113         return $ss->fetch('modules/DynamicFields/templates/Fields/Forms/enum.tpl');
114  }
115 ?>