]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/ModuleBuilder/views/view.popupview.php
Release 6.5.0
[Github/sugarcrm.git] / modules / ModuleBuilder / views / view.popupview.php
1 <?php
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-2012 SugarCRM Inc.
7  * 
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.
14  * 
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
18  * details.
19  * 
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
23  * 02110-1301 USA.
24  * 
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.
27  * 
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.
31  * 
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  ********************************************************************************/
38
39
40
41 require_once ('modules/ModuleBuilder/views/view.listview.php') ;
42 require_once 'modules/ModuleBuilder/parsers/constants.php' ;
43
44 class ViewPopupview extends ViewListView
45 {
46     function __construct()
47     {
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 ;
51
52         $this->fromModuleBuilder = isset ( $_REQUEST [ 'MB' ] ) || (isset($_REQUEST['view_package']) && $_REQUEST['view_package'] && $_REQUEST['view_package'] != 'studio') ;
53         if (!$this->fromModuleBuilder)
54         {
55             global $app_list_strings ;
56             $moduleNames = array_change_key_case ( $app_list_strings [ 'moduleList' ] ) ;
57             $this->translatedEditModule = $moduleNames [ strtolower ( $this->editModule ) ] ;
58         }
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     /*
75      * Pseudo-constructor to enable subclasses to call a parent's constructor without knowing the parent in PHP4
76      */
77     function init()
78     {
79
80     }
81
82     function preDisplay()
83     {
84     }
85
86     function display(
87         $preview = false
88         )
89     {
90         require_once 'modules/ModuleBuilder/parsers/ParserFactory.php' ;
91         $parser = ParserFactory::getParser ( $this->editLayout, $this->editModule, $this->editPackage) ;
92
93         $smarty = $this->constructSmarty ( $parser ) ;
94         if ($preview)
95         {
96                 echo $smarty->fetch ( "modules/ModuleBuilder/tpls/Preview/listView.tpl" ) ;
97         } else
98         {
99                 $ajax = $this->constructAjax () ;
100                 $ajax->addSection ( 'center', translate('LBL_POPUP'), $smarty->fetch ( "modules/ModuleBuilder/tpls/listView.tpl" ) ) ;
101                 echo $ajax->getJavascript () ;
102         }
103     }
104
105     function constructAjax()
106     {
107         require_once ('modules/ModuleBuilder/MB/AjaxCompose.php') ;
108         $ajax = new AjaxCompose ( ) ;
109
110         if ($this->fromModuleBuilder)
111         {
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 . '")' );
117
118             $ViewLabel = ($this->editLayout == MB_POPUPLIST) ? 'LBL_POPUPLISTVIEW' : 'LBL_POPUPSEARCH';
119             $ajax->addCrumb ( translate ($ViewLabel, 'ModuleBuilder' ), '' ) ;
120         }else{
121             $ajax->addCrumb ( translate($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' ), '' ) ;
126         }
127         return $ajax ;
128     }
129
130     function constructSmarty(
131         $parser
132         )
133     {
134         $smarty = new Sugar_Smarty ( ) ;
135         $smarty->assign ( 'translate', true ) ;
136         $smarty->assign ( 'language', $parser->getLanguage () ) ;
137
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());
150                 }
151
152         $smarty->assign ( 'title', $this->_constructTitle () ) ;
153         $groups = array ( ) ;
154         foreach ( $parser->columns as $column => $function )
155         {
156             $groups [ $GLOBALS [ 'mod_strings' ] [ $column ] ] = $parser->$function () ; 
157         }
158         foreach ( $groups as $groupKey => $group )
159         {
160             foreach ( $group as $fieldKey => $field )
161             {
162                 if (isset ( $field [ 'width' ] ))
163                 {
164                     if (substr ( $field [ 'width' ], - 1, 1 ) == '%')
165                     {
166                                                 $groups [ $groupKey ] [ $fieldKey ] [ 'width' ] = substr ( $field [ 'width' ], 0, strlen ( $field [ 'width' ] ) - 1 ) ;
167                     }
168                 }
169             }
170         }
171
172         $smarty->assign ( 'groups', $groups ) ;
173
174         global $image_path, $mod_strings;
175         $imageSave = SugarThemeRegistry::current()->getImage('studio_save','',null,null,'.gif',$mod_strings['LBL_BTN_SAVE']) ;
176
177
178         $histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\")" ;
179         if (isset($this->searchlayout))
180             $histaction = "ModuleBuilder.history.browse(\"{$this->editModule}\", \"{$this->editLayout}\", \"{$this->searchlayout}\")" ;
181
182         $buttons = array ( ) ;
183         if (! $this->fromModuleBuilder)
184         {
185             $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\" )'" ) ;
186         } else
187         {
188             $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         }
190         $buttons [] = array ( 'name' => 'historyBtn' , 'text' => translate ( 'LBL_HISTORY' ) , 'actionScript' => "onclick='$histaction'" ) ;
191         $smarty->assign ( 'buttons', $this->_buildImageButtons ( $buttons ) ) ;
192         $editImage = SugarThemeRegistry::current()->getImage('edit_inline','',null,null,'.gif',$mod_strings['LBL_EDIT']) ;
193
194         $smarty->assign ( 'editImage', $editImage ) ;
195         $deleteImage = SugarThemeRegistry::current()->getImage('delete_inline','',null,null,'.gif',$mod_strings['LBL_MB_DELETE']) ;
196
197         $smarty->assign ( 'deleteImage', $deleteImage ) ;
198         $smarty->assign ( 'MOD', $GLOBALS [ 'mod_strings' ] ) ;
199
200         if ($this->fromModuleBuilder)
201         {
202             $smarty->assign ( 'MB', true ) ;
203             $smarty->assign ( 'view_package', $this->editPackage ) ;
204             $smarty->assign ( 'description', $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_DESCRIPTION' ] ) ;
205
206         } else
207         {
208             $smarty->assign ( 'description', $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_DESCRIPTION' ] ) ;
209         }
210
211         return $smarty ;
212     }
213
214     function _constructTitle()
215     {
216
217         global $app_list_strings ;
218
219         if ($this->fromModuleBuilder)
220         {
221             $title = $this->editModule ;
222         } else
223         {
224             $title =  $app_list_strings [ 'moduleList' ] [ $this->editModule ] ;
225         }
226         return $GLOBALS [ 'mod_strings' ] [ 'LBL_LISTVIEW_EDIT' ] . ':&nbsp;' . $title ;
227
228     }
229 }