]> CyberLeo.Net >> Repos - Github/sugarcrm.git/blob - modules/ModuleBuilder/parsers/ParserFactory.php
Release 6.2.0
[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 Community Edition 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_BASICSEARCH :
68             case MB_ADVANCEDSEARCH :
69                 require_once 'modules/ModuleBuilder/parsers/views/SearchViewMetaDataParser.php' ;
70                 return new SearchViewMetaDataParser ( $view, $moduleName, $packageName ) ;
71             case MB_LISTVIEW :
72                 if ($subpanelName == null)
73                 {
74                     require_once 'modules/ModuleBuilder/parsers/views/ListLayoutMetaDataParser.php' ;
75                     return new ListLayoutMetaDataParser ( MB_LISTVIEW, $moduleName, $packageName ) ;
76                 } else
77                 {
78                     require_once 'modules/ModuleBuilder/parsers/views/SubpanelMetaDataParser.php' ;
79                     return new SubpanelMetaDataParser ( $subpanelName, $moduleName, $packageName ) ;
80                 }
81             case MB_DASHLET :
82             case MB_DASHLETSEARCH :
83                 require_once 'modules/ModuleBuilder/parsers/views/DashletMetaDataParser.php' ;
84                 return new DashletMetaDataParser($view, $moduleName, $packageName  );
85             case MB_POPUPLIST :
86             case MB_POPUPSEARCH :
87                 require_once 'modules/ModuleBuilder/parsers/views/PopupMetaDataParser.php' ;
88                 return new PopupMetaDataParser($view, $moduleName, $packageName  );
89             case MB_LABEL :
90                 require_once 'modules/ModuleBuilder/parsers/parser.label.php' ;
91                 return new ParserLabel ( $moduleName, $packageName ) ;
92             case MB_VISIBILITY :
93                 require_once 'modules/ModuleBuilder/parsers/parser.visibility.php' ;
94                 return new ParserVisibility ( $moduleName, $packageName ) ;
95             default :
96                 $prefix = '';
97                 if(!is_null ( $packageName )){
98                     $prefix = empty($packageName) ? 'build' :'modify';
99                 }
100                 $fileName = "modules/ModuleBuilder/parsers/parser." . strtolower ( $prefix . $view ) . ".php" ;
101                 if (file_exists ( $fileName ))
102                 {
103                     require_once $fileName ;
104                     $class = 'Parser' . $prefix . ucfirst ( $view ) ;
105                     if (class_exists ( $class ))
106                     {
107                         $GLOBALS [ 'log' ]->debug ( 'Using ModuleBuilder Parser ' . $fileName ) ;
108                         $parser = new $class ( ) ;
109                         return $parser ;
110                     }
111                 }
112
113         }
114
115         $GLOBALS [ 'log' ]->fatal ( get_class ( $this ) . ": cannot create ModuleBuilder Parser $fileName" ) ;
116
117     }
118
119 }
120 ?>