2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM Community Edition is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2012 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
38 require_once('include/MVC/View/SugarView.php');
41 class ImportView extends SugarView
43 protected $currentStep;
44 protected $pageTitleKey;
45 protected $instruction;
47 public function __construct($bean = null, $view_object_map = array())
51 parent::__construct($bean, $view_object_map);
53 if (isset($_REQUEST['button']) && trim($_REQUEST['button']) == htmlentities($mod_strings['LBL_BACK'])) {
54 // if the request comes from the "Back" button, decrease the step count
55 $this->currentStep = isset($_REQUEST['current_step']) ? ($_REQUEST['current_step'] - 1) : 1;
57 $this->currentStep = isset($_REQUEST['current_step']) ? ($_REQUEST['current_step'] + 1) : 1;
59 $this->importModule = isset($_REQUEST['import_module']) ? $_REQUEST['import_module'] : '';
64 * @see SugarView::getMenu()
66 public function getMenu($module = null)
68 global $mod_strings, $current_language;
71 $module = $this->importModule;
73 $old_mod_strings = $mod_strings;
74 $mod_strings = return_module_language($current_language, $module);
75 $returnMenu = parent::getMenu($module);
76 $mod_strings = $old_mod_strings;
82 * @see SugarView::_getModuleTab()
84 protected function _getModuleTab()
86 global $app_list_strings, $moduleTabMap;
88 // Need to figure out what tab this module belongs to, most modules have their own tabs, but there are exceptions.
89 if ( !empty($_REQUEST['module_tab']) )
90 return $_REQUEST['module_tab'];
91 elseif ( isset($moduleTabMap[$this->importModule]) )
92 return $moduleTabMap[$this->importModule];
93 // Default anonymous pages to be under Home
94 elseif ( !isset($app_list_strings['moduleList'][$this->importModule]) )
97 return $this->importModule;
101 * Send our output to the importer controller.
103 * @param string $html
104 * @param string $submitContent
105 * @param string $script
106 * @param bool $encode
109 protected function sendJsonOutput($html = "", $submitContent = "", $script = "", $encode = FALSE)
111 $title = $this->getModuleTitle(false);
114 'submitContent' => $submitContent,
116 'script' => $script);
119 array_walk($out, create_function('&$val', '$val = htmlspecialchars($val,ENT_NOQUOTES);'));
121 echo json_encode($out);
125 * @see SugarView::_getModuleTitleParams()
127 protected function _getModuleTitleParams($browserTitle = false)
129 global $mod_strings, $app_list_strings;
130 $returnArray = array(string_format($mod_strings[$this->pageTitleKey], array($this->currentStep)));
135 protected function getInstruction()
141 if ($this->instruction) {
142 $ins_string = $mod_strings[$this->instruction];
143 $ins = '<div class="import_instruction">' . $ins_string . '</div>';
150 * Displays the Smarty template for an error
152 * @param string $message error message to show
153 * @param string $module what module we were importing into
154 * @param string $action what page we should go back to
156 protected function _showImportError($message,$module,$action = 'Step1')
158 $ss = new Sugar_Smarty();
160 $ss->assign("MESSAGE",$message);
161 $ss->assign("ACTION",$action);
162 $ss->assign("IMPORT_MODULE",$module);
163 $ss->assign("MOD", $GLOBALS['mod_strings']);
164 $ss->assign("SOURCE","");
165 if ( isset($_REQUEST['source']) )
166 $ss->assign("SOURCE", $_REQUEST['source']);
168 echo $ss->fetch('modules/Import/tpls/error.tpl');