function createVardef($module,$object, $templates=array('default'), $object_name=false){ global $dictionary; //reverse the sort order so priority goes highest to lowest; $templates = array_reverse($templates); foreach($templates as $template){ VardefManager::addTemplate($module,$object,$template, $object_name); } LanguageManager::createLanguageFile($module, $templates); $vardef_paths = array( 'custom/modules/'.$module.'/Ext/Vardefs/vardefs.ext.php', 'custom/Extension/modules/'.$module.'/Ext/Vardefs/vardefs.php' ); //search a predefined set of locations for the vardef files foreach($vardef_paths as $path){ if(file_exists($path)){ require($path); } } }
global $dictionary; //reverse the sort order so priority goes highest to lowest;
$templates = array_reverse($templates);
foreach($templates as $template){
VardefManager::addTemplate($module,$object,$template, $object_name);
}
LanguageManager::createLanguageFile($module, $templates); $vardef_paths = array(
'custom/modules/'.$module.'/Ext/Vardefs/vardefs.ext.php',
'custom/Extension/modules/'.$module.'/Ext/Vardefs/vardefs.php'
); //search a predefined set of locations for the vardef files
foreach($vardef_paths as $path){
if(file_exists($path)){
require($path);
}
}
}
function addTemplate($module, $object, $template, $object_name=false){
if($template == 'default')$template = 'basic';
$templates = array();
$fields = array();
if(empty($object_name))$object_name = $object;
$_object_name = strtolower($object_name);
if(!empty($GLOBALS['dictionary'][$object]['table'])){
$table_name = $GLOBALS['dictionary'][$object]['table'];
}else{
$table_name = strtolower($module);
}
if(empty($templates[$template])){
$path = 'include/SugarObjects/templates/' . $template . '/vardefs.php';
if(file_exists($path)){
require($path);
$templates[$template] = $vardefs;
}else{
$path = 'include/SugarObjects/implements/' . $template . '/vardefs.php';
if(file_exists($path)){
require($path);
$templates[$template] = $vardefs;
}
}
} if(!empty($templates[$template])){
if(empty($GLOBALS['dictionary'][$object]['fields']))$GLOBALS['dictionary'][$object]['fields'] = array();
if(empty($GLOBALS['dictionary'][$object]['relationships']))$GLOBALS['dictionary'][$object]['relationships'] = array();
if(empty($GLOBALS['dictionary'][$object]['indices']))$GLOBALS['dictionary'][$object]['indices'] = array();
$GLOBALS['dictionary'][$object]['fields'] = array_merge($templates[$template]['fields'], $GLOBALS['dictionary'][$object]['fields']);
if(!empty($templates[$template]['relationships']))$GLOBALS['dictionary'][$object]['relationships'] = array_merge($templates[$template]['relationships'], $GLOBALS['dictionary'][$object]['relationships']);
if(!empty($templates[$template]['indices']))$GLOBALS['dictionary'][$object]['indices'] = array_merge($templates[$template]['indices'], $GLOBALS['dictionary'][$object]['indices']);
// maintain a record of this objects inheritance from the SugarObject templates...
$GLOBALS['dictionary'][$object]['templates'][ $template ] = $template ;
}
}
/**
http://bbs.cnsoftware.cn