本文整理汇总了PHP中SugarFieldHandler::getSugarField方法的典型用法代码示例。如果您正苦于以下问题:PHP SugarFieldHandler::getSugarField方法的具体用法?PHP SugarFieldHandler::getSugarField怎么用?PHP SugarFieldHandler::getSugarField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SugarFieldHandler
的用法示例。
在下文中一共展示了SugarFieldHandler::getSugarField方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: normalizeFieldDefs
/**
* Cleans field def default values before returning them as a member of the
* metadata response payload
*
* Bug 56505
* Cleans default value of fields to strip out metacharacters used by the app.
* Used initially for cleaning default multienum values.
*
* @param array $fielddefs
* @return array
*/
public function normalizeFieldDefs(array $defs)
{
$this->getSugarFieldHandler();
foreach ($defs['fields'] as $name => $def) {
if (isset($def['type'])) {
$type = !empty($def['custom_type']) ? $def['custom_type'] : $def['type'];
$field = $this->sfh->getSugarField($type);
$defs['fields'][$name] = $field->getNormalizedDefs($def, $defs);
}
}
return $defs['fields'];
}
示例2: testEmailTemplateFormat
/**
* @dataProvider _providerEmailTemplateFormat
*/
public function testEmailTemplateFormat($unformattedValue, $expectedValue)
{
require_once 'include/SugarFields/SugarFieldHandler.php';
$sfr = SugarFieldHandler::getSugarField('encrypt');
$formattedValue = $sfr->getEmailTemplateValue($unformattedValue, array(), array('notify_user' => $GLOBALS['current_user']));
$this->assertEquals($expectedValue, $formattedValue);
}
示例3: process_reports
private function process_reports()
{
require_once 'include/SugarFields/SugarFieldHandler.php';
$sfh = new SugarFieldHandler();
$sf = $sfh->getSugarField('Teamset', true);
$teams = $sf->getTeamsFromRequest($this->name);
$full_form_values = array();
if (!empty($teams)) {
if (isset($_REQUEST["primary_{$this->name}_collection"])) {
$this->ss->assign('hasPrimaryTeam', true);
$primary = $_REQUEST["primary_{$this->name}_collection"];
$key = "id_{$this->name}_collection_{$primary}";
//Get the $_REQUEST index key
$primary = $_REQUEST[$key];
$primaryTeam = array('id' => $primary, 'name' => $teams[$primary]);
$full_form_values['primary'] = $primaryTeam;
unset($teams[$primary]);
//Unset the primary team
} else {
//Here we technically don't have a primary team chosen, but we need to allocate
//a primary team to display as the first team in the widget
foreach ($teams as $team_id => $team_name) {
$full_form_values['primary'] = array('id' => $team_id, 'name' => $team_name);
$this->showPrimaryChecked = false;
unset($teams[$team_id]);
break;
}
}
foreach ($teams as $team_id => $team_name) {
$full_form_values['secondaries'][] = array('id' => $team_id, 'name' => $team_name);
}
$this->bean->{$this->value_name} = array_merge($this->bean->{$this->value_name}, $full_form_values);
}
}
示例4: __call
/**
* Checks the SugarField defintion for an available santization method.
*
* @param $value string
* @param $vardef array
* @param $focus object bean of the module we're importing into
* @return string sanitized and validated value on success, bool false on failure
*/
public function __call($name, $params)
{
static $sfh;
if (!isset($sfh)) {
require_once 'include/SugarFields/SugarFieldHandler.php';
$sfh = new SugarFieldHandler();
}
$value = $params[0];
$vardef = $params[1];
if (isset($params[2])) {
$focus = $params[2];
} else {
$focus = null;
}
if ($name == 'relate' && !empty($params[3])) {
$this->addRelatedBean = true;
} else {
$this->addRelatedBean = false;
}
$field = $sfh->getSugarField(ucfirst($name));
if ($field instanceof SugarFieldBase) {
$value = $field->importSanitize($value, $vardef, $focus, $this);
}
return $value;
}
示例5: getFile
/**
* Gets a file and returns an HTTP response with the contents of the request file for download
*
* @param SugarBean $bean The SugarBean to get the file for
* @param string $field The field name to get the file for
* @param boolean $forceDownload force to download the file if true.
*/
public function getFile(SugarBean $bean, $field, $forceDownload = false)
{
if ($this->validateBeanAndField($bean, $field, 'file') || $this->validateBeanAndField($bean, $field, 'image')) {
$def = $bean->field_defs[$field];
if ($def['type'] == 'image') {
$info = $this->getImageInfo($bean, $field);
} elseif ($def['type'] == 'file') {
$info = $this->getFileInfo($bean, $field);
require_once 'include/SugarFields/SugarFieldHandler.php';
$sfh = new SugarFieldHandler();
/* @var $sf SugarFieldFile */
$sf = $sfh->getSugarField($def['type']);
//If the requested file is not a supported image type, we should force a download.
if (!$forceDownload && !in_array($info['content-type'], $sf::$imageFileMimeTypes)) {
$forceDownload = true;
}
}
if ($info) {
$this->outputFile($forceDownload, $info);
} else {
// @TODO Localize this exception message
throw new Exception('File information could not be retrieved for this record');
}
}
}
示例6: smarty_function_sugarvar_teamset
function smarty_function_sugarvar_teamset($params, &$smarty)
{
require_once 'include/SugarFields/SugarFieldHandler.php';
$sfh = new SugarFieldHandler();
$sugarField = $sfh->getSugarField('Teamset');
return $sugarField->render($params, $smarty);
}
示例7: populateFromPost
function populateFromPost($prefix, &$focus, $skipRetrieve = false)
{
global $current_user;
if (!empty($_REQUEST[$prefix . 'record']) && !$skipRetrieve) {
$focus->retrieve($_REQUEST[$prefix . 'record']);
}
if (!empty($_POST['assigned_user_id']) && $focus->assigned_user_id != $_POST['assigned_user_id'] && $_POST['assigned_user_id'] != $current_user->id) {
$GLOBALS['check_notify'] = true;
}
require_once 'include/SugarFields/SugarFieldHandler.php';
$sfh = new SugarFieldHandler();
foreach ($focus->field_defs as $field => $def) {
$type = !empty($def['custom_type']) ? $def['custom_type'] : $def['type'];
$sf = $sfh->getSugarField(ucfirst($type), true);
if ($sf != null) {
$sf->save($focus, $_POST, $field, $def);
}
if (isset($_POST[$prefix . $field])) {
if (is_array($_POST[$prefix . $field]) && !empty($focus->field_defs[$field]['isMultiSelect'])) {
if (empty($_POST[$prefix . $field][0])) {
unset($_POST[$prefix . $field][0]);
}
if (!empty($_POST[$prefix . $field][0])) {
$_POST[$prefix . $field] = implode('^,^', $_POST[$prefix . $field]);
} else {
continue;
}
}
$focus->{$field} = $_POST[$prefix . $field];
/*
* overrides the passed value for booleans.
* this will be fully deprecated when the change to binary booleans is complete.
*/
if (isset($focus->field_defs[$prefix . $field]) && $focus->field_defs[$prefix . $field]['type'] == 'bool' && isset($focus->field_defs[$prefix . $field]['options'])) {
$opts = explode("|", $focus->field_defs[$prefix . $field]['options']);
$bool = $_POST[$prefix . $field];
if (is_int($bool) || ($bool === "0" || $bool === "1" || $bool === "2")) {
// 1=on, 2=off
$selection = $_POST[$prefix . $field] == "0" ? 1 : 0;
} elseif (is_bool($_POST[$prefix . $field])) {
// true=on, false=off
$selection = $_POST[$prefix . $field] ? 0 : 1;
}
$focus->{$field} = $opts[$selection];
}
} else {
if (!empty($focus->field_defs[$field]['isMultiSelect']) && !isset($_POST[$prefix . $field]) && isset($_POST[$prefix . $field . '_multiselect'])) {
$focus->{$field} = '';
}
}
}
foreach ($focus->additional_column_fields as $field) {
if (isset($_POST[$prefix . $field])) {
$value = $_POST[$prefix . $field];
$focus->{$field} = $value;
}
}
return $focus;
}
示例8: testEmailTemplateFormat
/**
* @dataProvider _providerEmailTemplateFormat
*/
public function testEmailTemplateFormat($unformattedValue, $expectedValue, $dateFormat, $timeFormat)
{
$GLOBALS['sugar_config']['default_date_format'] = $dateFormat;
$GLOBALS['sugar_config']['default_time_format'] = $timeFormat;
$this->user->setPreference('datef', $dateFormat);
$this->user->setPreference('timef', $timeFormat);
require_once 'include/SugarFields/SugarFieldHandler.php';
$sfr = SugarFieldHandler::getSugarField('datetimecombo');
$formattedValue = $sfr->getEmailTemplateValue($unformattedValue, array(), array('notify_user' => $this->user));
$this->assertEquals($expectedValue, $formattedValue);
}
示例9: testFormatEnumField
/**
* @ticket 36744
*/
public function testFormatEnumField()
{
$langpack = new SugarTestLangPackCreator();
$langpack->setAppListString('case_priority_dom', array('P1' => 'High', 'P2' => 'Medium', 'P3' => 'Low'));
$langpack->save();
$GLOBALS['app_list_strings'] = return_app_list_strings_language($GLOBALS['current_language']);
$fieldDef = array('name' => 'priority', 'vname' => 'LBL_PRIORITY', 'type' => 'enum', 'options' => 'case_priority_dom', 'len' => 25, 'audited' => true, 'comment' => 'The priority of the case');
$field_value = "P2";
require_once 'include/SugarFields/SugarFieldHandler.php';
$sfr = SugarFieldHandler::getSugarField('enum');
$this->assertEquals(trim($sfr->formatField($field_value, $fieldDef)), 'Medium');
}
示例10: setUp
public function setUp()
{
$enumField = SugarFieldHandler::getSugarField('enum');
$parentFieldArray = array('ACCEPT_STATUS_NAME' => 'Accepted');
$vardef = array('name' => 'accept_status_name', 'type' => 'enum', 'source' => 'non-db', 'vname' => 'LBL_LIST_ACCEPT_STATUS', 'options' => 'dom_meeting_accept_status', 'massupdate' => false, 'studio' => array('listview' => false, 'searchview' => false));
$displayParams = array('vname' => 'LBL_LIST_ACCEPT_STATUS', 'width' => '11%', 'sortable' => false, 'linked_field' => 'users', 'linked_field_set' => 'users', 'name' => 'accept_status_name', 'module' => 'Users');
$col = 1;
$this->_listViewSmartyOutput1 = trim($enumField->getListViewSmarty($parentFieldArray, $vardef, $displayParams, $col));
$vardef['name'] = 'just_another_name';
$parentFieldArray['JUST_ANOTHER_NAME'] = 'None';
$this->_listViewSmartyOutput2 = trim($enumField->getListViewSmarty($parentFieldArray, $vardef, $displayParams, $col));
}
示例11: apiSave
/**
* Override of parent apiSave to force the custom save to be run from API
* @param SugarBean $bean
* @param array $params
* @param string $field
* @param array $properties
*/
public function apiSave(SugarBean $bean, array $params, $field, $properties)
{
// Mapped fields needs to have something to map from.
if (empty($properties['mapFunction']) || empty($properties['parentField'])) {
return;
}
// First make sure the parent field exists on this bean
if (isset($bean->field_defs[$properties['parentField']])) {
require_once 'include/SugarFields/SugarFieldHandler.php';
$sfh = new SugarFieldHandler();
$sf = $sfh->getSugarField($bean->field_defs[$properties['parentField']]['type']);
if (method_exists($sf, $properties['mapFunction'])) {
$bean->{$field} = $sf->{$properties['mapFunction']}($bean->{$properties['parentField']});
}
}
}
示例12: toJson
/**
* Method that returns a JSON representation of the bean.
* @return string
*/
public function toJson()
{
$this->retrieve();
$sfh = new SugarFieldHandler();
$data = array();
require_once 'include/api/RestService.php';
$service = new RestService();
foreach ($this->field_defs as $fieldName => $properties) {
$type = !empty($properties['custom_type']) ? $properties['custom_type'] : $properties['type'];
$field = $sfh->getSugarField($type);
if ($field != null && isset($this->{$fieldName})) {
$field->apiFormatField($data, $this, array(), $fieldName, $properties, array(), $service);
}
}
return json_encode($data);
}
示例13: save
/**
* Save the Individual Worksheet
*
* @return ForecastWorksheet
* @throws SugarApiException
*/
public function save()
{
require_once 'include/SugarFields/SugarFieldHandler.php';
/* @var $seed ForecastWorksheet */
$seed = BeanFactory::getBean("ForecastWorksheets");
$seed->loadFromRow($this->args);
$sfh = new SugarFieldHandler();
foreach ($seed->field_defs as $properties) {
$fieldName = $properties['name'];
if (!isset($this->args[$fieldName])) {
continue;
}
if (!$seed->ACLFieldAccess($fieldName, 'save')) {
// No write access to this field, but they tried to edit it
global $app_strings;
throw new SugarApiException(string_format($app_strings['SUGAR_API_EXCEPTION_NOT_AUTHORIZED'], array($fieldName, $this->args['module'])));
}
$type = !empty($properties['custom_type']) ? $properties['custom_type'] : $properties['type'];
$field = $sfh->getSugarField($type);
if (!is_null($field)) {
$field->save($seed, $this->args, $fieldName, $properties);
}
}
// Check if this is the first commit, then save has_commits true to the config table
$admin = BeanFactory::getBean('Administration');
$settings = $admin->getConfigForModule('Forecasts');
if (!isset($settings['has_commits']) || !$settings['has_commits']) {
$admin->saveSetting('Forecasts', 'has_commits', true, 'base');
MetaDataManager::refreshModulesCache(array('Forecasts'));
}
$seed->setWorksheetArgs($this->args);
// we need to set the parent_type and parent_id so it finds it when we try and retrieve the old records
$seed->parent_type = $this->getArg('parent_type');
$seed->parent_id = $this->getArg('parent_id');
$seed->saveWorksheet();
// we have the id, just retrieve the record again
$seed = BeanFactory::getBean("ForecastWorksheets", $this->getArg('record'));
return $seed;
}
示例14: process_page
/**
*
*/
function process_page()
{
global $theme;
global $focus;
global $mod_strings;
global $app_strings;
global $app_list_strings;
global $currentModule;
global $odd_bg;
global $even_bg;
global $audit;
global $current_language;
$audit_list = Audit::get_audit_list();
$xtpl = new XTemplate('modules/Audit/Popup_picker.html');
$xtpl->assign('MOD', $mod_strings);
$xtpl->assign('APP', $app_strings);
insert_popup_header($theme);
//output header
echo "<table width='100%' cellpadding='0' cellspacing='0'><tr><td>";
$mod_strings = return_module_language($current_language, $focus->module_dir);
$printImageURL = SugarThemeRegistry::current()->getImageURL('print.gif');
$titleExtra = <<<EOHTML
<a href="javascript:void window.open('index.php?{$GLOBALS['request_string']}','printwin','menubar=1,status=0,resizable=1,scrollbars=1,toolbar=0,location=1')" class='utilsLink'>
<!--not_in_theme!--><img src="{$printImageURL}" alt="{$GLOBALS['app_strings']['LNK_PRINT']}"></a>
<a href="javascript:void window.open('index.php?{$GLOBALS['request_string']}','printwin','menubar=1,status=0,resizable=1,scrollbars=1,toolbar=0,location=1')" class='utilsLink'>
{$GLOBALS['app_strings']['LNK_PRINT']}
</a>
EOHTML;
$params = array();
$params[] = translate('LBL_MODULE_NAME', $focus->module_dir);
$params[] = $focus->get_summary_text();
$params[] = translate('LBL_CHANGE_LOG', 'Audit');
echo str_replace('</div>', "<span class='utils'>{$titleExtra}</span></div>", getClassicModuleTitle($focus->module_dir, $params, false));
$oddRow = true;
$audited_fields = $focus->getAuditEnabledFieldDefinitions();
asort($audited_fields);
$fields = '';
$field_count = count($audited_fields);
$start_tag = "<table><tr><td >";
$end_tag = "</td></tr></table>";
if ($field_count > 0) {
$index = 0;
foreach ($audited_fields as $key => $value) {
$index++;
$vname = '';
if (isset($value['vname'])) {
$vname = $value['vname'];
} else {
if (isset($value['label'])) {
$vname = $value['label'];
}
}
$fields .= str_replace(':', '', translate($vname, $focus->module_dir));
if ($index < $field_count) {
$fields .= ", ";
}
}
echo $start_tag . translate('LBL_AUDITED_FIELDS', 'Audit') . $fields . $end_tag;
} else {
echo $start_tag . translate('LBL_AUDITED_FIELDS', 'Audit') . $end_tag;
}
foreach ($audit_list as $audit) {
if (empty($audit['before_value_string']) && empty($audit['after_value_string'])) {
$before_value = $audit['before_value_text'];
$after_value = $audit['after_value_text'];
} else {
$before_value = $audit['before_value_string'];
$after_value = $audit['after_value_string'];
}
// Let's run the audit data through the sugar field system
if (isset($audit['data_type'])) {
require_once 'include/SugarFields/SugarFieldHandler.php';
$vardef = array('name' => 'audit_field', 'type' => $audit['data_type']);
$field = SugarFieldHandler::getSugarField($audit['data_type']);
$before_value = $field->getChangeLogSmarty(array($vardef['name'] => $before_value), $vardef, array(), $vardef['name']);
$after_value = $field->getChangeLogSmarty(array($vardef['name'] => $after_value), $vardef, array(), $vardef['name']);
}
$activity_fields = array('ID' => $audit['id'], 'NAME' => $audit['field_name'], 'BEFORE_VALUE' => $before_value, 'AFTER_VALUE' => $after_value, 'CREATED_BY' => $audit['created_by'], 'DATE_CREATED' => $audit['date_created']);
$xtpl->assign("ACTIVITY", $activity_fields);
if ($oddRow) {
//todo move to themes
$xtpl->assign("ROW_COLOR", 'oddListRow');
$xtpl->assign("BG_COLOR", $odd_bg);
} else {
//todo move to themes
$xtpl->assign("ROW_COLOR", 'evenListRow');
$xtpl->assign("BG_COLOR", $even_bg);
}
$oddRow = !$oddRow;
$xtpl->parse("audit.row");
// Put the rows in.
}
//end foreach
$xtpl->parse("audit");
$xtpl->out("audit");
insert_popup_footer();
}
示例15: setUp
public function setUp()
{
$this->intField = SugarFieldHandler::getSugarField('int');
}