2 /*********************************************************************************
3 * SugarCRM Community Edition is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2013 SugarCRM Inc.
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.
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
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
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.
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.
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 ********************************************************************************/
37 require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
38 require_once ('modules/ModuleBuilder/Module/StudioModuleFactory.php') ;
39 require_once ('include/MVC/View/SugarView.php') ;
41 class ModuleBuilderViewWizard extends SugarView
43 private $view = null ; // the wizard view to display
52 function __construct()
54 if ( isset ( $_REQUEST [ 'view' ] ) )
55 $this->view = $_REQUEST [ 'view' ] ;
57 $this->editModule = (! empty ( $_REQUEST [ 'view_module' ] ) ) ? $_REQUEST [ 'view_module' ] : null ;
58 $this->buttons = array(); // initialize so that modules without subpanels for example don't result in this being unset and causing problems in the smarty->assign
62 * @see SugarView::_getModuleTitleParams()
64 protected function _getModuleTitleParams($browserTitle = false)
69 translate('LBL_MODULE_NAME','Administration'),
70 ModuleBuilderController::getModuleTitle(),
76 $this->ajax = new AjaxCompose ( ) ;
77 $smarty = new Sugar_Smarty ( ) ;
79 if (isset ( $_REQUEST [ 'MB' ] ))
81 $this->processMB ( $this->ajax ) ;
85 $this->processStudio ( $this->ajax ) ;
89 $smarty->assign ( 'buttons', $this->buttons ) ;
90 $smarty->assign ( 'image_path', $GLOBALS [ 'image_path' ] ) ;
91 $smarty->assign ( "title", $this->title ) ;
92 $smarty->assign ( "question", $this->question ) ;
93 $smarty->assign ( "defaultHelp", $this->help ) ;
94 $smarty->assign ( "actions", $this->actions ) ;
96 $this->ajax->addSection ( 'center', $this->title, $smarty->fetch ( 'modules/ModuleBuilder/tpls/wizard.tpl' ) ) ;
97 echo $this->ajax->getJavascript () ;
100 function processStudio(
105 $this->ajax->addCrumb ( translate( 'LBL_STUDIO' ), 'ModuleBuilder.main("studio")' ) ;
107 if (! isset ( $this->editModule ))
109 //Studio Select Module Page
110 $this->generateStudioModuleButtons () ;
111 $this->question = translate('LBL_QUESTION_EDIT') ;
112 $this->title = translate( 'LBL_STUDIO' );
113 global $current_user;
114 if (is_admin($current_user))
115 $this->actions = "<input class=\"button\" type=\"button\" id=\"exportBtn\" name=\"exportBtn\" onclick=\"ModuleBuilder.getContent('module=ModuleBuilder&action=exportcustomizations');\" value=\"" . translate ( 'LBL_BTN_EXPORT' ) . '">' ;
117 $this->help = 'studioHelp' ;
120 $module = StudioModuleFactory::getStudioModule( $this->editModule ) ;
121 $this->ajax->addCrumb ( $module->name, !empty($this->view) ? 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view_module=' . $this->editModule . '")' : '' ) ;
122 switch ( $this->view )
125 //Studio Select Layout page
126 $this->buttons = $module->getLayouts() ;
127 $this->title = $module->name . " " . translate('LBL_LAYOUTS') ;
128 $this->question = translate( 'LBL_QUESTION_LAYOUT' ) ;
129 $this->help = 'layoutsHelp' ;
130 $this->ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), '' ) ;
135 //Studio Select Subpanel page.
136 $this->buttons = $module->getSubpanels() ;
137 $this->title = $module->name . " " . translate( 'LBL_SUBPANELS' ) ;
138 $this->question = translate( 'LBL_QUESTION_SUBPANEL' ) ;
139 $this->ajax->addCrumb ( translate( 'LBL_SUBPANELS' ), '' ) ;
140 $this->help = 'subpanelHelp' ;
144 //Studio Select Search Layout page.
145 $this->buttons = $module->getSearch() ;
146 $this->title = $module->name . " " . translate('LBL_SEARCH');
147 $this->question = translate( 'LBL_QUESTION_SEARCH' ) ;
148 $this->ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=layouts&view_module=' . $this->editModule . '")' ) ;
149 $this->ajax->addCrumb ( translate( 'LBL_SEARCH' ), '' ) ;
150 $this->help = 'searchHelp' ;
154 $this->generateStudioDashletButtons();
155 $this->title = $this->editModule ." " .translate('LBL_DASHLET');
156 $this->question = translate( 'LBL_QUESTION_DASHLET' ) ;
157 $this->ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=layouts&view_module=' . $this->editModule . '")' ) ;
158 $this->ajax->addCrumb ( translate( 'LBL_DASHLET' ), '' ) ;
159 $this->help = 'dashletHelp' ;
163 $this->generateStudioPopupButtons();
164 $this->title = $this->editModule ." " .translate('LBL_POPUP');
165 $this->question = translate( 'LBL_QUESTION_POPUP' ) ;
166 $this->ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=layouts&view_module=' . $this->editModule . '")' ) ;
167 $this->ajax->addCrumb ( translate( 'LBL_POPUP' ), '' ) ;
168 $this->help = 'popupHelp' ;
171 //Studio Edit Module Page
172 $this->buttons = $module->getModule () ;
173 $this->question = translate( 'LBL_QUESTION_MODULE' ) ;
174 $this->title = translate( 'LBL_EDIT' ) . " " . $module->name ;
175 $this->help = 'moduleHelp' ;
176 global $current_user;
177 if (is_admin($current_user))
178 $this->actions = "<input class=\"button\" type=\"button\" id=\"exportBtn\" name=\"exportBtn\" "
179 . "onclick=\"ModuleBuilder.getContent('module=ModuleBuilder&action=resetmodule&view_module=$this->editModule');\" value=\""
180 . translate( 'LBL_RESET_MODULE' ) . '">' ;
189 if (! isset ( $_REQUEST [ 'view_package' ] ))
191 sugar_die ( "no ModuleBuilder package set" ) ;
194 $this->editModule = $_REQUEST [ 'view_module' ] ;
195 $this->package = $_REQUEST [ 'view_package' ] ;
197 $ajax->addCrumb ( translate ( 'LBL_MODULEBUILDER', 'ModuleBuilder' ), 'ModuleBuilder.main("mb")' ) ;
198 $ajax->addCrumb ( $this->package, 'ModuleBuilder.getContent("module=ModuleBuilder&action=package&view_package=' . $this->package . '")' ) ;
199 $ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_module=' . $this->editModule . '&view_package=' . $this->package . '")') ;
201 switch ( $this->view )
204 //MB Select Search Layout page.
205 $this->generateMBSearchButtons () ;
206 $this->title = $this->editModule . " " . translate( 'LBL_SEARCH' ) ;
207 $this->question = translate( 'LBL_QUESTION_SEARCH' ) ;
208 $ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view_module=' . $this->editModule . '&view_package=' . $this->package . '")' ) ;
209 $ajax->addCrumb ( translate( 'LBL_SEARCH_FORMS' ), '' ) ;
210 $this->help = "searchHelp" ;
214 //ModuleBuilder Select Subpanel
215 $ajax->addCrumb ( $this->editModule, 'ModuleBuilder.getContent("module=ModuleBuilder&action=module&view_module=' . $this->editModule . '&view_package=' . $this->package . '")' ) ;
216 $ajax->addCrumb ( translate( 'LBL_SUBPANELS' ), '' ) ;
217 $this->question = translate( 'LBL_QUESTION_SUBPANEL' ) ;
218 $this->help = 'subpanelHelp' ;
222 $this->generateMBDashletButtons ();
223 $this->title = $this->editModule ." " .translate('LBL_DASHLET');
224 $this->question = translate( 'LBL_QUESTION_DASHLET' ) ;
225 $this->ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), 'ModuleBuilder.getContent("module=ModuleBuilder&action=wizard&view=layouts&MB=1&view_package='.$this->package.'&view_module=' . $this->editModule . '")' ) ;
226 $this->ajax->addCrumb ( translate( 'LBL_DASHLET' ), '' ) ;
227 $this->help = 'dashletHelp' ;
232 $this->generateMBPopupButtons();
233 $this->title = $this->editModule ." " .translate('LBL_POPUP');
234 $this->question = translate( 'LBL_QUESTION_POPUP' ) ;
235 $this->ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), 'ModuleBuilder.getContent("module=ModuleBuilder&MB=true&action=wizard&view=layouts&MB=1&view_package='.$this->package.'&view_module=' . $this->editModule . '")' ) ;
236 $this->ajax->addCrumb ( translate( 'LBL_POPUP' ), '' ) ;
237 $this->help = 'popupHelp' ;
240 $ajax->addCrumb ( translate( 'LBL_LAYOUTS' ), '' ) ;
241 $this->generateMBViewButtons () ;
242 $this->title = $this->editModule . " " . translate( 'LBL_LAYOUTS' ) ;
243 $this->question = translate( 'LBL_QUESTION_LAYOUT' ) ;
244 $this->help = "layoutsHelp" ;
249 function generateStudioModuleButtons()
251 require_once ('modules/ModuleBuilder/Module/StudioBrowser.php') ;
252 $sb = new StudioBrowser ( ) ;
253 $sb->loadModules () ;
254 $nodes = $sb->getNodes () ;
255 $this->buttons = array ( ) ;
256 //$GLOBALS['log']->debug(print_r($nodes,true));
257 foreach ( $nodes as $module )
259 $this->buttons [ $module [ 'name' ] ] = array ( 'action' => $module [ 'action' ] , 'imageTitle' => ucfirst ( $module [ 'module' ] . "_32" ) , 'size' => '32', 'linkId' => 'studiolink_'.$module [ 'module' ] ) ;
265 function generateMBViewButtons()
267 $this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_EDITVIEW' ] ] =
269 'action' => "module=ModuleBuilder&MB=true&action=editLayout&view=".MB_EDITVIEW."&view_module={$this->editModule}&view_package={$this->package}" ,
270 'imageTitle' => 'EditView',
271 'help'=>'viewBtnEditView'
273 $this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_DETAILVIEW' ] ] =
275 'action' => "module=ModuleBuilder&MB=true&action=editLayout&view=".MB_DETAILVIEW."&view_module={$this->editModule}&view_package={$this->package}" ,
276 'imageTitle' => 'DetailView',
277 'help'=>'viewBtnListView'
279 $this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW' ] ] =
281 'action' => "module=ModuleBuilder&MB=true&action=editLayout&view=".MB_LISTVIEW."&view_module={$this->editModule}&view_package={$this->package}" ,
282 'imageTitle' => 'ListView',
283 'help'=>'viewBtnListView'
285 $this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_QUICKCREATE' ] ] =
287 'action' => "module=ModuleBuilder&MB=true&action=editLayout&view=".MB_QUICKCREATE."&view_module={$this->editModule}&view_package={$this->package}" ,
288 'imageTitle' => 'QuickCreate',
289 'help'=>'viewBtnQuickCreate'
291 $this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_SEARCH' ] ] =
293 'action' => "module=ModuleBuilder&MB=true&action=wizard&view=search&view_module={$this->editModule}&view_package={$this->package}" ,
294 'imageTitle' => 'SearchForm' ,
297 $this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_DASHLET' ] ] =
299 'action' => "module=ModuleBuilder&MB=true&action=wizard&view=dashlet&view_module={$this->editModule}&view_package={$this->package}" ,
300 'imageTitle' => 'Dashlet',
301 'help'=>'viewBtnDashlet'
303 $this->buttons [ $GLOBALS [ 'mod_strings' ] ['LBL_POPUP'] ] =
305 'imageTitle' => 'Popup',
306 'action' => "module=ModuleBuilder&MB=true&action=wizard&view=popup&view_module={$this->editModule}&view_package={$this->package}",
307 'help'=>'PopupListViewBtn'
311 function generateMBDashletButtons()
313 $this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_DASHLETLISTVIEW' ] ] = array('action'=> "module=ModuleBuilder&MB=true&action=editLayout&view=dashlet&view_module={$this->editModule}&view_package={$this->package}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_DASHLETLISTVIEW'], 'imageName'=>'ListView', 'help'=>'DashletListViewBtn');
314 $this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_DASHLETSEARCHVIEW' ] ] = array('action'=> "module=ModuleBuilder&MB=true&action=editLayout&view=dashletsearch&view_module={$this->editModule}&view_package={$this->package}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_DASHLETSEARCHVIEW'], 'imageName'=>'BasicSearch','help'=> 'DashletSearchViewBtn');
317 function generateMBPopupButtons()
319 $this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_POPUPLISTVIEW' ] ] = array('action'=> "module=ModuleBuilder&action=editLayout&view=popuplist&view_module={$this->editModule}&view_package={$this->package}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_POPUPLISTVIEW'], 'imageName'=>'ListView', 'help'=>'PopupListViewBtn');
320 $this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_POPUPSEARCH' ] ] = array('action'=> "module=ModuleBuilder&action=editLayout&view=popupsearch&view_module={$this->editModule}&view_package={$this->package}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_POPUPSEARCH'], 'imageName'=>'BasicSearch','help'=> 'PopupSearchViewBtn');
323 function generateStudioDashletButtons()
325 $this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_DASHLETLISTVIEW' ] ] = array('action'=> "module=ModuleBuilder&action=editLayout&view=dashlet&view_module={$this->editModule}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_DASHLETLISTVIEW'], 'imageName'=>'ListView', 'help'=>'DashletListViewBtn');
326 $this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_DASHLETSEARCHVIEW' ] ] = array('action'=> "module=ModuleBuilder&action=editLayout&view=dashletsearch&view_module={$this->editModule}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_DASHLETSEARCHVIEW'], 'imageName'=>'BasicSearch','help'=> 'DashletSearchViewBtn');
329 function generateStudioPopupButtons()
331 $this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_POPUPLISTVIEW' ] ] = array('action'=> "module=ModuleBuilder&action=editLayout&view=popuplist&view_module={$this->editModule}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_POPUPLISTVIEW'], 'imageName'=>'ListView', 'help'=>'PopupListViewBtn');
332 $this->buttons [ $GLOBALS [ 'mod_strings' ][ 'LBL_POPUPSEARCH' ] ] = array('action'=> "module=ModuleBuilder&action=editLayout&view=popupsearch&view_module={$this->editModule}", 'imageTitle'=> $GLOBALS ['mod_strings']['LBL_POPUPSEARCH'], 'imageName'=>'BasicSearch','help'=> 'PopupSearchViewBtn');
335 function generateMBSearchButtons()
337 $this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_BASIC' ] ] = array ( 'action' => "module=ModuleBuilder&MB=true&action=editLayout&view_module={$this->editModule}&view_package={$this->package}&view=SearchView&searchlayout=basic_search" , 'imageTitle' => $GLOBALS [ 'mod_strings' ] [ 'LBL_BASIC_SEARCH' ] , 'imageName' => 'BasicSearch','help' => "BasicSearchBtn" ) ;
338 $this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_ADVANCED' ] ] = array ( 'action' => "module=ModuleBuilder&MB=true&action=editLayout&view_module={$this->editModule}&view_package={$this->package}&view=SearchView&searchlayout=advanced_search" , 'imageTitle' => $GLOBALS [ 'mod_strings' ] [ 'LBL_ADVANCED_SEARCH' ] , 'imageName' => 'AdvancedSearch','help' => "AdvancedSearchBtn" ) ;