function display() { global $mod_strings; $smarty = new Sugar_Smarty(); $mb = new ModuleBuilder(); //if (!empty($_REQUEST['package'])) { if (empty($_REQUEST['package']) && empty($_REQUEST['new'])) { $this->generatePackageButtons($mb->getPackageList()); $smarty->assign('buttons', $this->buttons); $smarty->assign('title', $GLOBALS['mod_strings']['LBL_MODULEBUILDER']); $smarty->assign("question", $GLOBALS['mod_strings']['LBL_QUESTION_PACKAGE']); $smarty->assign("defaultHelp", "mbHelp"); $ajax = new AjaxCompose(); $ajax->addCrumb($GLOBALS['mod_strings']['LBL_MODULEBUILDER'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package")'); $ajax->addCrumb($GLOBALS['mod_strings']['LBL_PACKAGE_LIST'], ''); $ajax->addSection('center', $GLOBALS['mod_strings']['LBL_PACKAGE_LIST'], $smarty->fetch('modules/ModuleBuilder/tpls/wizard.tpl')); echo $ajax->getJavascript(); } else { $name = !empty($_REQUEST['package']) ? $_REQUEST['package'] : ''; $mb->getPackage($name); require_once 'modules/ModuleBuilder/MB/MBPackageTree.php'; $mbt = new MBPackageTree(); $nodes = $mbt->fetchNodes(); $package_labels = array(); if (!empty($nodes['tree_data']['nodes'])) { foreach ($nodes['tree_data']['nodes'] as $entry) { if (!empty($entry['data']['label']) && $name != $entry['data']['label']) { $package_labels[] = strtoupper($entry['data']['label']); } } } $json = getJSONobj(); $smarty->assign('package_labels', $json->encode($package_labels)); $this->package =& $mb->packages[$name]; $this->loadModuleTypes(); $this->loadPackageHelp($name); $this->package->date_modified = $GLOBALS['timedate']->to_display_date_time($this->package->date_modified); $smarty->assign('package', $this->package); $smarty->assign('mod_strings', $mod_strings); $smarty->assign('package_already_deployed', 'false'); foreach ($this->package->modules as $a_module) { if (in_array($a_module->key_name, $GLOBALS['moduleList'])) { $smarty->assign('package_already_deployed', 'true'); break; } } $ajax = new AjaxCompose(); $ajax->addCrumb($GLOBALS['mod_strings']['LBL_MODULEBUILDER'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package")'); if (empty($name)) { $name = $mod_strings['LBL_NEW_PACKAGE']; } $ajax->addCrumb($name, ''); $html = $smarty->fetch('modules/ModuleBuilder/tpls/MBPackage/package.tpl'); if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'SavePackage') { $html .= "<script>ModuleBuilder.treeRefresh('ModuleBuilder')</script>"; } $ajax->addSection('center', translate('LBL_SECTION_PACKAGE', 'ModuleBuilder'), $html); echo $ajax->getJavascript(); } }
function display() { global $mod_strings; $smarty = new Sugar_Smarty(); $mb = new ModuleBuilder(); //if (!empty($_REQUEST['package'])) { if (empty($_REQUEST['package']) && empty($_REQUEST['new'])) { $this->generatePackageButtons($mb->getPackageList()); $smarty->assign('buttons', $this->buttons); $smarty->assign('title', $GLOBALS['mod_strings']['LBL_MODULEBUILDER']); $smarty->assign("question", $GLOBALS['mod_strings']['LBL_QUESTION_PACKAGE']); $smarty->assign("defaultHelp", "mbHelp"); $ajax = new AjaxCompose(); $ajax->addCrumb($GLOBALS['mod_strings']['LBL_MODULEBUILDER'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package")'); $ajax->addCrumb($GLOBALS['mod_strings']['LBL_PACKAGE_LIST'], ''); $ajax->addSection('center', $GLOBALS['mod_strings']['LBL_PACKAGE_LIST'], $smarty->fetch('modules/ModuleBuilder/tpls/wizard.tpl')); echo $ajax->getJavascript(); } else { $name = !empty($_REQUEST['package']) ? $_REQUEST['package'] : ''; $mb->getPackage($name); $this->package =& $mb->packages[$name]; $this->loadModuleTypes(); $this->loadPackageHelp($name); $this->package->date_modified = $GLOBALS['timedate']->to_display_date_time($this->package->date_modified); $smarty->assign('package', $this->package); $smarty->assign('mod_strings', $mod_strings); $ajax = new AjaxCompose(); $ajax->addCrumb($GLOBALS['mod_strings']['LBL_MODULEBUILDER'], 'ModuleBuilder.getContent("module=ModuleBuilder&action=package")'); if (empty($name)) { $name = $mod_strings['LBL_NEW_PACKAGE']; } $ajax->addCrumb($name, ''); $html = $smarty->fetch('modules/ModuleBuilder/tpls/MBPackage/package.tpl'); if (!empty($_REQUEST['action']) && $_REQUEST['action'] == 'SavePackage') { $html .= "<script>ModuleBuilder.treeRefresh('ModuleBuilder')</script>"; } $ajax->addSection('center', translate('LBL_SECTION_PACKAGE', 'ModuleBuilder'), $html); echo $ajax->getJavascript(); } }
static function parseDeployedModuleName($deployedName) { require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php'; $mb = new ModuleBuilder(); $packageName = ''; $moduleName = $deployedName; foreach ($mb->getPackageList() as $name) { // convert the keyName into a packageName, needed for checking to see if this is really an undeployed module, or just a module with a _ in the name... $package = $mb->getPackage($name); // seem to need to call getPackage twice to get the key correctly... TODO: figure out why... $key = $mb->getPackage($name)->key; if (strlen($key) < strlen($deployedName)) { $position = stripos($deployedName, $key); $moduleName = trim(substr($deployedName, strlen($key)), '_'); //use trim rather than just assuming that _ is between packageName and moduleName in the deployedName if ($position !== false && $position == 0 && isset($mb->packages[$name]->modules[$moduleName])) { $packageName = $name; break; } } } if (!empty($packageName)) { return array('moduleName' => $moduleName, 'packageName' => $packageName); } else { return array('moduleName' => $deployedName); } }
protected function getAllRelationships() { // start with the set of relationships known to this module plus those already deployed $allRelationships = array_merge($this->relationships, parent::getDeployedRelationships()); // add in the relationships known to ModuleBuilder require_once 'modules/ModuleBuilder/MB/ModuleBuilder.php'; $mb = new ModuleBuilder(); $mb->getPackages(); foreach ($mb->getPackageList() as $packageName) { $package = $mb->packages[$packageName]; foreach ($package->modules as $module) { foreach ($module->relationships->getRelationshipList() as $relationshipName) { $relationship = $module->relationships->get($relationshipName); $allRelationships[$relationship->getName()] = $relationship->getDefinition(); } } } return $allRelationships; }
/** * Gets a translated module name for both deployed and undeployed modules * * @param string $module The module to get a translated name for * @return string */ protected function getModuleName($module) { // If there is an object name for this (or bean name) assume this is a // deployed module and return the translated string if (BeanFactory::getObjectName($module)) { return translate($module); } // If we get here, then see if there is an undeployed module based on // all installed packages $mb = new ModuleBuilder(); $packages = $mb->getPackageList(); foreach ($packages as $package) { $mod = $mb->getPackage($package)->getModuleByFullName($module); if ($mod && !empty($mod->config['label'])) { // Since this is undeployed, there is no module "name" so rely on // the label in the module config return $mod->config['label']; } } // Hmmm, what really is this? Don't know, send it back as is return $module; }