2 /*********************************************************************************
3 * SugarCRM is a customer relationship management program developed by
4 * SugarCRM, Inc. Copyright (C) 2004-2011 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('include/TemplateHandler/TemplateHandler.php');
38 require_once('include/EditView/EditView2.php');
40 class DetailView2 extends EditView
42 var $view = 'DetailView';
45 * DetailView constructor
46 * This is the DetailView constructor responsible for processing the new
49 * @param $module String value of module this detail view is for
50 * @param $focus An empty sugarbean object of module
51 * @param $id The record id to retrieve and populate data for
52 * @param $metadataFile String value of file location to use in overriding default metadata file
53 * @param tpl String value of file location to use in overriding default Smarty template
60 $tpl = 'include/DetailView/DetailView.tpl'
63 $this->th = new TemplateHandler();
64 $this->th->ss =& $this->ss;
65 $this->focus = $focus;
67 $this->module = $module;
68 $this->metadataFile = $metadataFile;
69 if(isset($GLOBALS['sugar_config']['disable_vcr'])) {
70 $this->showVCRControl = !$GLOBALS['sugar_config']['disable_vcr'];
72 if(!empty($this->metadataFile) && file_exists($this->metadataFile)){
73 require_once($this->metadataFile);
75 //If file doesn't exist we create a best guess
76 if(!file_exists("modules/$this->module/metadata/detailviewdefs.php") &&
77 file_exists("modules/$this->module/DetailView.html")) {
79 $htmlFile = "modules/" . $this->module . "/DetailView.html";
80 $parser = new DetailViewMetaParser();
81 if(!file_exists('modules/'.$this->module.'/metadata')) {
82 sugar_mkdir('modules/'.$this->module.'/metadata');
84 $fp = sugar_fopen('modules/'.$this->module.'/metadata/detailviewdefs.php', 'w');
85 fwrite($fp, $parser->parse($htmlFile, $dictionary[$focus->object_name]['fields'], $this->module));
89 //Flag an error... we couldn't create the best guess meta-data file
90 if(!file_exists("modules/$this->module/metadata/detailviewdefs.php")) {
92 $error = str_replace("[file]", "modules/$this->module/metadata/detailviewdefs.php", $app_strings['ERR_CANNOT_CREATE_METADATA_FILE']);
93 $GLOBALS['log']->fatal($error);
97 require_once("modules/$this->module/metadata/detailviewdefs.php");
100 $this->defs = $viewdefs[$this->module][$this->view];