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-2013 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 ********************************************************************************/
43 require_once ('modules/ModuleBuilder/views/view.listview.php') ;
44 require_once 'modules/ModuleBuilder/parsers/constants.php' ;
46 class ViewDashlet extends ViewListView
48 function __construct()
50 $this->editModule = $_REQUEST [ 'view_module' ] ;
51 $this->editLayout = $_REQUEST [ 'view' ] ;
52 if(isset ( $_REQUEST [ 'view_package' ] ) && ! empty ( $_REQUEST [ 'view_package' ] ))
53 $this->editPackage = $_REQUEST [ 'view_package' ];
55 $this->editPackage = null;
57 $this->fromModuleBuilder = isset ( $_REQUEST [ 'MB' ] ) || (isset($_REQUEST['view_package']) && $_REQUEST['view_package'] && $_REQUEST['view_package'] != 'studio') ;
59 if (!$this->fromModuleBuilder)
61 global $app_list_strings ;
62 $moduleNames = array_change_key_case ( $app_list_strings [ 'moduleList' ] ) ;
63 $this->translatedEditModule = $moduleNames [ strtolower ( $this->editModule ) ] ;
68 * @see SugarView::_getModuleTitleParams()
70 protected function _getModuleTitleParams($browserTitle = false)
75 translate('LBL_MODULE_NAME','Administration'),
76 ModuleBuilderController::getModuleTitle(),
80 // DO NOT REMOVE - overrides parent ViewEdit preDisplay() which attempts to load a bean for a non-existent module
91 require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
92 $parser = ParserFactory::getParser ( $this->editLayout, $this->editModule, $this->editPackage) ;
94 $smarty = $this->constructSmarty ( $parser ) ;
97 echo $smarty->fetch ( "modules/ModuleBuilder/tpls/Preview/listView.tpl" ) ;
100 $ajax = $this->constructAjax () ;
101 $ajax->addSection ( 'center', translate('LBL_DASHLET'), $smarty->fetch ( "modules/ModuleBuilder/tpls/listView.tpl" ) ) ;
102 echo $ajax->getJavascript () ;
106 function constructAjax()
108 require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
109 $ajax = new AjaxCompose ( ) ;
111 if ($this->fromModuleBuilder)
113 $ajax->addCrumb ( translate ( 'LBL_MODULEBUILDER', 'ModuleBuilder' ), 'ModuleBuilder.main("mb")' ) ;
114 $ajax->addCrumb ( $_REQUEST [ 'view_package' ], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&package=' . $this->editPackage . '")' ) ;
115 $ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_package=' . $this->editPackage . '&view_module=' . $this->editModule . '")' ) ;
116 $ajax->addCrumb ( translate('LBL_LAYOUTS', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&layouts=1&MB=1&view_package='.$this->editPackage.'&view_module=' . $this->editModule . '")');
117 $ajax->addCrumb ( translate('LBL_DASHLET', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=dashlet&MB=1&view_package='.$this->editPackage.'&view_module=' . $this->editModule . '")' );
119 $ViewLabel = ($this->editLayout == MB_DASHLET) ? 'LBL_DASHLETLISTVIEW' : 'LBL_DASHLETSEARCHVIEW';
120 $ajax->addCrumb ( translate ($ViewLabel, 'ModuleBuilder' ), '' ) ;
122 $ajax->addCrumb ( translate($this->editModule), 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_module=' . $this->editModule . '")' ) ;
123 $ajax->addCrumb ( translate('LBL_LAYOUTS', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&layouts=1&view_module=' . $this->editModule . '")');
124 $ajax->addCrumb ( translate('LBL_DASHLET', 'ModuleBuilder'), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=dashlet&view_module=' . $this->editModule . '")' );
125 $ViewLabel = ($this->editLayout == MB_DASHLET) ? 'LBL_DASHLETLISTVIEW' : 'LBL_DASHLETSEARCHVIEW';
126 $ajax->addCrumb ( translate ($ViewLabel, 'ModuleBuilder' ), '' ) ;
131 function constructSmarty($parser)
133 $smarty = new Sugar_Smarty ( ) ;
134 $smarty->assign ( 'translate', true ) ;
135 $smarty->assign ( 'language', $parser->getLanguage () ) ;
137 $smarty->assign ( 'view', $this->editLayout ) ;
138 $smarty->assign ( 'action', 'dashletSave' ) ;
139 $smarty->assign( 'module', 'ModuleBuilder');
140 $smarty->assign ( 'view_module', $this->editModule ) ;
141 $smarty->assign ( 'field_defs', $parser->getFieldDefs () ) ;
142 $helpName = (isset( $_REQUEST['view']) && $_REQUEST['view']=='dashletsearch') ? 'searchViewEditor' : 'listViewEditor';
143 $smarty->assign ( 'helpName', $helpName ) ;
144 $smarty->assign ( 'helpDefault', 'modify' ) ;
145 if ($this->fromModuleBuilder) {
146 $mb = new ModuleBuilder ( ) ;
147 $module = & $mb->getPackageModule ( $this->editPackage, $this->editModule ) ;
148 $smarty->assign('current_mod_strings', $module->getModStrings());
150 $smarty->assign ( 'title', $this->_constructTitle () ) ;
151 $groups = array ( ) ;
152 foreach ( $parser->columns as $column => $function )
154 // update this so that each field has a properties set
155 // properties are name, value, title (optional)
156 $groups [ $GLOBALS [ 'mod_strings' ] [ $column ] ] = $parser->$function () ; // call the parser functions to populate the list view columns, by default 'default', 'available' and 'hidden'
158 foreach ( $groups as $groupKey => $group )
160 foreach ( $group as $fieldKey => $field )
162 if (isset ( $field [ 'width' ] ))
164 if (substr ( $field [ 'width' ], - 1, 1 ) == '%')
167 $groups [ $groupKey ] [ $fieldKey ] [ 'width' ] = substr ( $field [ 'width' ], 0, strlen ( $field [ 'width' ] ) - 1 ) ;
173 $smarty->assign ( 'groups', $groups ) ;
175 global $image_path, $mod_strings;
176 $imageSave = SugarThemeRegistry::current()->getImage('studio_save','',null,null,'.gif',$mod_strings['LBL_BTN_SAVE']) ;
178 // $imageHelp = SugarThemeRegistry::current()->getImage('help','',null,null,'.gif',$mod_strings['LBL_SECTION_HELP']) ;
181 $histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")" ;
182 if (isset($this->searchlayout))
183 $histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$this->searchlayout}\")" ;
185 $buttons = array ( ) ;
186 if (! $this->fromModuleBuilder)
188 $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\" )'" ) ;
191 $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\" )'" ) ;
193 $buttons [] = array ( 'name' => 'historyBtn' , 'text' => translate ( 'LBL_HISTORY' ) , 'actionScript' => "onclick='$histaction'" ) ;
194 $smarty->assign ( 'buttons', $this->_buildImageButtons ( $buttons ) ) ;
195 $editImage = SugarThemeRegistry::current()->getImage('edit_inline','',null,null,'.gif',$mod_strings['LBL_EDIT']) ;
197 $smarty->assign ( 'editImage', $editImage ) ;
198 $deleteImage = SugarThemeRegistry::current()->getImage('delete_inline','',null,null,'.gif',$mod_strings['LBL_MB_DELETE']) ;
200 $smarty->assign ( 'deleteImage', $deleteImage ) ;
201 $smarty->assign ( 'MOD', $GLOBALS [ 'mod_strings' ] ) ;
203 if ($this->fromModuleBuilder)
205 $smarty->assign ( 'MB', true ) ;
206 $smarty->assign ( 'view_package', $this->editPackage ) ;
207 $smarty->assign ( 'description', $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_DESCRIPTION' ] ) ;
211 $smarty->assign ( 'description', $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_DESCRIPTION' ] ) ;
217 function _constructTitle()
219 global $app_list_strings ;
221 if ($this->fromModuleBuilder)
222 $title = $this->editModule ;
224 $title = $app_list_strings [ 'moduleList' ] [ $this->editModule ] ;
226 return $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_EDIT' ] . ': ' . $title ;