2 if (! defined ( 'sugarEntry' ) || ! sugarEntry)
3 die ( 'Not A Valid Entry Point' ) ;
4 /*********************************************************************************
5 * SugarCRM is a customer relationship management program developed by
6 * SugarCRM, Inc. Copyright (C) 2004-2011 SugarCRM Inc.
8 * This program is free software; you can redistribute it and/or modify it under
9 * the terms of the GNU Affero General Public License version 3 as published by the
10 * Free Software Foundation with the addition of the following permission added
11 * to Section 15 as permitted in Section 7(a): FOR ANY PART OF THE COVERED WORK
12 * IN WHICH THE COPYRIGHT IS OWNED BY SUGARCRM, SUGARCRM DISCLAIMS THE WARRANTY
13 * OF NON INFRINGEMENT OF THIRD PARTY RIGHTS.
15 * This program is distributed in the hope that it will be useful, but WITHOUT
16 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 * FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
20 * You should have received a copy of the GNU Affero General Public License along with
21 * this program; if not, see http://www.gnu.org/licenses or write to the Free
22 * Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
25 * You can contact SugarCRM, Inc. headquarters at 10050 North Wolfe Road,
26 * SW2-130, Cupertino, CA 95014, USA. or at email address contact@sugarcrm.com.
28 * The interactive user interfaces in modified source and object code versions
29 * of this program must display Appropriate Legal Notices, as required under
30 * Section 5 of the GNU Affero General Public License version 3.
32 * In accordance with Section 7(b) of the GNU Affero General Public License version 3,
33 * these Appropriate Legal Notices must retain the display of the "Powered by
34 * SugarCRM" logo. If the display of the logo is not reasonably feasible for
35 * technical reasons, the Appropriate Legal Notices must display the words
36 * "Powered by SugarCRM".
37 ********************************************************************************/
40 require_once 'modules/ModuleBuilder/parsers/views/AbstractMetaDataParser.php' ;
41 require_once 'modules/ModuleBuilder/parsers/views/MetaDataParserInterface.php' ;
42 require_once 'modules/ModuleBuilder/parsers/constants.php' ;
44 class GridLayoutMetaDataParser extends AbstractMetaDataParser implements MetaDataParserInterface
47 static $variableMap = array (
48 MB_EDITVIEW => 'EditView' ,
49 MB_DETAILVIEW => 'DetailView' ,
50 MB_QUICKCREATE => 'QuickCreate',
57 * @param string view The view type, that is, editview, searchview etc
58 * @param string moduleName The name of the module to which this view belongs
59 * @param string packageName If not empty, the name of the package to which this view belongs
61 function __construct ($view , $moduleName , $packageName = '')
63 $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->__construct( {$view} , {$moduleName} , {$packageName} )" ) ;
65 $view = strtolower ( $view ) ;
68 if (! isset ( self::$variableMap [ $view ] ) )
69 sugar_die ( get_class ( $this ) . ": View $view is not supported" ) ;
72 $this->FILLER = array ( 'name' => MBConstants::$FILLER['name'] , 'label' => translate ( MBConstants::$FILLER['label'] ) ) ;
74 $this->_moduleName = $moduleName ;
75 $this->_view = $view ;
77 if (empty ( $packageName ))
79 require_once 'modules/ModuleBuilder/parsers/views/DeployedMetaDataImplementation.php' ;
80 $this->implementation = new DeployedMetaDataImplementation ( $view, $moduleName, self::$variableMap ) ;
83 require_once 'modules/ModuleBuilder/parsers/views/UndeployedMetaDataImplementation.php' ;
84 $this->implementation = new UndeployedMetaDataImplementation ( $view, $moduleName, $packageName ) ;
87 $viewdefs = $this->implementation->getViewdefs () ;
89 if (! isset ( $viewdefs [ self::$variableMap [ $view ] ] ))
90 sugar_die ( get_class ( $this ) . ": missing variable " . self::$variableMap [ $view ] . " in layout definition" ) ;
92 $viewdefs = $viewdefs [ self::$variableMap [ $view ] ] ;
93 if (! isset ( $viewdefs [ 'templateMeta' ] ))
94 sugar_die ( get_class ( $this ) . ": missing templateMeta section in layout definition (case sensitive)" ) ;
96 if (! isset ( $viewdefs [ 'panels' ] ))
97 sugar_die ( get_class ( $this ) . ": missing panels section in layout definition (case sensitive)" ) ;
99 $this->_viewdefs = $viewdefs ;
100 if ($this->getMaxColumns () < 1)
101 sugar_die ( get_class ( $this ) . ": maxColumns=" . $this->getMaxColumns () . " - must be greater than 0!" ) ;
103 $this->_fielddefs = $this->implementation->getFielddefs() ;
104 $this->_standardizeFieldLabels( $this->_fielddefs );
105 $this->_viewdefs [ 'panels' ] = $this->_convertFromCanonicalForm ( $this->_viewdefs [ 'panels' ] , $this->_fielddefs ) ; // put into our internal format
106 $this->_originalViewDef = $this->getFieldsFromLayout($this->implementation->getOriginalViewdefs ());
110 * Save a draft layout
112 function writeWorkingFile ($populate = true)
115 $this->_populateFromRequest ( $this->_fielddefs ) ;
117 $viewdefs = $this->_viewdefs ;
118 $viewdefs [ 'panels' ] = $this->_convertToCanonicalForm ( $this->_viewdefs [ 'panels' ] , $this->_fielddefs ) ;
119 $this->implementation->save ( array ( self::$variableMap [ $this->_view ] => $viewdefs ) ) ;
124 * @param boolean $populate If true (default), then update the layout first with new layout information from the $_REQUEST array
126 function handleSave ($populate = true)
128 $GLOBALS [ 'log' ]->info ( get_class ( $this ) . "->handleSave()" ) ;
131 $this->_populateFromRequest ( $this->_fielddefs ) ;
133 $viewdefs = $this->_viewdefs ;
134 $viewdefs [ 'panels' ] = $this->_convertToCanonicalForm ( $this->_viewdefs [ 'panels' ] , $this->_fielddefs ) ;
135 $this->implementation->deploy ( array ( self::$variableMap [ $this->_view ] => $viewdefs ) ) ;
139 * Return the layout, padded out with (empty) and (filler) fields ready for display
141 function getLayout ()
143 $viewdefs = array () ;
144 $fielddefs = $this->_fielddefs;
145 $fielddefs [ $this->FILLER [ 'name' ] ] = $this->FILLER ;
146 $fielddefs [ MBConstants::$EMPTY [ 'name' ] ] = MBConstants::$EMPTY ;
148 foreach ( $this->_viewdefs [ 'panels' ] as $panelID => $panel )
150 foreach ( $panel as $rowID => $row )
152 foreach ( $row as $colID => $fieldname )
154 if (isset ($this->_fielddefs [ $fieldname ]))
156 $viewdefs [ $panelID ] [ $rowID ] [ $colID ] = self::_trimFieldDefs( $this->_fielddefs [ $fieldname ] ) ;
158 else if (isset($this->_originalViewDef [ $fieldname ]) && is_array($this->_originalViewDef [ $fieldname ]))
160 $viewdefs [ $panelID ] [ $rowID ] [ $colID ] = self::_trimFieldDefs( $this->_originalViewDef [ $fieldname ] ) ;
164 $viewdefs [ $panelID ] [ $rowID ] [ $colID ] = array("name" => $fieldname, "label" => $fieldname);
172 function getMaxColumns ()
174 if (!empty( $this->_viewdefs) && isset($this->_viewdefs [ 'templateMeta' ] [ 'maxColumns' ]))
176 return $this->_viewdefs [ 'templateMeta' ] [ 'maxColumns' ] ;
183 function getAvailableFields ()
186 // Obtain the full list of valid fields in this module
187 $availableFields = array () ;
188 foreach ( $this->_fielddefs as $key => $def )
190 if ( GridLayoutMetaDataParser::validField ( $def, $this->_view ) || isset($this->_originalViewDef[$key]) )
192 //If the field original label existing, we should use the original label instead the label in its fielddefs.
193 if(isset($this->_originalViewDef[$key]) && is_array($this->_originalViewDef[$key]) && isset($this->_originalViewDef[$key]['label'])){
194 $availableFields [ $key ] = array ( 'name' => $key , 'label' => $this->_originalViewDef[$key]['label']) ;
196 $availableFields [ $key ] = array ( 'name' => $key , 'label' => isset($def [ 'label' ]) ? $def [ 'label' ] : $def['vname'] ) ; // layouts use 'label' not 'vname' for the label entry
202 // Available fields are those that are in the Model and the original layout definition, but not already shown in the View
203 // So, because the formats of the two are different we brute force loop through View and unset the fields we find in a copy of Model
204 if (! empty ( $this->_viewdefs ))
206 foreach ( $this->_viewdefs [ 'panels' ] as $panel )
208 foreach ( $panel as $row )
210 foreach ( $row as $field )
212 unset ( $availableFields [ $field ] ) ;
218 return $availableFields ;
221 function getPanelDependency ( $panelID )
223 if ( ! isset ( $this->_viewdefs [ 'templateMeta' ][ 'dependency' ] ) && ! isset ( $this->_viewdefs [ 'templateMeta' ][ 'dependency' ] [ $panelID ] ) )
226 return $this->_viewdefs [ 'templateMeta' ][ 'dependency' ] [ $panelID ] ;
230 * Add a new field to the layout
231 * If $panelID is passed in, attempt to add to that panel, otherwise add to the first panel
232 * The field is added in place of the first empty (not filler) slot after the last field in the panel; if that row is full, then a new row will be added to the end of the panel
233 * and the field added to the start of it.
234 * @param array $def Set of properties for the field, in same format as in the viewdefs
235 * @param string $panelID Identifier of the panel to add the field to; empty or false if we should use the first panel
237 function addField ( $def , $panelID = FALSE)
240 if (count ( $this->_viewdefs [ 'panels' ] ) == 0)
242 $GLOBALS [ 'log' ]->error ( get_class ( $this ) . "->addField(): _viewdefs empty for module {$this->_moduleName} and view {$this->_view}" ) ;
245 // if a panelID was not provided, use the first available panel in the list
248 $panels = array_keys ( $this->_viewdefs [ 'panels' ] ) ;
249 list ( $dummy, $panelID ) = each ( $panels ) ;
252 if (isset ( $this->_viewdefs [ 'panels' ] [ $panelID ] ))
255 $panel = $this->_viewdefs [ 'panels' ] [ $panelID ] ;
256 $lastrow = count ( $panel ) - 1 ; // index starts at 0
257 $maxColumns = $this->getMaxColumns () ;
258 $lastRowDef = $this->_viewdefs [ 'panels' ] [ $panelID ] [ $lastrow ];
259 for ( $column = 0 ; $column < $maxColumns ; $column ++ )
261 if (! isset ( $lastRowDef [ $column ] )
262 || (is_array( $lastRowDef [ $column ]) && $lastRowDef [ $column ][ 'name' ] == '(empty)')
263 || (is_string( $lastRowDef [ $column ]) && $lastRowDef [ $column ] == '(empty)')
269 // if we're on the last column of the last row, start a new row
270 if ($column >= $maxColumns)
273 $this->_viewdefs [ 'panels' ] [ $panelID ] [ $lastrow ] = array ( ) ;
277 $this->_viewdefs [ 'panels' ] [ $panelID ] [ $lastrow ] [ $column ] = $def [ 'name' ] ;
278 // now update the fielddefs
279 if (isset($this->_fielddefs [ $def [ 'name' ] ]))
281 $this->_fielddefs [ $def [ 'name' ] ] = array_merge ( $this->_fielddefs [ $def [ 'name' ] ] , $def ) ;
284 $this->_fielddefs [ $def [ 'name' ] ] = $def;
291 * Remove all instances of a field from the layout, and replace by (filler)
292 * Filler because we attempt to preserve the customized layout as much as possible - replacing by (empty) would mean that the positions or sizes of adjacent fields may change
293 * If the last row of a panel only consists of (filler) after removing the fields, then remove the row also. This undoes the standard addField() scenario;
294 * If the fields had been moved around in the layout however then this will not completely undo any addField()
295 * @param string $fieldName Name of the field to remove
296 * @return boolean True if the field was removed; false otherwise
298 function removeField ($fieldName)
300 $GLOBALS [ 'log' ]->info ( get_class ( $this ) . "->removeField($fieldName)" ) ;
303 reset ( $this->_viewdefs ) ;
304 $firstPanel = each ( $this->_viewdefs [ 'panels' ] ) ;
305 $firstPanelID = $firstPanel [ 'key' ] ;
307 foreach ( $this->_viewdefs [ 'panels' ] as $panelID => $panel )
309 $lastRowTouched = false ;
310 $lastRowID = count ( $this->_viewdefs [ 'panels' ] [ $panelID ] ) - 1 ; // zero offset
312 foreach ( $panel as $rowID => $row )
315 foreach ( $row as $colID => $field )
316 if ($field == $fieldName)
318 $lastRowTouched = $rowID ;
319 $this->_viewdefs [ 'panels' ] [ $panelID ] [ $rowID ] [ $colID ] = $this->FILLER [ 'name' ];
324 // if we removed a field from the last row of this panel, tidy up if the last row now consists only of (empty) or (filler)
326 if ( $lastRowTouched == $lastRowID )
328 $lastRow = $this->_viewdefs [ 'panels' ] [ $panelID ] [ $lastRowID ] ; // can't use 'end' for this as we need the key as well as the value...
332 foreach ( $lastRow as $colID => $field )
333 $empty &= $field == MBConstants::$EMPTY ['name' ] || $field == $this->FILLER [ 'name' ] ;
337 unset ( $this->_viewdefs [ 'panels' ] [ $panelID ] [ $lastRowID ] ) ;
338 // if the row was the only one in the panel, and the panel is not the first (default) panel, then remove the panel also
339 if ( count ( $this->_viewdefs [ 'panels' ] [ $panelID ] ) == 0 && $panelID != $firstPanelID )
340 unset ( $this->_viewdefs [ 'panels' ] [ $panelID ] ) ;
345 $result |= ($lastRowTouched !== false ); // explicitly compare to false as row 0 will otherwise evaluate as false
352 function setPanelDependency ( $panelID , $dependency )
354 // only accept dependencies for pre-existing panels
355 if ( ! isset ( $this->_viewdefs [ 'panels' ] [ $panelID ] ) )
358 $this->_viewdefs [ 'templateMeta' ] [ 'dependency' ] [ $panelID ] = $dependency ;
363 * Return an integer value for the next unused panel identifier, such that it and any larger numbers are guaranteed to be unused already in the layout
364 * Necessary when adding new panels to a layout
365 * @return integer First unique panel ID suffix
367 function getFirstNewPanelId ()
369 $firstNewPanelId = 0 ;
370 foreach ( $this->_viewdefs [ 'panels' ] as $panelID => $panel )
372 // strip out all but the numerics from the panelID - can't just use a cast as numbers may not be first in the string
373 for ( $i = 0, $result = '' ; $i < strlen ( $panelID ) ; $i ++ )
375 if (is_numeric ( $panelID [ $i ] ))
377 $result .= $panelID [ $i ] ;
381 $firstNewPanelId = max ( ( int ) $result, $firstNewPanelId ) ;
383 return $firstNewPanelId + 1 ;
387 * Load the panel layout from the submitted form and update the _viewdefs
389 protected function _populateFromRequest ( &$fielddefs )
391 $GLOBALS [ 'log' ]->debug ( get_class ( $this ) . "->populateFromRequest()" ) ;
394 // set up the map of panel# (as provided in the _REQUEST) to panel ID (as used in $this->_viewdefs['panels'])
396 foreach ( $this->_viewdefs [ 'panels' ] as $panelID => $panel )
398 $panelMap [ $i ++ ] = $panelID ;
401 foreach ( $_REQUEST as $key => $displayLabel )
403 $components = explode ( '-', $key ) ;
404 if ($components [ 0 ] == 'panel' && $components [ 2 ] == 'label')
406 $panelMap [ $components [ '1' ] ] = $displayLabel ;
410 $this->_viewdefs [ 'panels' ] = array () ; // because the new field properties should replace the old fields, not be merged
412 // run through the $_REQUEST twice - first to obtain the fieldnames, the second to update the field properties
413 for ( $pass=1 ; $pass<=2 ; $pass++ )
415 foreach ( $_REQUEST as $slot => $value )
417 $slotComponents = explode ( '-', $slot ) ; // [0] = 'slot', [1] = panel #, [2] = slot #, [3] = property name
419 if ($slotComponents [ 0 ] == 'slot')
421 $slotNumber = $slotComponents [ '2' ] ;
422 $panelID = $panelMap [ $slotComponents [ '1' ] ] ;
423 $rowID = floor ( $slotNumber / $this->getMaxColumns () ) ;
424 $colID = $slotNumber - ($rowID * $this->getMaxColumns ()) ;
425 $property = $slotComponents [ '3' ] ;
427 //If this field has a custom definition, copy that over
430 if ( $property == 'name' )
431 $this->_viewdefs [ 'panels' ] [ $panelID ] [ $rowID ] [ $colID ] = $value ;
434 // update fielddefs for this property in the provided position
435 if ( isset ( $this->_viewdefs [ 'panels' ] [ $panelID ] [ $rowID ] [ $colID ] ) )
437 $fieldname = $this->_viewdefs [ 'panels' ] [ $panelID ] [ $rowID ] [ $colID ] ;
438 $fielddefs [ $fieldname ] [ $property ] = $value ;
446 //Set the tabs setting
447 if (isset($_REQUEST['panels_as_tabs']))
449 if ($_REQUEST['panels_as_tabs'] == false || $_REQUEST['panels_as_tabs'] == "false")
450 $this->setUseTabs( false );
452 $this->setUseTabs( true );
455 //bug: 38232 - Set the sync detail and editview settings
456 if (isset($_REQUEST['sync_detail_and_edit']))
458 if ($_REQUEST['sync_detail_and_edit'] == false || $_REQUEST['sync_detail_and_edit'] == "false")
459 $this->setSyncDetailEditViews( false );
461 $this->setSyncDetailEditViews( true );
464 $GLOBALS [ 'log' ]->debug ( print_r ( $this->_viewdefs [ 'panels' ], true ) ) ;
468 /* Convert our internal format back to the standard Canonical MetaData layout
469 * First non-(empty) field goes in at column 0; all other (empty)'s removed
470 * Studio required fields are also added to the layout.
471 * Do this AFTER reading in all the $_REQUEST parameters as can't guarantee the order of those, and we need to operate on complete rows
473 protected function _convertToCanonicalForm ( $panels , $fielddefs )
475 $previousViewDef = $this->getFieldsFromLayout($this->implementation->getViewdefs ());
476 $oldDefs = $this->implementation->getViewdefs ();
477 $currentFields = $this->getFieldsFromLayout($this->_viewdefs);
478 foreach($fielddefs as $field => $def)
480 if (self::fieldIsRequired($def) && !isset($currentFields[$field]))
482 //Use the previous viewdef if this field was on it.
483 if (isset($previousViewDef[$field]))
485 $def = $previousViewDef[$field];
487 //next see if the field was on the original layout.
488 else if (isset ($this->_originalViewDef [ $field ]))
490 $def = $this->_originalViewDef [ $field ] ;
492 //Otherwise make up a viewdef for it from field_defs
495 $def = self::_trimFieldDefs( $def ) ;
497 $this->addField($def);
501 foreach ( $panels as $panelID => $panel )
503 // remove all (empty)s
504 foreach ( $panel as $rowID => $row )
508 foreach ( $row as $colID => $fieldname )
510 if ($fieldname == MBConstants::$EMPTY[ 'name' ])
512 // if a leading (empty) then remove (by noting that remaining fields need to be shuffled along)
517 unset ( $row [ $colID ] ) ;
520 $startOfRow = false ;
524 // reindex to remove leading (empty)s and replace fieldnames by full definition from fielddefs
525 $newRow = array ( ) ;
526 foreach ( $row as $colID => $fieldname )
528 if ($fieldname == null)
531 //Backwards compatibility and a safeguard against multiple calls to _convertToCanonicalForm
532 if(is_array($fieldname))
534 $newRow [ $colID - $offset ] = $fieldname;
538 //Replace (filler) with the empty string
539 if ($fieldname == $this->FILLER[ 'name' ]) {
540 $newRow [ $colID - $offset ] = '' ;
542 //Use the previous viewdef if this field was on it.
543 else if (isset($previousViewDef[$fieldname]))
545 $newRow [ $colID - $offset ] = $previousViewDef[$fieldname];
546 //We should copy over the tabindex if it is set.
547 if (isset ($fielddefs [ $fieldname ]) && !empty($fielddefs [ $fieldname ]['tabindex']))
548 $newRow [ $colID - $offset ]['tabindex'] = $fielddefs [ $fieldname ]['tabindex'];
550 //next see if the field was on the original layout.
551 else if (isset ($this->_originalViewDef [ $fieldname ]))
553 $newRow [ $colID - $offset ] = $this->_originalViewDef [ $fieldname ] ;
554 //We should copy over the tabindex if it is set.
555 if (isset ($fielddefs [ $fieldname ]) && !empty($fielddefs [ $fieldname ]['tabindex']))
556 $newRow [ $colID - $offset ]['tabindex'] = $fielddefs [ $fieldname ]['tabindex'];
558 //Otherwise make up a viewdef for it from field_defs
559 else if (isset ($fielddefs [ $fieldname ]))
561 $newRow [ $colID - $offset ] = self::_trimFieldDefs( $fielddefs [ $fieldname ] ) ;
564 //No additional info on this field can be found, jsut use the name;
567 $newRow [ $colID - $offset ] = $fieldname;
570 $panels [ $panelID ] [ $rowID ] = $newRow ;
578 * Convert from the standard MetaData format to our internal format
579 * Replace NULL with (filler) and missing entries with (empty)
581 protected function _convertFromCanonicalForm ( $panels , $fielddefs )
583 if (empty ( $panels ))
586 // Fix for a flexibility in the format of the panel sections - if only one panel, then we don't have a panel level defined,
587 // it goes straight into rows
588 // See EditView2 for similar treatment
589 if (! empty ( $panels ) && count ( $panels ) > 0)
591 $keys = array_keys ( $panels ) ;
592 if (is_numeric ( $keys [ 0 ] ))
594 $defaultPanel = $panels ;
595 unset ( $panels ) ; //blow away current value
596 $panels [ 'default' ] = $defaultPanel ;
600 $newPanels = array ( ) ;
602 // replace '' with (filler)
603 foreach ( $panels as $panelID => $panel )
605 foreach ( $panel as $rowID => $row )
608 foreach ( $row as $colID => $col )
610 if ( ! empty ( $col ) )
612 if ( is_string ( $col ))
615 } else if (! empty ( $col [ 'name' ] ))
617 $fieldname = $col [ 'name' ] ;
621 $fieldname = $this->FILLER['name'] ;
624 $newPanels [ $panelID ] [ $rowID ] [ $cols ] = $fieldname ;
630 // replace missing fields with (empty)
631 foreach ( $newPanels as $panelID => $panel )
634 foreach ( $panel as $rowID => $row )
636 // pad between fields on a row
637 foreach ( $row as $colID => $col )
639 for ( $i = $column + 1 ; $i < $colID ; $i ++ )
641 $row [ $i ] = MBConstants::$EMPTY ['name'];
645 // now pad out to the end of the row
646 if (($column + 1) < $this->getMaxColumns ())
647 { // last column is maxColumns-1
648 for ( $i = $column + 1 ; $i < $this->getMaxColumns () ; $i ++ )
650 $row [ $i ] = MBConstants::$EMPTY ['name'] ;
654 $newPanels [ $panelID ] [ $rowID ] = $row ;
661 protected function getFieldsFromLayout($viewdef) {
662 if (isset($viewdef['panels']))
664 $panels = $viewdef['panels'];
666 $panels = $viewdef[self::$variableMap [ $this->_view ] ]['panels'];
670 if (is_array($panels))
672 foreach ( $panels as $rows) {
673 foreach ($rows as $fields) {
674 //wireless layouts have one less level of depth
675 if (is_array($fields) && isset($fields['name'])) {
676 $ret[$fields['name']] = $fields;
679 if (!is_array($fields)) {
680 $ret[$fields] = $fields;
683 foreach ($fields as $field) {
684 if (is_array($field) && !empty($field['name']))
686 $ret[$field['name']] = $field;
688 else if(!is_array($field)){
689 $ret[$field] = $field;
698 protected function fieldIsRequired($def)
700 if (isset($def['studio']))
702 if (is_array($def['studio']))
704 if (!empty($def['studio'][$this->_view]) && $def['studio'][$this->_view] == "required")
708 else if (!empty($def['studio']['required']) && $def['studio']['required'] == true)
713 else if ($def['studio'] == "required" ){
720 static function _trimFieldDefs ( $def )
722 $ret = array_intersect_key ( $def ,
723 array ( 'studio' => true , 'name' => true , 'label' => true , 'displayParams' => true , 'comment' => true ,
724 'customCode' => true , 'customLabel' => true , 'tabIndex' => true , 'hideLabel' => true) ) ;
725 if (!empty($def['vname']) && empty($def['label']))
726 $ret['label'] = $def['vname'];
730 public function getUseTabs(){
731 if (isset($this->_viewdefs [ 'templateMeta' ]['useTabs']))
732 return $this->_viewdefs [ 'templateMeta' ]['useTabs'];
737 public function setUseTabs($useTabs){
738 $this->_viewdefs [ 'templateMeta' ]['useTabs'] = $useTabs;
742 * Return whether the Detail & EditView should be in sync.
744 public function getSyncDetailEditViews(){
745 if (isset($this->_viewdefs [ 'templateMeta' ]['syncDetailEditViews']))
746 return $this->_viewdefs [ 'templateMeta' ]['syncDetailEditViews'];
752 * Sync DetailView & EditView. This should only be set on the EditView
753 * @param bool $syncViews
755 public function setSyncDetailEditViews($syncDetailEditViews){
756 $this->_viewdefs [ 'templateMeta' ]['syncDetailEditViews'] = $syncDetailEditViews;
760 * Getter function to get the implementation method which is a private variable
761 * @return DeployedMetaDataImplementation
763 public function getImplementation(){
764 return $this->implementation;
768 * Public access to _convertFromCanonicalForm
773 public function convertFromCanonicalForm ( $panels , $fielddefs )
775 return $this->_convertFromCanonicalForm ( $panels , $fielddefs );
779 * Public access to _convertToCanonicalForm
784 public function convertToCanonicalForm ( $panels , $fielddefs )
786 return $this->_convertToCanonicalForm ( $panels , $fielddefs );
791 * @return Array list of fields in this module that have the calculated property
793 public function getCalculatedFields() {
795 foreach ($this->_fielddefs as $field => $def)
797 if(!empty($def['calculated']) && !empty($def['formula']))