2 if (! defined ( 'sugarEntry' ) || ! sugarEntry)
3 die ( 'Not A Valid Entry Point' ) ;
4 /*********************************************************************************
5 * SugarCRM Community Edition is a customer relationship management program developed by
6 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU Affero General Public License version 3 as published by the
10 * Free Software Foundation with the addition of the following permission added
11 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
12 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
13 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
20 * You should have received a copy of the GNU Affero General Public License along with
21 * this program; if not, see http://www.gnu.org/licenses or write to the Free
22 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
26 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
28 * The interactive user interfaces in modified source and object code versions
29 * of this program must display Appropriate Legal Notices, as required under
30 * Section 5 of the GNU Affero General Public License version 3.
32 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
33 * these Appropriate Legal Notices must retain the display of the "Powered by
34 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
35 * technical reasons, the Appropriate Legal Notices must display the words
36 * "Powered by SugarCRM".
37 ********************************************************************************/
41 require_once ('modules/ModuleBuilder/views/view.listview.php') ;
42 require_once 'modules/ModuleBuilder/parsers/constants.php' ;
44 class ViewPopupview extends ViewListView
46 function __construct()
48 $this->editModule = $_REQUEST [ 'view_module' ] ;
49 $this->editLayout = $_REQUEST [ 'view' ] ;
50 $this->editPackage = (isset ( $_REQUEST [ 'view_package' ] ) && ! empty ( $_REQUEST [ 'view_package' ] )) ? $_REQUEST [ 'view_package' ] : null ;
52 $this->fromModuleBuilder = isset ( $_REQUEST [ 'MB' ] ) || (isset($_REQUEST['view_package']) && $_REQUEST['view_package'] && $_REQUEST['view_package'] != 'studio') ;
53 if (!$this->fromModuleBuilder)
55 global $app_list_strings ;
56 $moduleNames = array_change_key_case ( $app_list_strings [ 'moduleList' ] ) ;
57 $this->translatedEditModule = $moduleNames [ strtolower ( $this->editModule ) ] ;
62 * @see SugarView::_getModuleTitleParams()
64 protected function _getModuleTitleParams($browserTitle = false)
69 translate('LBL_MODULE_NAME','Administration'),
70 ModuleBuilderController::getModuleTitle(),
75 * Pseudo-constructor to enable subclasses to call a parent's constructor without knowing the parent in PHP4
90 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
91 $parser = ParserFactory::getParser ( $this->editLayout, $this->editModule, $this->editPackage) ;
93 $smarty = $this->constructSmarty ( $parser ) ;
96 echo $smarty->fetch ( "modules/ModuleBuilder/tpls/Preview/listView.tpl" ) ;
99 $ajax = $this->constructAjax () ;
100 $ajax->addSection ( 'center', translate('LBL_POPUP'), $smarty->fetch ( "modules/ModuleBuilder/tpls/listView.tpl" ) ) ;
101 echo $ajax->getJavascript () ;
105 function constructAjax()
107 require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
108 $ajax = new AjaxCompose ( ) ;
110 if ($this->fromModuleBuilder)
112 $ajax->addCrumb ( translate ( 'LBL_MODULEBUILDER', 'ModuleBuilder' ), 'ModuleBuilder.main("mb")' ) ;
113 $ajax->addCrumb ( $_REQUEST [ 'view_package' ], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $this->editPackage . '")' ) ;
114 $ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $this->editPackage . '&view_module=' . $this->editModule . '")' ) ;
115 $ajax->addCrumb ( translate('LBL_LAYOUTS', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&layouts=1&MB=1&view_package='.$this->editPackage.'&view_module=' . $this->editModule . '")');
116 $ajax->addCrumb ( translate('LBL_POPUP', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=popup&MB=1&view_package='.$this->editPackage.'&view_module=' . $this->editModule . '")' );
118 $ViewLabel = ($this->editLayout == MB_POPUPLIST) ? 'LBL_POPUPLISTVIEW' : 'LBL_POPUPSEARCH';
119 $ajax->addCrumb ( translate ($ViewLabel, 'ModuleBuilder' ), '' ) ;
121 $ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_module=' . $this->editModule . '")' ) ;
122 $ajax->addCrumb ( translate('LBL_LAYOUTS', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&layouts=1&view_module=' . $this->editModule . '")');
123 $ajax->addCrumb ( translate('LBL_POPUP', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=popup&view_module=' . $this->editModule . '")' );
124 $ViewLabel = ($this->editLayout == MB_POPUPLIST) ? 'LBL_POPUPLISTVIEW' : 'LBL_POPUPSEARCH';
125 $ajax->addCrumb ( translate ($ViewLabel, 'ModuleBuilder' ), '' ) ;
130 function constructSmarty(
134 $smarty = new Sugar_Smarty ( ) ;
135 $smarty->assign ( 'translate', true ) ;
136 $smarty->assign ( 'language', $parser->getLanguage () ) ;
138 $smarty->assign ( 'view', $this->editLayout ) ;
139 $smarty->assign ( 'action', 'popupSave' ) ;
140 $smarty->assign( 'module', 'ModuleBuilder');
141 $smarty->assign ( 'view_module', $this->editModule ) ;
142 $smarty->assign ( 'field_defs', $parser->getFieldDefs () ) ;
143 $helpName = (isset( $_REQUEST['view']) && $_REQUEST['view']==MB_POPUPSEARCH) ? 'searchViewEditor' : 'popupListViewEditor';
144 $smarty->assign ( 'helpName', $helpName ) ;
145 $smarty->assign ( 'helpDefault', 'modify' ) ;
146 if ($this->fromModuleBuilder) {
147 $mb = new ModuleBuilder ( ) ;
148 $module = & $mb->getPackageModule ( $this->editPackage, $this->editModule ) ;
149 $smarty->assign('current_mod_strings', $module->getModStrings());
152 $smarty->assign ( 'title', $this->_constructTitle () ) ;
153 $groups = array ( ) ;
154 foreach ( $parser->columns as $column => $function )
156 $groups [ $GLOBALS [ 'mod_strings' ] [ $column ] ] = $parser->$function () ;
158 foreach ( $groups as $groupKey => $group )
160 foreach ( $group as $fieldKey => $field )
162 if (isset ( $field [ 'width' ] ))
164 if (substr ( $field [ 'width' ], - 1, 1 ) == '%')
166 $groups [ $groupKey ] [ $fieldKey ] [ 'width' ] = substr ( $field [ 'width' ], 0, strlen ( $field [ 'width' ] ) - 1 ) ;
172 $smarty->assign ( 'groups', $groups ) ;
175 $imageSave = SugarThemeRegistry::current()->getImage('studio_save') ;
177 $histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")" ;
178 if (isset($this->searchlayout))
179 $histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$this->searchlayout}\")" ;
181 $buttons = array ( ) ;
182 if (! $this->fromModuleBuilder)
184 $buttons [] = array ( 'name' => 'savebtn' , 'image' => $imageSave , 'text' => $GLOBALS [ 'mod_strings' ] [ 'LBL_BTN_SAVEPUBLISH' ] , 'actionScript' => "onclick='studiotabs.generateGroupForm(\"edittabs\");ModuleBuilder.state.isDirty=false;ModuleBuilder.submitForm(\"edittabs\" )'" ) ;
187 $buttons [] = array ( 'name' => 'mbsavebtn' , 'image' => $imageSave , 'text' => $GLOBALS [ 'mod_strings' ] [ 'LBL_BTN_SAVE' ] , 'actionScript' => "onclick='studiotabs.generateGroupForm(\"edittabs\");ModuleBuilder.state.isDirty=false;ModuleBuilder.submitForm(\"edittabs\" )'" ) ;
189 $buttons [] = array ( 'name' => 'historyBtn' , 'text' => translate ( 'LBL_HISTORY' ) , 'actionScript' => "onclick='$histaction'" ) ;
190 $smarty->assign ( 'buttons', $this->_buildImageButtons ( $buttons ) ) ;
191 $editImage = SugarThemeRegistry::current()->getImage('edit_inline') ;
192 $smarty->assign ( 'editImage', $editImage ) ;
193 $deleteImage = SugarThemeRegistry::current()->getImage('delete_inline') ;
194 $smarty->assign ( 'deleteImage', $deleteImage ) ;
195 $smarty->assign ( 'MOD', $GLOBALS [ 'mod_strings' ] ) ;
197 if ($this->fromModuleBuilder)
199 $smarty->assign ( 'MB', true ) ;
200 $smarty->assign ( 'view_package', $this->editPackage ) ;
201 $smarty->assign ( 'description', $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_DESCRIPTION' ] ) ;
205 $smarty->assign ( 'description', $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_DESCRIPTION' ] ) ;
211 function _constructTitle()
214 global $app_list_strings ;
216 if ($this->fromModuleBuilder)
218 $title = $this->editModule ;
221 $title = $app_list_strings [ 'moduleList' ] [ $this->editModule ] ;
223 return $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_EDIT' ] . ': ' . $title ;