2 /*********************************************************************************
3 * SugarCRM Community Edition 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');
41 * DetailView - display single record
45 class DetailView2 extends EditView
47 var $view = 'DetailView';
50 * DetailView constructor
51 * This is the DetailView constructor responsible for processing the new
54 * @param $module String value of module this detail view is for
55 * @param $focus An empty sugarbean object of module
56 * @param $id The record id to retrieve and populate data for
57 * @param $metadataFile String value of file location to use in overriding default metadata file
58 * @param tpl String value of file location to use in overriding default Smarty template
64 $tpl = 'include/DetailView/DetailView.tpl'
67 $this->th = new TemplateHandler();
68 $this->th->ss =& $this->ss;
69 $this->focus = $focus;
71 $this->module = $module;
72 $this->metadataFile = $metadataFile;
73 if(isset($GLOBALS['sugar_config']['disable_vcr'])) {
74 $this->showVCRControl = !$GLOBALS['sugar_config']['disable_vcr'];
76 if(!empty($this->metadataFile) && file_exists($this->metadataFile)){
77 require_once($this->metadataFile);
79 //If file doesn't exist we create a best guess
80 if(!file_exists("modules/$this->module/metadata/detailviewdefs.php") &&
81 file_exists("modules/$this->module/DetailView.html")) {
83 $htmlFile = "modules/" . $this->module . "/DetailView.html";
84 $parser = new DetailViewMetaParser();
85 if(!file_exists('modules/'.$this->module.'/metadata')) {
86 sugar_mkdir('modules/'.$this->module.'/metadata');
88 $fp = sugar_fopen('modules/'.$this->module.'/metadata/detailviewdefs.php', 'w');
89 fwrite($fp, $parser->parse($htmlFile, $dictionary[$focus->object_name]['fields'], $this->module));
93 //Flag an error... we couldn't create the best guess meta-data file
94 if(!file_exists("modules/$this->module/metadata/detailviewdefs.php")) {
96 $error = str_replace("[file]", "modules/$this->module/metadata/detailviewdefs.php", $app_strings['ERR_CANNOT_CREATE_METADATA_FILE']);
97 $GLOBALS['log']->fatal($error);
101 require_once("modules/$this->module/metadata/detailviewdefs.php");
104 $this->defs = $viewdefs[$this->module][$this->view];