]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/ModuleBuilder/parsers/ParserFactory.php
Release 6.1.4
[Github/sugarcrm.git] / modules / ModuleBuilder / parsers / ParserFactory.php
1 <?php
2 if (! defined ( 'sugarEntry' ) || ! sugarEntry)
3     die ( 'Not A Valid Entry Point' ) ;
4
5 /*********************************************************************************
6  * SugarCRM is a customer relationship management program developed by
7  * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
8  * 
9  * This program is free software; you can redistribute it and/or modify it under
10  * the terms of the GNU Affero General Public License version 3 as published by the
11  * Free Software Foundation with the addition of the following permission added
12  * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
13  * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
14  * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
15  * 
16  * This program is distributed in the hope that it will be useful, but WITHOUT
17  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18  * FOR A PARTICULAR PURPOSE.  See the GNU Affero General Public License for more
19  * details.
20  * 
21  * You should have received a copy of the GNU Affero General Public License along with
22  * this program; if not, see http://www.gnu.org/licenses or write to the Free
23  * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24  * 02110-1301 USA.
25  * 
26  * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
27  * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
28  * 
29  * The interactive user interfaces in modified source and object code versions
30  * of this program must display Appropriate Legal Notices, as required under
31  * Section 5 of the GNU Affero General Public License version 3.
32  * 
33  * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
34  * these Appropriate Legal Notices must retain the display of the "Powered by
35  * SugarCRM" logo. If the display of the logo is not reasonably feasible for
36  * technical reasons, the Appropriate Legal Notices must display the words
37  * "Powered by SugarCRM".
38  ********************************************************************************/
39
40
41 require_once 'modules/ModuleBuilder/parsers/constants.php' ;
42
43 class ParserFactory
44 {
45
46     /*
47      * Create a new parser
48      *
49      * @param string $view          The view, for example EditView or ListView. For search views, use advanced_search or basic_search
50      * @param string $moduleName    Module name
51      * @param string $packageName   Package name. If present implies that we are being called from ModuleBuilder
52      * @return AbstractMetaDataParser
53      */
54
55     function getParser ( $view , $moduleName , $packageName = null , $subpanelName = null )
56     {
57         $GLOBALS [ 'log' ]->info ( "ParserFactory->getParser($view,$moduleName,$packageName,$subpanelName )" ) ;
58                 if ( empty ( $packageName ) || ( $packageName == 'studio' ) )
59                         $packageName = null ;
60         switch ( strtolower ( $view ))
61         {
62             case MB_EDITVIEW :
63             case MB_DETAILVIEW :
64             case MB_QUICKCREATE :
65                 require_once 'modules/ModuleBuilder/parsers/views/GridLayoutMetaDataParser.php' ;
66                 return new GridLayoutMetaDataParser ( $view, $moduleName, $packageName ) ;
67             case MB_CONVERTLEAD :
68                 require_once 'modules/Leads/ConvertLayoutMetadataParser.php';
69                 return new ConvertLayoutMetadataParser( $moduleName );
70             case MB_BASICSEARCH :
71             case MB_ADVANCEDSEARCH :
72                 require_once 'modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php' ;
73                 return new SearchViewMetaDataParser ( $view, $moduleName, $packageName ) ;
74             case MB_LISTVIEW :
75                 if ($subpanelName == null)
76                 {
77                     require_once 'modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php' ;
78                     return new ListLayoutMetaDataParser ( MB_LISTVIEW, $moduleName, $packageName ) ;
79                 } else
80                 {
81                     require_once 'modules/ModuleBuilder/parsers/views/SubpanelMetaDataParser.php' ;
82                     return new SubpanelMetaDataParser ( $subpanelName, $moduleName, $packageName ) ;
83                 }
84             case MB_DASHLET :
85             case MB_DASHLETSEARCH :
86                 require_once 'modules/ModuleBuilder/parsers/views/DashletMetaDataParser.php' ;
87                 return new DashletMetaDataParser($view, $moduleName, $packageName  );
88             case MB_POPUPLIST :
89             case MB_POPUPSEARCH :
90                 require_once 'modules/ModuleBuilder/parsers/views/PopupMetaDataParser.php' ;
91                 return new PopupMetaDataParser($view, $moduleName, $packageName  );
92             case MB_LABEL :
93                 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
94                 return new ParserLabel ( $moduleName, $packageName ) ;
95             case MB_VISIBILITY :
96                 require_once 'modules/ModuleBuilder/parsers/parser.visibility.php' ;
97                 return new ParserVisibility ( $moduleName, $packageName ) ;
98             default :
99                 $prefix = '';
100                 if(!is_null ( $packageName )){
101                     $prefix = empty($packageName) ? 'build' :'modify';
102                 }
103                 $fileName = "modules/ModuleBuilder/parsers/parser." . strtolower ( $prefix . $view ) . ".php" ;
104                 if (file_exists ( $fileName ))
105                 {
106                     require_once $fileName ;
107                     $class = 'Parser' . $prefix . ucfirst ( $view ) ;
108                     if (class_exists ( $class ))
109                     {
110                         $GLOBALS [ 'log' ]->debug ( 'Using ModuleBuilder Parser ' . $fileName ) ;
111                         $parser = new $class ( ) ;
112                         return $parser ;
113                     }
114                 }
115
116         }
117
118         $GLOBALS [ 'log' ]->fatal ( get_class ( $this ) . ": cannot create ModuleBuilder Parser $fileName" ) ;
119
120     }
121
122 }
123 ?>