Skip to content

Instantly share code, notes, and snippets.

@vjaro-metrix
Created June 6, 2016 19:03
Show Gist options
  • Select an option

  • Save vjaro-metrix/875a2d11afa1b64dfe87580a3a687e92 to your computer and use it in GitHub Desktop.

Select an option

Save vjaro-metrix/875a2d11afa1b64dfe87580a3a687e92 to your computer and use it in GitHub Desktop.
Extract Module list and get field an field names
<?php
ini_set("display_errors", true);
if (! defined('sugarEntry')) {
define('sugarEntry', true);
}
require_once('include/entryPoint.php');
$user = BeanFactory::getBean("Users", 1);
$GLOBALS["current_user"] = $user;
$file = fopen("modulesFieldsLabels.csv", "w");
$header = array("Module", "Label", "Field");
fputcsv($file,$header);
foreach ($GLOBALS['moduleList'] as $module_name) {
$bean = BeanFactory::getBean($module_name);
if (is_object($bean)) {
$fieldDef = $bean->getFieldDefinitions();
foreach ($fieldDef as $fieldName => $fieldDefArray) {
if (! empty($fieldDefArray['vname'])) {
$fieldLabel = translate($fieldDefArray['vname'], $bean->module_dir);
$moduleLabel = translate('LBL_MODULE_NAME', $bean->module_dir);
$field_defs[] = array(
$moduleLabel,
$fieldLabel,
$fieldName
);
fputcsv($file, array($moduleLabel, $fieldLabel,$fieldName));
}
}
}
}
fclose($file);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment