]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/DetailView/DetailView2.php
Release 6.4.0
[Github/sugarcrm.git] / include / DetailView / DetailView2.php
1 <?php
2 /*********************************************************************************
3  * SugarCRM Community Edition 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('include/TemplateHandler/TemplateHandler.php');
38 require_once('include/EditView/EditView2.php');
39
40 /**
41  * DetailView - display single record
42  * New implementation
43  * @api
44  */
45 class DetailView2 extends EditView
46 {
47     var $view = 'DetailView';
48
49     /**
50      * DetailView constructor
51      * This is the DetailView constructor responsible for processing the new
52      * Meta-Data framework
53      *
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
59      */
60     function setup(
61         $module,
62         $focus,
63         $metadataFile = null,
64         $tpl = 'include/DetailView/DetailView.tpl'
65         )
66     {
67         $this->th = new TemplateHandler();
68         $this->th->ss =& $this->ss;
69         $this->focus = $focus;
70         $this->tpl = $tpl;
71         $this->module = $module;
72         $this->metadataFile = $metadataFile;
73         if(isset($GLOBALS['sugar_config']['disable_vcr'])) {
74            $this->showVCRControl = !$GLOBALS['sugar_config']['disable_vcr'];
75         }
76         if(!empty($this->metadataFile) && file_exists($this->metadataFile)){
77                 require_once($this->metadataFile);
78         }else {
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")) {
82                 global $dictionary;
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');
87                     }
88                         $fp = sugar_fopen('modules/'.$this->module.'/metadata/detailviewdefs.php', 'w');
89                     fwrite($fp, $parser->parse($htmlFile, $dictionary[$focus->object_name]['fields'], $this->module));
90                     fclose($fp);
91                 }
92
93                 //Flag an error... we couldn't create the best guess meta-data file
94                 if(!file_exists("modules/$this->module/metadata/detailviewdefs.php")) {
95                    global $app_strings;
96                    $error = str_replace("[file]", "modules/$this->module/metadata/detailviewdefs.php", $app_strings['ERR_CANNOT_CREATE_METADATA_FILE']);
97                    $GLOBALS['log']->fatal($error);
98                    echo $error;
99                    die();
100                 }
101             require_once("modules/$this->module/metadata/detailviewdefs.php");
102         }
103
104         $this->defs = $viewdefs[$this->module][$this->view];
105     }
106
107 }
108 ?>