_subpanelName = $subpanelName ; $this->_moduleName = $moduleName ; // TODO: history $this->historyPathname = 'custom/history/modulebuilder/packages/' . $packageName . '/modules/' . $moduleName . '/metadata/' . self::HISTORYFILENAME ; $this->_history = new History ( $this->historyPathname ) ; //get the bean from ModuleBuilder $mb = new ModuleBuilder ( ) ; $this->module = & $mb->getPackageModule ( $packageName, $moduleName ) ; $this->module->mbvardefs->updateVardefs () ; $this->_fielddefs = & $this->module->mbvardefs->vardefs [ 'fields' ] ; $subpanel_layout = $this->module->getAvailibleSubpanelDef ( $this->_subpanelName ) ; $this->_viewdefs = & $subpanel_layout [ 'list_fields' ] ; $this->_mergeFielddefs($this->_fielddefs, $this->_viewdefs); // Set the global mod_strings directly as Sugar does not automatically load the language files for undeployed modules (how could it?) $selected_lang = 'en_us'; if(isset($GLOBALS['current_language']) &&!empty($GLOBALS['current_language'])) { $selected_lang = $GLOBALS['current_language']; } $GLOBALS [ 'mod_strings' ] = array_merge ( $GLOBALS [ 'mod_strings' ], $this->module->getModStrings ($selected_lang) ) ; } function getLanguage () { return "" ; // '' is the signal to translate() to use the global mod_strings } /* * Save a subpanel * @param array defs Layout definition in the same format as received by the constructor * @param string type The location for the file - for example, MB_BASEMETADATALOCATION for a location in the OOB metadata directory */ function deploy ($defs) { $outputDefs = $this->module->getAvailibleSubpanelDef ( $this->_subpanelName ) ; // first sort out the historical record... // copy the definition to a temporary file then let the history object add it write_array_to_file ( self::HISTORYVARIABLENAME, $outputDefs, $this->historyPathname, 'w', '' ) ; $this->_history->append ( $this->historyPathname ) ; // no need to unlink the temporary file as being handled by in history->append() //unlink ( $this->historyPathname ) ; $outputDefs [ 'list_fields' ] = $defs ; $this->_viewdefs = $defs ; $this->module->saveAvailibleSubpanelDef ( $this->_subpanelName, $outputDefs ) ; } }