]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/ModuleBuilder/views/view.package.php
Release 6.1.4
[Github/sugarcrm.git] / modules / ModuleBuilder / views / view.package.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM is a customer relationship management program developed by
4  * SugarCRM, Inc. Copyright (C) 2004-2011 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/MB/ModuleBuilder.php');
39 class Viewpackage extends SugarView
40 {
41         /**
42          * @see SugarView::_getModuleTitleParams()
43          */
44         protected function _getModuleTitleParams()
45         {
46             global $mod_strings;
47             
48         return array(
49            translate('LBL_MODULE_NAME','Administration'),
50            $mod_strings['LBL_MODULEBUILDER'],
51            );
52     }
53
54         function display()
55         {
56                 global $mod_strings;
57                 $smarty = new Sugar_Smarty();
58                 $mb = new ModuleBuilder();
59                 //if (!empty($_REQUEST['package'])) {
60                 if (empty($_REQUEST['package']) && empty($_REQUEST['new'])) {
61                         $this->generatePackageButtons($mb->getPackageList());
62
63                         $smarty->assign('buttons', $this->buttons);
64                         $smarty->assign('title', $GLOBALS['mod_strings']['LBL_MODULEBUILDER']);
65                         $smarty->assign("question", $GLOBALS['mod_strings']['LBL_QUESTION_PACKAGE']);
66                         $smarty->assign("defaultHelp", "mbHelp");
67
68                         $ajax = new AjaxCompose();
69                         $ajax->addCrumb($GLOBALS['mod_strings']['LBL_MODULEBUILDER'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package")');
70                         $ajax->addCrumb($GLOBALS['mod_strings']['LBL_PACKAGE_LIST'],'');
71                         $ajax->addSection('center', $GLOBALS['mod_strings']['LBL_PACKAGE_LIST'], $smarty->fetch('modules/ModuleBuilder/tpls/wizard.tpl'));
72                         echo $ajax->getJavascript();
73                 }
74                 else {
75                         $name = (!empty($_REQUEST['package']))?$_REQUEST['package']:'';
76                         $mb->getPackage($name);
77                         $this->package =& $mb->packages[$name];
78                         $this->loadModuleTypes();
79                         $this->loadPackageHelp($name);
80                         $this->package->date_modified = $GLOBALS['timedate']->to_display_date_time($this->package->date_modified);
81                         $smarty->assign('package', $this->package);
82                         $smarty->assign('mod_strings',$mod_strings);
83                         $smarty->assign('package_already_deployed', 'false');
84             foreach($this->package->modules as $a_module){
85                 if(in_array($a_module->key_name, $GLOBALS['moduleList'])){
86                                 $smarty->assign('package_already_deployed', 'true');
87                     break;
88                 }
89             }
90
91                         $ajax = new AjaxCompose();
92                         $ajax->addCrumb($GLOBALS['mod_strings']['LBL_MODULEBUILDER'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package")');
93                         if(empty($name))$name = $mod_strings['LBL_NEW_PACKAGE'];
94                         $ajax->addCrumb($name,'');
95                         $html=$smarty->fetch('modules/ModuleBuilder/tpls/MBPackage/package.tpl');
96                         if(!empty($_REQUEST['action']) && $_REQUEST['action']=='SavePackage')
97                                 $html.="<script>ModuleBuilder.treeRefresh('ModuleBuilder')</script>";
98                         $ajax->addSection('center', translate('LBL_SECTION_PACKAGE', 'ModuleBuilder'), $html);
99                         echo $ajax->getJavascript();
100                 }
101         }
102
103         function loadModuleTypes()
104         {
105                 $this->package->moduleTypes = array();
106                 $this->package->loadModules();
107                 foreach(array_keys($this->package->modules) as $name){
108                         foreach($this->package->modules[$name]->config['templates'] as $template=>$var){
109
110                                         $this->package->moduleTypes[$name] = $template;
111
112                         }
113                 }
114         }
115         function loadPackageHelp(
116             $name
117             )
118         {
119                         $this->package->help['default'] = (empty($name))?'create':'modify';
120                         $this->package->help['group'] = 'package';
121         }
122
123         function generatePackageButtons(
124             $packages
125             )
126         {
127                 global $mod_strings;
128                 $this->buttons[$mod_strings['LBL_NEW_PACKAGE']] = array(
129                                                                                 'action' => "module=ModuleBuilder&action=package&new=1",
130                                                                                 'imageTitle' => 'package_create',
131                                                                                 'size' => '64',
132                                                                                 'help' => 'newPackage',
133                                                                                 );
134                 foreach($packages as $package) {
135                         $this->buttons[$package] = array(
136                                                                                 'action' =>"module=ModuleBuilder&action=package&package={$package}",
137                                                                                 'imageTitle' => 'package',
138                                                                                 'size' => '64',
139                                                                                 );
140                 }
141         }
142 }