]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/ModuleBuilder/views/view.wizard.php
Release 6.5.0
[Github/sugarcrm.git] / modules / ModuleBuilder / views / view.wizard.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
5  * 
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.
12  * 
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
16  * details.
17  * 
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
21  * 02110-1301 USA.
22  * 
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.
25  * 
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.
29  * 
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  ********************************************************************************/
36
37 require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
38 require_once ('modules/ModuleBuilder/Module/StudioModuleFactory.php') ;
39 require_once ('include/MVC/View/SugarView.php') ;
40
41 class ModuleBuilderViewWizard extends SugarView
42 {
43         private $view = null ; // the wizard view to display
44         private $actions ;
45         private $buttons ;
46         private $question ;
47         private $title ;
48         private $help ;
49
50         private $editModule ;
51
52         function __construct()
53         {
54                 if ( isset ( $_REQUEST [ 'view' ] ) )
55                         $this->view = $_REQUEST [ 'view' ] ;
56
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
59         }
60         
61         /**
62          * @see SugarView::_getModuleTitleParams()
63          */
64         protected function _getModuleTitleParams($browserTitle = false)
65         {
66             global $mod_strings;
67             
68         return array(
69            translate('LBL_MODULE_NAME','Administration'),
70            ModuleBuilderController::getModuleTitle(),
71            );
72     }
73
74         function display()
75         {
76                 $this->ajax = new AjaxCompose ( ) ;
77                 $smarty = new Sugar_Smarty ( ) ;
78
79                 if (isset ( $_REQUEST [ 'MB' ] ))
80                 {
81                         $this->processMB ( $this->ajax ) ;
82                 } else
83                 {
84
85                                 $this->processStudio ( $this->ajax ) ;
86
87                 }
88
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 ) ;
95
96                 $this->ajax->addSection ( 'center', $this->title, $smarty->fetch ( 'modules/ModuleBuilder/tpls/wizard.tpl' ) ) ;
97                 echo $this->ajax->getJavascript () ;
98         }
99
100         function processStudio( 
101             $ajax
102             )
103         {
104
105                 $this->ajax->addCrumb ( translate( 'LBL_STUDIO' ), 'ModuleBuilder.main("studio")' ) ;
106
107                 if (! isset ( $this->editModule ))
108                 {
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' ) . '">' ;
116
117                         $this->help = 'studioHelp' ;
118                 } else
119                 {
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 )
123                         {
124                                 case 'layouts':
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' ), '' ) ;
131                                         break;
132
133
134                                 case 'subpanels':
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' ;
141                                         break;
142
143                                 case 'search':
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' ;
151                                         break;
152
153                                 case 'dashlet':
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' ;
160                                         break;
161                                 
162                                 case 'popup':
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' ;
169                                         break;
170                                 default:
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' ) . '">' ;
181                         }
182                 }
183         }
184
185         function processMB ( 
186             $ajax 
187             )
188         {
189                 if (! isset ( $_REQUEST [ 'view_package' ] ))
190                 {
191                         sugar_die ( "no ModuleBuilder package set" ) ;
192                 }
193
194                 $this->editModule = $_REQUEST [ 'view_module' ] ;
195                 $this->package = $_REQUEST [ 'view_package' ] ;
196
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 . '")') ;
200
201                 switch ( $this->view )
202                 {
203                         case 'search':
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" ;
211                                 break;
212
213                         case 'subpanel':
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' ;
219                                 break;
220
221                         case 'dashlet':
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' ;
228                                 break;
229
230
231                         case 'popup':
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' ;
238                                 break;
239                         default:
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" ;
245                 }
246         }
247
248
249         function generateStudioModuleButtons()
250         {
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 )
258                 {
259                         $this->buttons [ $module [ 'name' ] ] = array ( 'action' => $module [ 'action' ] , 'imageTitle' => ucfirst ( $module [ 'module' ] . "_32" ) , 'size' => '32', 'linkId' => 'studiolink_'.$module [ 'module' ] ) ;
260                 }
261         }
262
263
264
265         function generateMBViewButtons()
266         {
267                 $this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_EDITVIEW' ] ] = 
268                   array ( 
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'
272                   ) ;
273                 $this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_DETAILVIEW' ] ] = 
274                   array ( 
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'  
278                   ) ;
279                 $this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW' ] ] = 
280                   array ( 
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' 
284                   ) ;
285                   $this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_QUICKCREATE' ] ] = 
286                   array ( 
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' 
290                   ) ;
291                 $this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_SEARCH' ] ] = 
292                   array (
293                       'action' => "module=ModuleBuilder&MB=true&action=wizard&view=search&view_module={$this->editModule}&view_package={$this->package}" , 
294                       'imageTitle' => 'SearchForm' , 
295                       'help'=> 'searchBtn' 
296                   ) ;
297                 $this->buttons [ $GLOBALS [ 'mod_strings' ] [ 'LBL_DASHLET' ] ] = 
298                   array ( 
299                       'action' => "module=ModuleBuilder&MB=true&action=wizard&view=dashlet&view_module={$this->editModule}&view_package={$this->package}" , 
300                       'imageTitle' => 'Dashlet', 
301                       'help'=>'viewBtnDashlet' 
302                   ) ;
303                 $this->buttons [ $GLOBALS [ 'mod_strings' ] ['LBL_POPUP'] ] = 
304                 array ( 
305                         'imageTitle' => 'Popup',  
306                         'action' => "module=ModuleBuilder&MB=true&action=wizard&view=popup&view_module={$this->editModule}&view_package={$this->package}", 
307                         'help'=>'PopupListViewBtn'
308                 );  
309         }
310
311         function generateMBDashletButtons() 
312         {
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');
315         }
316         
317         function generateMBPopupButtons() 
318         {
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');
321         }
322         
323         function generateStudioDashletButtons() 
324         {
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');
327         }
328         
329         function generateStudioPopupButtons()
330         {
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');
333         }
334         
335         function generateMBSearchButtons()
336         {
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" ) ;
339         }
340 }