]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - include/DetailView/DetailView2.php
Release 6.2.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 class DetailView2 extends EditView 
41 {
42     var $view = 'DetailView';
43     
44     /**
45      * DetailView constructor
46      * This is the DetailView constructor responsible for processing the new
47      * Meta-Data framework
48      *    
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
54      * 
55      */ 
56     function setup(
57         $module, 
58         $focus, 
59         $metadataFile = null, 
60         $tpl = 'include/DetailView/DetailView.tpl'
61         ) 
62     {      
63         $this->th = new TemplateHandler();
64         $this->th->ss =& $this->ss;
65         $this->focus = $focus;
66         $this->tpl = $tpl;  
67         $this->module = $module;
68         $this->metadataFile = $metadataFile;
69         if(isset($GLOBALS['sugar_config']['disable_vcr'])) {
70            $this->showVCRControl = !$GLOBALS['sugar_config']['disable_vcr'];    
71         }
72         if(!empty($this->metadataFile) && file_exists($this->metadataFile)){
73                 require_once($this->metadataFile);
74         }else {
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")) {   
78                 global $dictionary;
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');       
83                     }
84                         $fp = sugar_fopen('modules/'.$this->module.'/metadata/detailviewdefs.php', 'w');
85                     fwrite($fp, $parser->parse($htmlFile, $dictionary[$focus->object_name]['fields'], $this->module));
86                     fclose($fp);
87                 }
88                 
89                 //Flag an error... we couldn't create the best guess meta-data file
90                 if(!file_exists("modules/$this->module/metadata/detailviewdefs.php")) {
91                    global $app_strings;
92                    $error = str_replace("[file]", "modules/$this->module/metadata/detailviewdefs.php", $app_strings['ERR_CANNOT_CREATE_METADATA_FILE']);
93                    $GLOBALS['log']->fatal($error);
94                    echo $error;
95                    die();       
96                 }
97             require_once("modules/$this->module/metadata/detailviewdefs.php");
98         }
99    
100         $this->defs = $viewdefs[$this->module][$this->view];
101     }
102         
103 }
104 ?>