本文整理汇总了PHP中DynamicField类的典型用法代码示例。如果您正苦于以下问题:PHP DynamicField类的具体用法?PHP DynamicField怎么用?PHP DynamicField使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DynamicField类的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: testGetRelateJoin
public function testGetRelateJoin()
{
require_once 'modules/DynamicFields/DynamicField.php';
$dynamicField = new DynamicField();
$account = new Account();
$dynamicField->bean = $account;
$field_def = array('dependency' => '', 'required' => '', 'source' => 'non-db', 'name' => 'm1_related_c', 'vname' => 'LBL_M1_RELATED', 'type' => 'relate', 'massupdate' => 0, 'default' => '', 'comments' => '', 'help' => '', 'importable' => true, 'duplicate_merge' => 'disabled', 'duplicate_merge_dom_value' => 0, 'audited' => '', 'reportable' => 1, 'calculated' => '', 'len' => 255, 'size' => 20, 'id_name' => 'def_m1_id_c', 'ext2' => 'Accounts', 'module' => 'Accounts', 'rname' => 'name', 'quicksearch' => 'enabled', 'studio' => 'visible', 'id' => 'def_M1m1_related_c', 'custom_module' => 'Accounts');
$joinTableAlias = 'jt1';
$relatedJoinInfo = $dynamicField->getRelateJoin($field_def, $joinTableAlias);
//echo var_export($relatedJoinInfo, true);
$this->assertEquals(', accounts_cstm.def_m1_id_c, jt1.name m1_related_c ', $relatedJoinInfo['select']);
}
示例3: testSaveUsersVardefs
public function testSaveUsersVardefs()
{
global $dictionary;
$dynamicField = new DynamicField('Users');
VardefManager::loadVardef('Users', 'User');
$dynamicField->saveToVardef('Users', $dictionary['User']['fields']);
//Test that we have refreshed the Employees vardef
$this->assertTrue(file_exists('cache/modules/Employees/Employeevardefs.php'), 'cache/modules/Employees/Emloyeevardefs.php file not created');
//Test that status is not set to be required
$this->assertFalse($dictionary['Employee']['fields']['status']['required'], 'status field set to required');
//Test that the studio attribute is set to false for status field
$this->assertFalse($dictionary['Employee']['fields']['status']['studio'], 'status field studio not set to false');
}
示例4: 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);
}
示例5: process
function process($option)
{
switch ($option) {
case 'ViewCustomFields':
parent::process($option);
require_once 'modules/Studio/EditCustomFields/ListView.php';
break;
case 'CreateCustomFields':
if (empty($_REQUEST['to_pdf'])) {
parent::process($option);
}
require_once 'modules/Studio/EditCustomFields/EditView.php';
break;
case 'SaveCustomField':
require_once 'modules/Studio/EditCustomFields/Save.php';
break;
case 'DeleteCustomField':
require_once 'modules/Studio/EditCustomFields/Delete.php';
break;
case 'EditCustomField':
parent::process($option);
require_once 'modules/Studio/EditCustomFields/EditView.php';
break;
case 'ClearCache':
require_once 'modules/DynamicFields/DynamicField.php';
DynamicField::deleteCache();
echo '<script>YAHOO.util.Event.addListener(window, "load", function(){ajaxStatus.showStatus("cache cleared");window.setTimeout(\'ajaxStatus.hideStatus();\', 2000);});</script>';
parent::process($option);
break;
case 'RepairCustomFields':
header('Location: index.php?module=Administration&action=UpgradeFields');
sugar_cleanup(true);
default:
parent::process($option);
}
}
示例6: saveIdLabel
/**
* Save label for id field
*
* @param string $idLabelName
* @param DynamicField $df
*/
protected function saveIdLabel($idLabelName, $df)
{
if ($df instanceof DynamicField) {
$module = $df->module;
} elseif ($df instanceof MBModule) {
$module = $df->name;
} else {
Log::fatal('Unsupported DynamicField type');
}
$viewPackage = isset($df->package) ? $df->package : null;
$idLabelValue = string_format($GLOBALS['mod_strings']['LBL_RELATED_FIELD_ID_NAME_LABEL'], array($this->label_value, $GLOBALS['app_list_strings']['moduleListSingular'][$this->ext2]));
$idFieldLabelArr = array("label_{$idLabelName}" => $idLabelValue);
foreach (ModuleBuilder::getModuleAliases($module) as $moduleName) {
if ($df instanceof DynamicField) {
$parser = new ParserLabel($moduleName, $viewPackage);
$parser->handleSave($idFieldLabelArr, $GLOBALS['current_language']);
} elseif ($df instanceof MBModule) {
$df->setLabel($GLOBALS['current_language'], $idLabelName, $idLabelValue);
$df->save();
}
}
}
示例7: __construct
function __construct($module = '')
{
parent::DynamicField($module);
}
示例8: refreshVardefs
/**
* Given a module, search all of the specified locations, and any others as specified
* in order to refresh the cache file
*
* @param string $module the given module we want to load the vardefs for
* @param string $object the given object we wish to load the vardefs for
* @param array $additional_search_paths an array which allows a consumer to pass in additional vardef locations to search
*/
static function refreshVardefs($module, $object, $additional_search_paths = null, $cacheCustom = true, $params = array())
{
// Some of the vardefs do not correctly define dictionary as global. Declare it first.
global $dictionary, $beanList;
$vardef_paths = array('modules/' . $module . '/vardefs.php', 'custom/modules/' . $module . '/Ext/Vardefs/vardefs.ext.php', 'custom/Extension/modules/' . $module . '/Ext/Vardefs/vardefs.php');
// Add in additional search paths if they were provided.
if (!empty($additional_search_paths) && is_array($additional_search_paths)) {
$vardef_paths = array_merge($vardef_paths, $additional_search_paths);
}
$found = false;
//search a predefined set of locations for the vardef files
foreach ($vardef_paths as $path) {
if (file_exists($path)) {
require $path;
$found = true;
}
}
//Some modules have multiple beans, we need to see if this object has a module_dir that is different from its module_name
if (!$found) {
$temp = BeanFactory::newBean($module);
if ($temp) {
$object_name = BeanFactory::getObjectName($temp->module_dir);
if ($temp && $temp->module_dir != $temp->module_name && !empty($object_name)) {
self::refreshVardefs($temp->module_dir, $object_name, $additional_search_paths, $cacheCustom);
}
}
}
//Some modules like cases have a bean name that doesn't match the object name
if (empty($dictionary[$object])) {
$newName = BeanFactory::getObjectName($module);
$object = $newName != false ? $newName : $object;
}
//load custom fields into the vardef cache
if ($cacheCustom) {
require_once "modules/DynamicFields/DynamicField.php";
$df = new DynamicField($module);
$df->buildCache($module, false);
}
//great! now that we have loaded all of our vardefs.
//let's go save them to the cache file.
if (!empty($dictionary[$object])) {
VardefManager::saveCache($module, $object);
}
}
示例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: 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;
}
示例11: FieldsMetaData
* Section 5 of the GNU General Public License version 3.
*
* In accordance with Section 7(b) of the GNU General Public License version 3,
* these Appropriate Legal Notices must retain the display of the "Powered by
* 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/EditCustomFields/EditCustomFields.php';
require_once 'modules/DynamicFields/DynamicField.php';
require_once 'modules/DynamicFields/DynamicField.php';
if (!empty($_REQUEST['record'])) {
$fields_meta_data = new FieldsMetaData($_REQUEST['record']);
$fields_meta_data->retrieve($_REQUEST['record']);
$module = $fields_meta_data->custom_module;
$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 Delete";
}
$custom_fields->deleteField($fields_meta_data->name);
$fields_meta_data->mark_deleted($_REQUEST['record']);
}
示例12: 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');
示例13: uninstall_relationships
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();
}
示例14: drop_tables
/**
* Delete the primary table for the module implementing the class.
* If custom fields were added to this table/module, the custom table will be removed too, along with the cache
* entries that define the custom fields.
*
*/
function drop_tables()
{
global $dictionary;
$key = $this->getObjectName();
if (!array_key_exists($key, $dictionary)) {
$GLOBALS['log']->fatal("drop_tables: Metadata for table " . $this->table_name . " does not exist");
echo "meta data absent for table " . $this->table_name . "<br>\n";
} else {
if (empty($this->table_name)) {
return;
}
if ($this->db->tableExists($this->table_name)) {
$this->dbManager->dropTable($this);
}
if ($this->db->tableExists($this->table_name . '_cstm')) {
$this->dbManager->dropTableName($this->table_name . '_cstm');
DynamicField::deleteCache();
}
if ($this->db->tableExists($this->get_audit_table_name())) {
$this->dbManager->dropTableName($this->get_audit_table_name());
}
}
}
示例15: strtolower
$custom_table_name = strtolower($fields_meta_data->custom_module) . '_cstm';
$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}");