2 if (! defined ( 'sugarEntry' ) || ! sugarEntry)
3 die ( 'Not A Valid Entry Point' ) ;
5 /*********************************************************************************
6 * SugarCRM 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()
85 translate('LBL_MODULE_NAME','Administration'),
86 $mod_strings['LBL_MODULEBUILDER'],
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 ( ) ;
123 $smarty->assign ( 'layouttitle', translate ( 'LBL_LAYOUT_PREVIEW', 'ModuleBuilder' ) ) ;
126 $smarty->assign ( 'layouttitle', translate ( 'LBL_CURRENT_LAYOUT', 'ModuleBuilder' ) ) ;
127 if (! $this->fromModuleBuilder)
129 $buttons [] = array (
131 'text' => translate ( 'LBL_BTN_SAVE' ) ,
132 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handleSave();'"
134 $buttons [] = array (
135 'id' => 'publishBtn' ,
136 'text' => translate ( 'LBL_BTN_SAVEPUBLISH' ) ,
137 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handlePublish();'"
139 $buttons [] = array ( 'id' => 'spacer' , 'width' => '50px' ) ;
140 $buttons [] = array (
141 'id' => 'historyBtn' ,
142 'text' => translate ( 'LBL_HISTORY' ) ,
143 'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'"
145 $buttons [] = array (
146 'id' => 'historyDefault' ,
147 'text' => translate ( 'LBL_RESTORE_DEFAULT' ) ,
148 'actionScript' => "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'"
152 $buttons [] = array (
154 'text' => $GLOBALS [ 'mod_strings' ] [ 'LBL_BTN_SAVE' ] ,
155 'actionScript' => "onclick='if(Studio2.checkGridLayout(\"{$this->editLayout}\")) Studio2.handlePublish();'"
157 $buttons [] = array ( 'id' => 'spacer' , 'width' => '50px' ) ;
158 $buttons [] = array (
159 'id' => 'historyBtn' ,
160 'text' => translate ( 'LBL_HISTORY' ) ,
161 'actionScript' => "onclick='ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")'"
163 $buttons [] = array (
164 'id' => 'historyDefault' ,
165 'text' => translate ( 'LBL_RESTORE_DEFAULT' ) ,
166 'actionScript' => "onclick='ModuleBuilder.history.revert(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$history->getLast()}\", \"\")'"
172 foreach ( $buttons as $button )
174 if ($button['id'] == "spacer") {
175 $html .= "<td style='width:{$button['width']}'> </td>";
177 $html .= "<td><input id='{$button['id']}' type='button' valign='center' class='button' style='cursor:pointer' "
178 . "onmousedown='this.className=\"buttonOn\";return false;' onmouseup='this.className=\"button\"' "
179 . "onmouseout='this.className=\"button\"' {$button['actionScript']} value = '{$button['text']}' ></td>" ;
183 $smarty->assign ( 'buttons', $html ) ;
185 // assign fields and layout
186 $smarty->assign ( 'available_fields', $parser->getAvailableFields () ) ;
187 $smarty->assign ( 'required_fields', $requiredFields) ;
188 $smarty->assign ( 'layout', $parser->getLayout () ) ;
189 $smarty->assign ( 'view_module', $this->editModule ) ;
190 $smarty->assign ( 'view', $this->editLayout ) ;
191 $smarty->assign ( 'maxColumns', $parser->getMaxColumns() ) ;
192 $smarty->assign ( 'nextPanelId', $parser->getFirstNewPanelId() ) ;
193 $smarty->assign ( 'displayAsTabs', $parser->getUseTabs() ) ;
194 $smarty->assign ( 'fieldwidth', 150 ) ;
195 $smarty->assign ( 'translate', $this->fromModuleBuilder ? false : true ) ;
197 if ($this->fromModuleBuilder)
199 $smarty->assign ( 'fromModuleBuilder', $this->fromModuleBuilder ) ;
200 $smarty->assign ( 'view_package', $this->package ) ;
204 MB_EDITVIEW => 'LBL_EDITVIEW' ,
205 MB_DETAILVIEW => 'LBL_DETAILVIEW' ,
206 MB_QUICKCREATE => 'LBL_QUICKCREATE',
209 $layoutLabel = 'LBL_LAYOUTS' ;
210 $layoutView = 'layouts' ;
213 $ajax = new AjaxCompose ( ) ;
216 $translatedViewType = '' ;
217 if ( isset ( $labels [ strtolower ( $this->editLayout ) ] ) )
218 $translatedViewType = translate ( $labels [ strtolower( $this->editLayout ) ] , 'ModuleBuilder' ) ;
220 if ($this->fromModuleBuilder)
222 $ajax->addCrumb ( translate ( 'LBL_MODULEBUILDER', 'ModuleBuilder' ), 'ModuleBuilder.main("mb")' ) ;
223 $ajax->addCrumb ( $this->package, 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $this->package . '")' ) ;
224 $ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $this->package . '&view_module=' . $this->editModule . '")' ) ;
225 $ajax->addCrumb ( translate ( $layoutLabel, 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view='.$layoutView.'&view_module=' . $this->editModule . '&view_package=' . $this->package . '")' ) ;
226 $ajax->addCrumb ( $translatedViewType, '' ) ;
229 $ajax->addCrumb ( translate ( 'LBL_STUDIO', 'ModuleBuilder' ), 'ModuleBuilder.main("studio")' ) ;
230 $ajax->addCrumb ( $this->translatedEditModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->editModule . '")' ) ;
231 $ajax->addCrumb ( translate ( $layoutLabel, 'ModuleBuilder' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view='.$layoutView.'&view_module=' . $this->editModule . '")' ) ;
232 $ajax->addCrumb ( $translatedViewType, '' ) ;
235 // set up language files
236 $smarty->assign ( 'language', $parser->getLanguage() ) ; // for sugar_translate in the smarty template
237 $smarty->assign('from_mb',$this->fromModuleBuilder);
238 $smarty->assign('calc_field_list', json_encode($parser->getCalculatedFields()));
239 if ($this->fromModuleBuilder) {
240 $mb = new ModuleBuilder ( ) ;
241 $module = & $mb->getPackageModule ( $this->package, $this->editModule ) ;
242 $smarty->assign('current_mod_strings', $module->getModStrings());
245 $ajax->addSection ( 'center', $translatedViewType, $smarty->fetch ( 'modules/ModuleBuilder/tpls/layoutView.tpl' ) ) ;
247 echo $smarty->fetch ( 'modules/ModuleBuilder/tpls/Preview/layoutView.tpl' );
249 echo $ajax->getJavascript () ;