本文整理汇总了PHP中DynamicField::setup方法的典型用法代码示例。如果您正苦于以下问题:PHP DynamicField::setup方法的具体用法?PHP DynamicField::setup怎么用?PHP DynamicField::setup使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DynamicField
的用法示例。
在下文中一共展示了DynamicField::setup方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setUp
public function setUp()
{
SugarTestHelper::setUp('beanList');
SugarTestHelper::setUp('beanFiles');
SugarTestHelper::setUp('app_strings');
SugarTestHelper::setUp('app_list_strings');
SugarTestHelper::setUp('mod_strings', array('ModuleBuilder'));
SugarTestHelper::setUp('current_user', array(true, 1));
$_POST = $_REQUEST = $this->getPostData();
$this->accountFieldWidget = get_widget($_REQUEST['type']);
$this->accountFieldWidget->populateFromPost();
$module = $_REQUEST['view_module'];
$this->accountField = new DynamicField($module);
$class_name = $GLOBALS['beanList'][$module];
require_once $GLOBALS['beanFiles'][$class_name];
$mod = new $class_name();
$this->accountField->setup($mod);
$this->accountFieldWidget->save($this->accountField);
$_POST['view_module'] = $_REQUEST['view_module'] = 'Opportunities';
$this->opportunityFieldWidget = get_widget($_REQUEST['type']);
$this->opportunityFieldWidget->populateFromPost();
$module = $_REQUEST['view_module'];
$this->opportunityField = new DynamicField($module);
$class_name = $GLOBALS['beanList'][$module];
require_once $GLOBALS['beanFiles'][$class_name];
$mod = new $class_name();
$this->opportunityField->setup($mod);
$this->opportunityFieldWidget->save($this->opportunityField);
$repair = new RepairAndClear();
$repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs'), array($GLOBALS['beanList']['Accounts'], $GLOBALS['beanList']['Opportunities']), true, false);
}
示例2: setUp
/**
* Creating new field, account, contact with filled custom field, relationship between them
*/
public function setUp()
{
SugarTestHelper::setUp('beanList');
SugarTestHelper::setUp('beanFiles');
SugarTestHelper::setUp('current_user', array(true, true));
$this->field = get_widget('varchar');
$this->field->id = 'Contactstest_c';
$this->field->name = 'test_c';
$this->field->type = 'varchar';
$this->field->len = 255;
$this->field->importable = 'true';
$this->field->label = '';
$this->module = new Contact();
$this->dynamicField = new DynamicField('Contacts');
$this->dynamicField->setup($this->module);
$this->dynamicField->addFieldObject($this->field);
SugarTestHelper::setUp('dictionary');
$GLOBALS['reload_vardefs'] = true;
$this->account = SugarTestAccountUtilities::createAccount();
$this->contact = SugarTestContactUtilities::createContact();
$this->contact->account_id = $this->account->id;
$this->contact->test_c = 'test value';
$this->contact->load_relationship('accounts');
$this->contact->accounts->add($this->account->id);
$this->contact->save();
$GLOBALS['db']->commit();
}
示例3: createCustomField
/**
* Create the custom field with type 'relate'
*/
protected function createCustomField()
{
$field = get_widget('relate');
$field->id = 'Contacts' . $this->field_name_c;
$field->name = $this->field_name_c;
$field->type = 'relate';
$field->label = 'LBL_' . strtoupper($this->field_name_c);
$field->ext2 = 'Accounts';
$field->view_module = 'Contacts';
$this->relateField = $field;
$this->bean = BeanFactory::getBean('Contacts');
$this->df = new DynamicField($this->bean->module_name);
$this->df->setup($this->bean);
$field->save($this->df);
$this->rc = new RepairAndClear();
$this->rc->repairAndClearAll(array("rebuildExtensions", "clearVardefs"), array('Contact'), false, false);
}
示例4: array
function uninstall_relationships($include_studio_relationships = false)
{
$relationships = array();
//Find and remove studio created relationships.
global $beanList, $beanFiles, $dictionary;
//Load up the custom relationship definitions.
if (file_exists('custom/application/Ext/TableDictionary/tabledictionary.ext.php')) {
include 'custom/application/Ext/TableDictionary/tabledictionary.ext.php';
}
//Find all the relatioships/relate fields involving this module.
$rels_to_remove = array();
foreach ($beanList as $mod => $bean) {
//Some modules like cases have a bean name that doesn't match the object name
$bean = BeanFactory::getObjectName($mod);
VardefManager::loadVardef($mod, $bean);
//We can skip modules that are in this package as they will be removed anyhow
if (!in_array($mod, $this->modulesInPackage) && !empty($dictionary[$bean]) && !empty($dictionary[$bean]['fields'])) {
$field_defs = $dictionary[$bean]['fields'];
foreach ($field_defs as $field => $def) {
//Weed out most fields first
if (isset($def['type'])) {
//Custom relationships created in the relationship editor
if ($def['type'] == "link" && !empty($def['relationship']) && !empty($dictionary[$def['relationship']])) {
$rel_name = $def['relationship'];
$rel_def = $dictionary[$rel_name]['relationships'][$rel_name];
//Check against mods to be removed.
foreach ($this->modulesInPackage as $removed_mod) {
if ($rel_def['lhs_module'] == $removed_mod || $rel_def['rhs_module'] == $removed_mod) {
$dictionary[$rel_name]['from_studio'] = true;
$relationships[$rel_name] = $dictionary[$rel_name];
}
}
}
//Custom "relate" fields created in studio also need to be removed
if ($def['type'] == 'relate' && isset($def['module'])) {
foreach ($this->modulesInPackage as $removed_mod) {
if ($def['module'] == $removed_mod) {
require_once 'modules/ModuleBuilder/Module/StudioModule.php';
$studioMod = new StudioModule($mod);
$studioMod->removeFieldFromLayouts($field);
if (isset($def['custom_module'])) {
require_once 'modules/DynamicFields/DynamicField.php';
require_once $beanFiles[$bean];
$seed = new $bean();
$df = new DynamicField($mod);
$df->setup($seed);
//Need to load the entire field_meta_data for some field types
$field_obj = $df->getFieldWidget($mod, $field);
$field_obj->delete($df);
}
}
}
}
}
}
}
}
$this->uninstall_relationship(null, $relationships);
if (isset($this->installdefs['relationships'])) {
$relationships = $this->installdefs['relationships'];
$this->log(translate('LBL_MI_UN_RELATIONSHIPS'));
foreach ($relationships as $relationship) {
// remove the metadata entry
$filename = basename($relationship['meta_data']);
$pathname = file_exists("custom/metadata/{$filename}") ? "custom/metadata/{$filename}" : "metadata/{$filename}";
if (isset($GLOBALS['mi_remove_tables']) && $GLOBALS['mi_remove_tables']) {
$this->uninstall_relationship($pathname);
}
if (file_exists($pathname)) {
unlink($pathname);
}
}
}
if (file_exists("custom/Extension/application/Ext/TableDictionary/{$this->id_name}.php")) {
unlink("custom/Extension/application/Ext/TableDictionary/{$this->id_name}.php");
}
Relationship::delete_cache();
$this->rebuild_tabledictionary();
}
示例5: DynamicField
* SugarCRM" logo. If the display of the logo is not reasonably feasible for
* technical reasons, the Appropriate Legal Notices must display the words
* "Powered by SugarCRM".
********************************************************************************/
require_once 'modules/DynamicFields/DynamicField.php';
$module = $_REQUEST['module_name'];
$custom_fields = new DynamicField($module);
if (!empty($module)) {
$class_name = $beanList[$module];
$class_file = $class_name;
if ($class_file == 'aCase') {
$class_file = 'Case';
}
require_once "modules/{$module}/{$class_file}.php";
$mod = new $class_name();
$custom_fields->setup($mod);
} else {
echo "\nNo Module Included Could Not Save";
}
$name = $_REQUEST['field_label'];
$options = '';
if ($_REQUEST['field_type'] == 'enum') {
$options = $_REQUEST['options'];
}
$default_value = '';
$custom_fields->addField($name, $name, $_REQUEST['field_type'], '255', 'optional', $default_value, $options, '', '');
$html = $custom_fields->getFieldHTML($name, $_REQUEST['file_type']);
set_register_value('dyn_layout', 'field_counter', $_REQUEST['field_count']);
$label = $custom_fields->getFieldLabelHTML($name, $_REQUEST['field_type']);
require_once 'modules/DynamicLayout/AddField.php';
$af = new AddField();
示例6: DynamicField
function action_DeleteField()
{
require_once 'modules/DynamicFields/FieldCases.php';
$field = get_widget($_POST['type']);
$field->name = $_REQUEST['name'];
if (!isset($_REQUEST['view_package'])) {
if (!empty($_REQUEST['name']) && !empty($_REQUEST['view_module'])) {
require_once 'modules/DynamicFields/DynamicField.php';
$moduleName = $_REQUEST['view_module'];
$class_name = $GLOBALS['beanList'][$moduleName];
require_once $GLOBALS['beanFiles'][$class_name];
$seed = new $class_name();
$df = new DynamicField($moduleName);
$df->setup($seed);
//Need to load the entire field_meta_data for some field types
$field = $df->getFieldWidget($moduleName, $field->name);
$field->delete($df);
require_once 'modules/ModuleBuilder/Module/StudioModule.php';
$module = new StudioModule($moduleName);
}
} else {
$mb = new ModuleBuilder();
$module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']);
$field->delete($module);
$mb->save();
}
$module->removeFieldFromLayouts($field->name);
$this->view = 'modulefields';
}
示例7: DynamicField
function action_DeleteField()
{
require_once 'modules/DynamicFields/FieldCases.php';
$field = get_widget($_REQUEST['type']);
$field->name = $_REQUEST['name'];
if (!isset($_REQUEST['view_package'])) {
if (!empty($_REQUEST['name']) && !empty($_REQUEST['view_module'])) {
require_once 'modules/DynamicFields/DynamicField.php';
$moduleName = $_REQUEST['view_module'];
// bug 51325 make sure we make this switch or delete will not work
if ($moduleName == 'Employees') {
$moduleName = 'Users';
}
$class_name = $GLOBALS['beanList'][$moduleName];
require_once $GLOBALS['beanFiles'][$class_name];
$seed = new $class_name();
$df = new DynamicField($moduleName);
$df->setup($seed);
//Need to load the entire field_meta_data for some field types
$field = $df->getFieldWidget($moduleName, $field->name);
$field->delete($df);
$GLOBALS['mod_strings']['LBL_ALL_MODULES'] = 'all_modules';
$_REQUEST['execute_sql'] = true;
include_once 'modules/Administration/QuickRepairAndRebuild.php';
$repair = new RepairAndClear();
$repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($class_name), true, false);
require_once 'modules/ModuleBuilder/Module/StudioModuleFactory.php';
$module = StudioModuleFactory::getStudioModule($moduleName);
}
} else {
$mb = new ModuleBuilder();
$module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']);
$field = $module->getField($field->name);
$field->delete($module);
$mb->save();
}
$module->removeFieldFromLayouts($field->name);
$this->view = 'modulefields';
if (isset($GLOBALS['current_language']) && isset($_REQUEST['label']) && isset($_REQUEST['labelValue']) && isset($_REQUEST['view_module'])) {
$this->DeleteLabel($GLOBALS['current_language'], $_REQUEST['label'], $_REQUEST['labelValue'], $_REQUEST['view_module']);
}
}
示例8: removeCustomFields
/**
* Removes all custom fields created in studio
*
* @return html output record of the field deleted
*/
function removeCustomFields()
{
$moduleName = $this->module;
$class_name = $GLOBALS['beanList'][$moduleName];
require_once $GLOBALS['beanFiles'][$class_name];
$seed = new $class_name();
$df = new DynamicField($moduleName);
$df->setup($seed);
$module = StudioModuleFactory::getStudioModule($moduleName);
$customFields = array();
foreach ($seed->field_defs as $def) {
if (isset($def['source']) && $def['source'] == 'custom_fields') {
$field = $df->getFieldWidget($moduleName, $def['name']);
$field->delete($df);
$module->removeFieldFromLayouts($def['name']);
$customFields[] = $def['name'];
}
}
$out = "";
foreach ($customFields as $field) {
$out .= "Removed field {$field}<br/>";
}
return $out;
}
示例9: upgradeVardefsInDeployedModules
/**
* Find custom address fields added to modules that modulebuilder created and deployed
*/
public function upgradeVardefsInDeployedModules()
{
//Created for access to a field's vardef_map
$tempField = new TemplateField();
foreach (glob('modules/*/vardefs.php') as $file) {
//Get module name from file name
$fileParts = explode('/', $file);
$module = $fileParts[1];
require $file;
if (!empty($dictionary[$module]['fields'])) {
//Set up vardef extension save mechanism
$bean = BeanFactory::getBean($module);
if (empty($bean)) {
continue;
}
$df = new DynamicField($module);
$df->setup($bean);
//Find all custom street fields
foreach ($dictionary[$module]['fields'] as $fieldName => $field) {
if ($this->validateStreetField($dictionary[$module]['fields'], $fieldName)) {
$upgradeField = new stdClass();
$upgradeField->type = 'text';
$upgradeField->dbType = 'varchar';
$upgradeField->name = $fieldName;
$upgradeField->vardef_map = $tempField->vardef_map;
$upgradeField->vardef_map['dbType'] = 'dbType';
$df->saveExtendedAttributes($upgradeField, array());
}
}
}
}
}
示例10: action_DeleteField
public function action_DeleteField()
{
$field = get_widget($_REQUEST['type']);
$field->name = $_REQUEST['name'];
if (!isset($_REQUEST['view_package'])) {
if (!empty($_REQUEST['name']) && !empty($_REQUEST['view_module'])) {
$moduleName = $_REQUEST['view_module'];
// bug 51325 make sure we make this switch or delete will not work
if ($moduleName == 'Employees') {
$moduleName = 'Users';
}
$seed = BeanFactory::getBean($moduleName);
$df = new DynamicField($moduleName);
$df->setup($seed);
//Need to load the entire field_meta_data for some field types
$field = $df->getFieldWidget($moduleName, $field->name);
$field->delete($df);
$GLOBALS['mod_strings']['LBL_ALL_MODULES'] = 'all_modules';
$_REQUEST['execute_sql'] = true;
include_once 'modules/Administration/QuickRepairAndRebuild.php';
$repair = new RepairAndClear();
$repair->repairAndClearAll(array('rebuildExtensions', 'clearVardefs', 'clearTpls'), array($moduleName), true, false);
require_once 'modules/ModuleBuilder/Module/StudioModuleFactory.php';
$module = StudioModuleFactory::getStudioModule($moduleName);
}
} else {
$mb = new ModuleBuilder();
$module =& $mb->getPackageModule($_REQUEST['view_package'], $_REQUEST['view_module']);
$field = $module->getField($field->name);
$field->delete($module);
$mb->save();
}
$module->removeFieldFromLayouts($field->name);
$this->view = 'modulefields';
if (isset($GLOBALS['current_language']) && isset($_REQUEST['label']) && isset($_REQUEST['labelValue']) && isset($_REQUEST['view_module'])) {
$this->DeleteLabel($GLOBALS['current_language'], $_REQUEST['label'], $_REQUEST['labelValue'], $_REQUEST['view_module']);
$this->metadataApiCacheCleared = true;
}
// Clear the metadata cache if it hasn't been done already
if (!$this->metadataApiCacheCleared && !empty($moduleName)) {
// This removes the labels associated with the field and rebuilds
// the api cache for the module
$repair->module_list = array($moduleName);
$repair->repairMetadataAPICache('labels');
}
}
示例11: die
<?php
if (!defined('sugarEntry') || !sugarEntry) {
die('Not A Valid Entry Point');
}
/*********************************************************************************
* The contents of this file are subject to the SugarCRM Public License Version
* 1.1.3 ("License"); You may not use this file except in compliance with the
* License. You may obtain a copy of the License at http://www.sugarcrm.com/SPL
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* All copies of the Covered Code must include on each user interface screen:
* (i) the "Powered by SugarCRM" logo and
* (ii) the SugarCRM copyright notice
* in the same form as they appear in the distribution. See full license for
* requirements.
*
* The Original Code is: SugarCRM Open Source
* The Initial Developer of the Original Code is SugarCRM, Inc.
* Portions created by SugarCRM are Copyright (C) 2004-2006 SugarCRM, Inc.;
* All Rights Reserved.
* Contributor(s): ______________________________________.
********************************************************************************/
// adding custom fields:
require_once 'modules/DynamicFields/DynamicField.php';
$custom_fields = new DynamicField();
$custom_fields->setup($focus);
$custom_fields->populateXTPL($xtpl, 'detail');
示例12: DynamicField
if ($fileType != 'other') {
require_once 'modules/DynamicFields/DynamicField.php';
if (!empty($_REQUEST['mod_class'])) {
$temp_mod = $_REQUEST['mod_class'];
$class_name = $beanList[$temp_mod];
$class_file = $beanFiles[$class_name];
require_once $class_file;
$customFields = new DynamicField($temp_mod);
} else {
$class_name = $beanList[$the_module];
$class_file = $beanFiles[$class_name];
require_once $class_file;
$customFields = new DynamicField($the_module);
}
$mod = new $class_name();
$customFields->setup($mod);
$result = $customFields->getAllBeanFieldsView($fileType, 'html');
foreach ($result as $f_name => $f_field) {
$addfield->add_field($f_name, $f_field['html'], $f_field['label'], '', 'sugar_fields_MSI');
}
}
$deleteFields->load_deleted_fields();
foreach ($deleteFields->deleted_fields as $dl) {
$addfield->add_deleted_field($dl);
}
$sp->parse_file($file);
echo $sp->get_javascript_swap();
//$view = str_replace('<!-- END: main -->', $addfield->get_script()."\n<!-- END: main -->", $sp->get_edit_view() );
echo $addfield->get_script();
$view = $sp->get_edit_view();
$slotCount = sizeof($sp->slots);
示例13: setupCustomFields
/**
* Loads the definition of custom fields defined for the module.
* Local file system cache is created as needed.
*
* @param string $module_name setting up custom fields for this module.
* @param boolean $clean_load Optional, default true, rebuilds the cache if set to true.
*/
public function setupCustomFields($module_name, $clean_load = true)
{
$this->custom_fields = new DynamicField($module_name);
$this->custom_fields->setup($this);
}
示例14: removeCustomFields
/**
* Removes all custom fields created in studio
*
* @return html output record of the field deleted
*/
function removeCustomFields()
{
$moduleName = $this->module;
$seed = BeanFactory::getBean($moduleName);
$df = new DynamicField($moduleName);
$df->setup($seed);
$module = StudioModuleFactory::getStudioModule($moduleName);
$customFields = array();
foreach ($seed->field_defs as $def) {
if (isset($def['custom_module']) && $def['custom_module'] === $moduleName) {
$field = $df->getFieldWidget($moduleName, $def['name']);
// the field may have already been deleted
if ($field) {
$field->delete($df);
}
$module->removeFieldFromLayouts($def['name']);
$customFields[] = $def['name'];
}
}
$out = "";
foreach ($customFields as $field) {
$out .= "Removed field {$field}<br/>";
}
return $out;
}
示例15: CustomFieldsTableSchema
$custom_fields_table_schema = new CustomFieldsTableSchema($custom_table_name);
if (!CustomFieldsTableSchema::custom_table_exists($custom_table_name)) {
$custom_fields_table_schema->create_table();
}
$column_name = $fields_meta_data->name;
$field_label = $fields_meta_data->label;
$data_type = $fields_meta_data->data_type;
$max_size = $fields_meta_data->max_size;
$required = $fields_meta_data->required_option;
$default_value = $fields_meta_data->default_value;
$module_dir = $fields_meta_data->custom_module;
if ($new_field) {
$custom_fields_table_schema->add_column($column_name, $data_type, $required, $default_value);
$class_name = $beanList[$fields_meta_data->custom_module];
$custom_field = new DynamicField($fields_meta_data->custom_module);
require_once "modules/{$module_dir}/{$class_name}.php";
$sugarbean_module = new $class_name();
$custom_field->setup($sugarbean_module);
$custom_field->addField($field_label, $data_type, $max_size, 'optional', $default_value, '', '');
}
if (isset($_REQUEST['form'])) {
// we are doing the save from a popup window
echo '<script>opener.window.location.reload();self.close();</script>';
die;
} else {
// need to refresh the page properly
$return_module = empty($_REQUEST['return_module']) ? 'EditCustomFields' : $_REQUEST['return_module'];
$return_action = empty($_REQUEST['return_action']) ? 'index' : $_REQUEST['return_action'];
$return_module_select = empty($_REQUEST['return_module_select']) ? 0 : $_REQUEST['return_module_select'];
header("Location: index.php?action={$return_action}&module={$return_module}&module_select={$return_module_select}");
}