2 if (! defined ( 'sugarEntry' ) || ! sugarEntry)
3 die ( 'Not A Valid Entry Point' ) ;
5 /*********************************************************************************
6 * SugarCRM Community Edition is a customer relationship management program developed by
7 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
9 * This program is free software; you can redistribute it and/or modify it under
10 * the terms of the GNU Affero General Public License version 3 as published by the
11 * Free Software Foundation with the addition of the following permission added
12 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
13 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
14 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
16 * This program is distributed in the hope that it will be useful, but WITHOUT
17 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
21 * You should have received a copy of the GNU Affero General Public License along with
22 * this program; if not, see http://www.gnu.org/licenses or write to the Free
23 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
26 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
27 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
29 * The interactive user interfaces in modified source and object code versions
30 * of this program must display Appropriate Legal Notices, as required under
31 * Section 5 of the GNU Affero General Public License version 3.
33 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
34 * these Appropriate Legal Notices must retain the display of the "Powered by
35 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
36 * technical reasons, the Appropriate Legal Notices must display the words
37 * "Powered by SugarCRM".
38 ********************************************************************************/
40 /*********************************************************************************
42 * Description: This file is used to override the default Meta-data EditView behavior
43 * to provide customization specific to the Calls module.
44 * Portions created by SugarCRM are Copyright (C) SugarCRM, Inc.
45 * All Rights Reserved.
46 * Contributor(s): ______________________________________..
47 ********************************************************************************/
49 require_once ('include/MVC/View/views/view.edit.php') ;
50 require_once ('modules/ModuleBuilder/parsers/ParserFactory.php') ;
51 require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
52 require_once 'modules/ModuleBuilder/parsers/constants.php' ;
54 //require_once('include/Utils.php');
57 class ViewLayoutView extends ViewEdit
59 function ViewLayoutView ()
61 $GLOBALS [ 'log' ]->debug ( 'in ViewLayoutView' ) ;
62 $this->editModule = $_REQUEST [ 'view_module' ] ;
63 $this->editLayout = $_REQUEST [ 'view' ] ;
64 $this->package = null;
65 $this->fromModuleBuilder = isset ( $_REQUEST [ 'MB' ] ) || !empty($_REQUEST [ 'view_package' ]);
66 if ($this->fromModuleBuilder)
68 $this->package = $_REQUEST [ 'view_package' ] ;
71 global $app_list_strings ;
72 $moduleNames = array_change_key_case ( $app_list_strings [ 'moduleList' ] ) ;
73 $this->translatedEditModule = $moduleNames [ strtolower ( $this->editModule ) ] ;
78 * @see SugarView::_getModuleTitleParams()
80 protected function _getModuleTitleParams($browserTitle = false)
85 translate('LBL_MODULE_NAME','Administration'),
86 ModuleBuilderController::getModuleTitle(),
90 // DO NOT REMOVE - overrides parent ViewEdit preDisplay() which attempts to load a bean for a non-existent module
91 function preDisplay ()
95 function display ($preview = false)
99 $parser = ParserFactory::getParser($this->editLayout,$this->editModule,$this->package);
100 $history = $parser->getHistory () ;
101 $smarty = new Sugar_Smarty ( ) ;
102 //Add in the module we are viewing to our current mod strings
103 if (! $this->fromModuleBuilder) {
104 global $current_language;
105 $editModStrings = return_module_language($current_language, $this->editModule);
106 $mod_strings = sugarArrayMerge($editModStrings, $mod_strings);
108 $smarty->assign('mod', $mod_strings);
109 $smarty->assign('MOD', $mod_strings);
111 $images = array ( 'icon_save' => 'studio_save' , 'icon_publish' => 'studio_publish' , 'icon_address' => 'icon_Address' , 'icon_emailaddress' => 'icon_EmailAddress' , 'icon_phone' => 'icon_Phone' ) ;
112 foreach ( $images as $image => $file )
114 $smarty->assign ( $image, SugarThemeRegistry::current()->getImage($file) ) ;
117 $requiredFields = implode($parser->getRequiredFields () , ',');
118 $slashedRequiredFields = addslashes($requiredFields);
119 $buttons = array ( ) ;
120 $disableLayout = false;
124 $smarty->assign ( 'layouttitle', translate ( 'LBL_LAYOUT_PREVIEW', 'ModuleBuilder' ) ) ;
127 $smarty->assign ( 'layouttitle', translate ( 'LBL_CURRENT_LAYOUT', 'ModuleBuilder' ) ) ;
129 if($this->editLayout == MB_DETAILVIEW || $this->editLayout == MB_QUICKCREATE){
130 $parser2 = ParserFactory::getParser(MB_EDITVIEW,$this->editModule,$this->package);
131 if($this->editLayout == MB_DETAILVIEW){
132 $disableLayout = $parser2->getSyncDetailEditViews();
134 if(!empty($_REQUEST['copyFromEditView'])){
135 $editViewPanels = $parser2->convertFromCanonicalForm ( $parser2->_viewdefs [ 'panels' ] , $parser2->_fielddefs ) ;
136 $parser->_viewdefs [ 'panels' ] = $editViewPanels;
137 $parser->_fielddefs = $parser2->_fielddefs;
138 $parser->setUseTabs($parser2->getUseTabs());
142 if (! $this->fromModuleBuilder)
144 $buttons [] = array (
146 'text' => translate ( 'LBL_BTN_SAVE' ) ,
147 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handleSave();'",
148 'disabled' => $disableLayout,
150 $buttons [] = array (
151 'id' => 'publishBtn' ,
152 'text' => translate ( 'LBL_BTN_SAVEPUBLISH' ) ,
153 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handlePublish();'",
154 'disabled' => $disableLayout,
156 $buttons [] = array ( 'id' => 'spacer' , 'width' => '33px' ) ;
157 $buttons [] = array (
158 'id' => 'historyBtn' ,
159 'text' => translate ( 'LBL_HISTORY' ) ,
160 'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'",
161 'disabled' => $disableLayout,
163 $buttons [] = array (
164 'id' => 'historyDefault' ,
165 'text' => translate ( 'LBL_RESTORE_DEFAULT' ) ,
166 'actionScript' => "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'",
167 'disabled' => $disableLayout,
171 $buttons [] = array (
173 'text' => $GLOBALS [ 'mod_strings' ] [ 'LBL_BTN_SAVE' ] ,
174 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handlePublish();'",
175 'disabled' => $disableLayout,
177 $buttons [] = array ( 'id' => 'spacer' , 'width' => '33px' ) ;
178 $buttons [] = array (
179 'id' => 'historyBtn' ,
180 'text' => translate ( 'LBL_HISTORY' ) ,
181 'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'",
182 'disabled' => $disableLayout,
184 $buttons [] = array (
185 'id' => 'historyDefault' ,
186 'text' => translate ( 'LBL_RESTORE_DEFAULT' ) ,
187 'actionScript' => "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'",
188 'disabled' => $disableLayout,
193 if($this->editLayout == MB_DETAILVIEW || $this->editLayout == MB_QUICKCREATE){
194 $buttons [] = array (
195 'id' => 'copyFromEditView' ,
196 'text' => translate ( 'LBL_COPY_FROM_EDITVIEW' ) ,
197 'actionScript' => "onclick='ModuleBuilder.copyFromView(\"{$this->editModule}\", \"{$this->editLayout}\")'",
198 'disabled' => $disableLayout,
204 foreach ( $buttons as $button )
206 if ($button['id'] == "spacer") {
207 $html .= "<td style='width:{$button['width']}'> </td>";
209 $html .= "<td><input id='{$button['id']}' type='button' valign='center' class='button' style='cursor:pointer' "
210 . "onmousedown='this.className=\"buttonOn\";return false;' onmouseup='this.className=\"button\"' "
211 . "onmouseout='this.className=\"button\"' {$button['actionScript']} value = '{$button['text']}'" ;
212 if(!empty($button['disabled'])){
213 $html .= " disabled";
219 $smarty->assign ( 'buttons', $html ) ;
221 // assign fields and layout
222 $smarty->assign ( 'available_fields', $parser->getAvailableFields () ) ;
224 $smarty->assign ( 'disable_layout', $disableLayout) ;
225 $smarty->assign ( 'required_fields', $requiredFields) ;
226 $smarty->assign ( 'layout', $parser->getLayout () ) ;
227 $smarty->assign ( 'field_defs', $parser->getFieldDefs () ) ;
228 $smarty->assign ( 'view_module', $this->editModule ) ;
229 $smarty->assign ( 'view', $this->editLayout ) ;
230 $smarty->assign ( 'maxColumns', $parser->getMaxColumns() ) ;
231 $smarty->assign ( 'nextPanelId', $parser->getFirstNewPanelId() ) ;
232 $smarty->assign ( 'displayAsTabs', $parser->getUseTabs() ) ;
233 $smarty->assign ( 'syncDetailEditViews', $parser->getSyncDetailEditViews() ) ;
234 $smarty->assign ( 'fieldwidth', 150 ) ;
235 $smarty->assign ( 'translate', $this->fromModuleBuilder ? false : true ) ;
237 if ($this->fromModuleBuilder)
239 $smarty->assign ( 'fromModuleBuilder', $this->fromModuleBuilder ) ;
240 $smarty->assign ( 'view_package', $this->package ) ;
244 MB_EDITVIEW => 'LBL_EDITVIEW' ,
245 MB_DETAILVIEW => 'LBL_DETAILVIEW' ,
246 MB_QUICKCREATE => 'LBL_QUICKCREATE',
249 $layoutLabel = 'LBL_LAYOUTS' ;
250 $layoutView = 'layouts' ;
253 $ajax = new AjaxCompose ( ) ;
256 $translatedViewType = '' ;
257 if ( isset ( $labels [ strtolower ( $this->editLayout ) ] ) )
258 $translatedViewType = translate ( $labels [ strtolower( $this->editLayout ) ] , 'ModuleBuilder' ) ;
260 if ($this->fromModuleBuilder)
262 $ajax->addCrumb ( translate ( 'LBL_MODULEBUILDER', 'ModuleBuilder' ), 'ModuleBuilder.main("mb")' ) ;
263 $ajax->addCrumb ( $this->package, 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $this->package . '")' ) ;
264 $ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $this->package . '&view_module=' . $this->editModule . '")' ) ;
265 $ajax->addCrumb ( translate ( $layoutLabel, 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view='.$layoutView.'&view_module=' . $this->editModule . '&view_package=' . $this->package . '")' ) ;
266 $ajax->addCrumb ( $translatedViewType, '' ) ;
269 $ajax->addCrumb ( translate ( 'LBL_STUDIO', 'ModuleBuilder' ), 'ModuleBuilder.main("studio")' ) ;
270 $ajax->addCrumb ( $this->translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->editModule . '")' ) ;
271 $ajax->addCrumb ( translate ( $layoutLabel, 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view='.$layoutView.'&view_module=' . $this->editModule . '")' ) ;
272 $ajax->addCrumb ( $translatedViewType, '' ) ;
275 // set up language files
276 $smarty->assign ( 'language', $parser->getLanguage() ) ; // for sugar_translate in the smarty template
277 $smarty->assign('from_mb',$this->fromModuleBuilder);
278 $smarty->assign('calc_field_list', json_encode($parser->getCalculatedFields()));
279 if ($this->fromModuleBuilder) {
280 $mb = new ModuleBuilder ( ) ;
281 $module = & $mb->getPackageModule ( $this->package, $this->editModule ) ;
282 $smarty->assign('current_mod_strings', $module->getModStrings());
285 $ajax->addSection ( 'center', $translatedViewType, $smarty->fetch ( 'modules/ModuleBuilder/tpls/layoutView.tpl' ) ) ;
287 echo $smarty->fetch ( 'modules/ModuleBuilder/tpls/Preview/layoutView.tpl' );
289 echo $ajax->getJavascript () ;