]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/ModuleBuilder/views/view.labels.php
Release 6.5.0
[Github/sugarcrm.git] / modules / ModuleBuilder / views / view.labels.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 24, 2007
39  *
40  * To change the template for this generated file go to
41  * Window - Preferences - PHPeclipse - PHP - Code Templates
42  */
43 require_once('modules/ModuleBuilder/MB/AjaxCompose.php');
44 require_once('modules/ModuleBuilder/views/view.modulefields.php');
45 class ViewLabels extends ViewModulefields
46 {
47     /**
48          * @see SugarView::_getModuleTitleParams()
49          */
50         protected function _getModuleTitleParams($browserTitle = false)
51         {
52             global $mod_strings;
53
54         return array(
55            translate('LBL_MODULE_NAME','Administration'),
56            ModuleBuilderController::getModuleTitle(),
57            );
58     }
59
60         //STUDIO LABELS ONLY//
61         //TODO Bundle Studio and ModuleBuilder label handling to increase maintainability.
62         function display()
63         {
64                 $editModule = $_REQUEST['view_module'];
65                 $allLabels = (!empty($_REQUEST['labels']) && $_REQUEST['labels']== 'all');
66
67                 if (!isset($_REQUEST['MB']))
68                 {
69                     global $app_list_strings;
70                     $moduleNames = array_change_key_case($app_list_strings['moduleList']);
71                     $translatedEditModule = $moduleNames[strtolower($editModule)];
72                 }
73                 $selected_lang = (!empty($_REQUEST['selected_lang'])? $_REQUEST['selected_lang']:$_SESSION['authenticated_user_language']);
74                 if(empty($selected_lang)){
75                     $selected_lang = $GLOBALS['sugar_config']['default_language'];
76                 }
77
78                 $smarty = new Sugar_Smarty();
79                 global $mod_strings;
80         $smarty->assign('mod_strings', $mod_strings);
81                 $smarty->assign('available_languages',get_languages());
82
83
84         $objectName = BeanFactory::getObjectName($editModule);
85         VardefManager::loadVardef($editModule, $objectName);
86         global $dictionary;
87         $vnames = array();
88                 //jchi 24557 . We should list all the lables in viewdefs(list,detail,edit,quickcreate) that the user can edit them.
89                 require_once 'modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php' ;
90         $parser = new ListLayoutMetaDataParser ( MB_LISTVIEW, $editModule ) ;
91         foreach ( $parser->getLayout() as $key => $def )
92         {
93                 if(isset($def['label']) ) {
94                $vnames[$def['label']] = $def['label'];
95                 }
96         }
97
98        require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ;
99         $variableMap = $this->getVariableMap($editModule);
100         foreach($variableMap as $key => $value){
101                 $gridLayoutMetaDataParserTemp = new GridLayoutMetaDataParser ( $value, $editModule) ;
102                 foreach ( $gridLayoutMetaDataParserTemp->getLayout() as $panel)
103                 {
104                         foreach ( $panel as $row )
105                         {
106                             foreach ( $row as $fieldArray )
107                             { // fieldArray is an array('name'=>name,'label'=>label)
108                                 if (isset ( $fieldArray [ 'label' ] ))
109                                 {
110                                     $vnames[$fieldArray [ 'label' ] ] = $fieldArray [ 'label' ] ;
111                                 }
112                             }
113                         }
114                 }
115         }
116         //end
117
118         //Get Subpanel Labels:
119         require_once ('include/SubPanel/SubPanel.php') ;
120         $subList =  SubPanel::getModuleSubpanels ( $editModule );
121         foreach($subList as $subpanel => $titleLabel) {
122                 $vnames[$titleLabel] = $titleLabel;
123         }
124
125         foreach($dictionary[$objectName]['fields'] as $name=>$def) {
126                 if(isset($def['vname'])) {
127                $vnames[$def['vname']] = $def['vname'];
128                 }
129                 }
130             $formatted_mod_strings = array();
131
132             //we shouldn't set the $refresh=true here, or will lost template language mod_strings.
133             //return_module_language($selected_lang, $editModule,false) : the mod_strings will be included from cache files here.
134         foreach(return_module_language($selected_lang, $editModule,false) as $name=>$label) {
135                         //#25294
136                         if($allLabels || isset($vnames[$name]) || preg_match( '/lbl_city|lbl_country|lbl_billing_address|lbl_alt_address|lbl_shipping_address|lbl_postal_code|lbl_state$/si' , $name)) {
137                     $formatted_mod_strings[$name] = htmlentities($label, ENT_QUOTES, 'UTF-8');
138                         }
139         }
140         //Grab everything from the custom files
141         $mod_bak = $mod_strings;
142         $files = array(
143             "custom/modules/$editModule/language/$selected_lang.lang.php",
144             "custom/modules/$editModule/Ext/Language/$selected_lang.lang.ext.php"
145         );
146         foreach($files as $langfile){
147                 $mod_strings = array();
148                 if (is_file($langfile))
149                 {
150                    include($langfile);
151                    foreach($mod_strings as $key => $label)
152                    {
153                     $formatted_mod_strings[$key] = htmlentities($label, ENT_QUOTES, 'UTF-8');
154                    }
155                 }
156         }
157         $mod_strings = $mod_bak;
158         ksort($formatted_mod_strings);
159                 $smarty->assign('MOD', $formatted_mod_strings);
160                 $smarty->assign('view_module', $editModule);
161                 $smarty->assign('APP', $GLOBALS['app_strings']);
162                 $smarty->assign('selected_lang', $selected_lang);
163                 $smarty->assign('defaultHelp', 'labelsBtn');
164                 $smarty->assign('assistant', array('key'=>'labels', 'group'=>'module'));
165                 $smarty->assign('labels_choice', $mod_strings['labelTypes']);
166                 $smarty->assign('labels_current', $allLabels?"all":"");
167
168                 $ajax = new AjaxCompose();
169                 $ajax->addCrumb($mod_strings['LBL_STUDIO'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard")');
170                 $ajax->addCrumb($translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module='.$editModule.'")');
171                 $ajax->addCrumb($mod_strings['LBL_LABELS'], '');
172
173                 $html = $smarty->fetch('modules/ModuleBuilder/tpls/labels.tpl');
174                 $ajax->addSection('center', $GLOBALS['mod_strings']['LBL_SECTION_EDLABELS'], $html);
175                 echo $ajax->getJavascript();
176         }
177     
178     // fixing bug #39749: Quick Create in Studio
179     function getVariableMap($module)
180     {
181         $variableMap = array(MB_EDITVIEW => 'EditView', 
182                              MB_DETAILVIEW => 'DetailView', 
183                              MB_QUICKCREATE => 'QuickCreate');
184         
185         $hideQuickCreateForModules = array('KBDocuments',
186                                            'ProjectTask',
187                                            'Campaigns',
188                                            'Quotes',
189                                            'ProductTemplates');
190         
191         if(in_array($module, $hideQuickCreateForModules))
192         {
193             if(isset($variableMap['quickcreate']))
194             {
195                 unset($variableMap['quickcreate']);
196             }
197         }
198         
199         if($module == 'KBDocuments')
200         {
201             $variableMap  = array();
202         }
203         
204         return $variableMap;
205     }
206 }