2 if(!defined('sugarEntry') || !sugarEntry) die('Not A Valid Entry Point');
3 /*********************************************************************************
4 * SugarCRM is a customer relationship management program developed by
5 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
7 * This program is free software; you can redistribute it and/or modify it under
8 * the terms of the GNU Affero General Public License version 3 as published by the
9 * Free Software Foundation with the addition of the following permission added
10 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
11 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
12 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
14 * This program is distributed in the hope that it will be useful, but WITHOUT
15 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
16 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
19 * You should have received a copy of the GNU Affero General Public License along with
20 * this program; if not, see http://www.gnu.org/licenses or write to the Free
21 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
24 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
25 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
27 * The interactive user interfaces in modified source and object code versions
28 * of this program must display Appropriate Legal Notices, as required under
29 * Section 5 of the GNU Affero General Public License version 3.
31 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
32 * these Appropriate Legal Notices must retain the display of the "Powered by
33 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
34 * technical reasons, the Appropriate Legal Notices must display the words
35 * "Powered by SugarCRM".
36 ********************************************************************************/
39 abstract class AbstractMetaDataParser
42 //Make these properties public for now until we can create some usefull accessors
45 protected $_moduleName ;
46 protected $implementation ; // the DeployedMetaDataImplementation or UndeployedMetaDataImplementation object to handle the reading and writing of files and field data
48 function getLayoutAsArray ()
50 $viewdefs = $this->_panels ;
53 function getLanguage ()
55 return $this->implementation->getLanguage () ;
58 function getHistory ()
60 return $this->implementation->getHistory () ;
63 function removeField ($fieldName)
69 * Is this field something we wish to show in Studio/ModuleBuilder layout editors?
70 * @param array $def Field definition in the standard SugarBean field definition format - name, vname, type and so on
71 * @return boolean True if ok to show, false otherwise
73 static function validField ( $def, $view = "")
75 //Studio invisible fields should always be hidden
76 if (isset ($def[ 'studio' ] ) )
78 if (is_array($def [ 'studio' ]))
80 if (!empty($view) && isset($def [ 'studio' ][$view]))
81 return $def [ 'studio' ][$view] !== false && $def [ 'studio' ][$view] !== 'false' && $def [ 'studio' ][$view] !== 'hidden';
82 if (isset($def [ 'studio' ]['visible']))
83 return $def [ 'studio' ]['visible'];
85 return ($def [ 'studio' ] != 'false' && $def [ 'studio' ] != 'hidden' && $def [ 'studio' ] !== false) ;
89 // bug 19656: this test changed after 5.0.0b - we now remove all ID type fields - whether set as type, or dbtype, from the fielddefs
93 (empty ( $def [ 'source' ] ) || $def [ 'source' ] == 'db' || $def [ 'source' ] == 'custom_fields')
94 && isset($def [ 'type' ]) && $def [ 'type' ] != 'id' && $def [ 'type' ] != 'parent_type'
95 && (empty ( $def [ 'dbType' ] ) || $def [ 'dbType' ] != 'id')
96 && ( isset ( $def [ 'name' ] ) && strcmp ( $def [ 'name' ] , 'deleted' ) != 0 )
97 ) // db and custom fields that aren't ID fields
99 // exclude fields named *_name regardless of their type...just convention
100 (isset ( $def [ 'name' ] ) && substr ( $def [ 'name' ], -5 ) === '_name' ) ) ;
103 protected function _standardizeFieldLabels ( &$fielddefs )
105 foreach ( $fielddefs as $key => $def )
107 if ( !isset ($def [ 'label' ] ) )
109 $fielddefs [ $key ] [ 'label'] = ( isset ( $def [ 'vname' ] ) ) ? $def [ 'vname' ] : $key ;
114 abstract static function _trimFieldDefs ( $def ) ;
116 public function getRequiredFields(){
117 $fieldDefs = $this->implementation->getFielddefs();
119 foreach($fieldDefs as $field){
120 if(isset($field['required']) && $field['required'] && isset($field['name'])){
121 array_push($newAry , '"'.$field['name'].'"');