本文整理汇总了PHP中SugarFieldHandler类的典型用法代码示例。如果您正苦于以下问题:PHP SugarFieldHandler类的具体用法?PHP SugarFieldHandler怎么用?PHP SugarFieldHandler使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SugarFieldHandler类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: 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');
}
}
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:32,代码来源:download_file.php
示例2: 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);
}
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:34,代码来源:ReportsSugarFieldTeamsetCollection.php
示例3: __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;
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:33,代码来源:ImportFieldSanitize.php
示例4: 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);
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:7,代码来源:function.sugarvar_teamset.php
示例5: 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;
}
开发者ID:nerdystudmuffin,项目名称:dashlet-subpanels,代码行数:59,代码来源:formbase.php
示例6: smarty_function_sugar_teamset_list
function smarty_function_sugar_teamset_list($params, &$smarty)
{
if (!isset($params['row']) && !isset($params['col'])) {
$smarty->trigger_error("sugar_phone: missing parameters, cannot continue");
return '';
}
require_once 'include/SugarFields/SugarFieldHandler.php';
$sfh = new SugarFieldHandler();
return $sfh->displaySmarty($params['row'], $params['vardef'], 'ListView', array('col' => $params['col']));
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:10,代码来源:function.sugar_teamset_list.php
示例7: 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'];
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:23,代码来源:MetaDataHacks.php
示例8: 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);
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:20,代码来源:Comment.php
示例9: 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);
}
开发者ID:rgauss,项目名称:sugarcrm_dev,代码行数:10,代码来源:SugarFieldEncryptTest.php
示例10: 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']});
}
}
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:23,代码来源:SugarFieldMapped.php
示例11: smarty_function_sugar_field
function smarty_function_sugar_field($params, &$smarty)
{
if (!isset($params['vardef']) || !isset($params['displayType']) || !isset($params['parentFieldArray'])) {
if (!isset($params['vardef'])) {
$smarty->trigger_error("sugar_field: missing 'vardef' parameter");
}
if (!isset($params['displayType'])) {
$smarty->trigger_error("sugar_field: missing 'displayType' parameter");
}
if (!isset($params['parentFieldArray'])) {
$smarty->trigger_error("sugar_field: missing 'parentFieldArray' parameter");
}
return;
}
static $sfh;
if (!isset($sfh)) {
$sfh = new SugarFieldHandler();
}
if (!isset($params['displayParams'])) {
$displayParams = array();
} else {
$displayParams = $params['displayParams'];
}
if (isset($params['labelSpan'])) {
$displayParams['labelSpan'] = $params['labelSpan'];
} else {
$displayParams['labelSpan'] = null;
}
if (isset($params['fieldSpan'])) {
$displayParams['fieldSpan'] = $params['fieldSpan'];
} else {
$displayParams['fieldSpan'] = null;
}
if (isset($params['typeOverride'])) {
// override the type in the vardef?
$params['vardef']['type'] = $params['typeOverride'];
}
if (isset($params['formName'])) {
$displayParams['formName'] = $params['formName'];
}
if (isset($params['field'])) {
$params['vardef']['name'] = $params['field'];
}
if (isset($params['call_back_function'])) {
$displayParams['call_back_function'] = $params['call_back_function'];
}
if (isset($params['skipClearButton'])) {
$displayParams['skipClearButton'] = $params['skipClearButton'];
}
if (isset($params['idName'])) {
$displayParams['idName'] = $params['idName'];
}
if (isset($params['accesskey'])) {
$displayParams['accesskey'] = $params['accesskey'];
}
$_contents = $sfh->displaySmarty($params['parentFieldArray'], $params['vardef'], $params['displayType'], $displayParams, $params['tabindex']);
return $_contents;
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:58,代码来源:function.sugar_field.php
示例12: 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);
}
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:14,代码来源:Bug41114Test.php
示例13: 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));
}
开发者ID:jgera,项目名称:sugarcrm_dev,代码行数:12,代码来源:Bug50117Test.php
示例14: 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');
}
开发者ID:delkyd,项目名称:sugarcrm_dev,代码行数:15,代码来源:SugarFieldEnumTest.php
示例15: 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;
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:45,代码来源:Individual.php
示例16: populateFromPost
/**
* Populating bean from $_POST
*
* @param string $prefix of name of fields
* @param SugarBean $focus bean
* @param bool $skipRetrieve do not retrieve data of bean
* @param bool $checkACL do not update fields if they are forbidden for current user
* @return SugarBean
*/
function populateFromPost($prefix, &$focus, $skipRetrieve = false, $checkACL = 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();
$isOwner = $focus->isOwner($current_user->id);
$relatedFields = array();
foreach ($focus->field_defs as $field => $def) {
if (empty($def['type']) || $def['type'] != 'relate') {
continue;
}
if (empty($def['source']) || $def['source'] != 'non-db') {
continue;
}
if (empty($def['id_name']) || $def['id_name'] == $field) {
continue;
}
$relatedFields[$def['id_name']] = $field;
}
foreach ($focus->field_defs as $field => $def) {
if ($field == 'id' && !empty($focus->id)) {
// Don't try and overwrite the ID
continue;
}
$type = !empty($def['custom_type']) ? $def['custom_type'] : $def['type'];
$sf = $sfh->getSugarField($type);
if ($sf != null) {
$sf->save($focus, $_POST, $field, $def, $prefix);
} else {
$GLOBALS['log']->fatal("Field '{$field}' does not have a SugarField handler");
}
/*
if(isset($_POST[$prefix.$field])) {
if(is_array($_POST[$prefix.$field]) && !empty($focus->field_defs[$field]['isMultiSelect'])) {
if($_POST[$prefix.$field][0] === '' && !empty($_POST[$prefix.$field][1]) ) {
unset($_POST[$prefix.$field][0]);
}
$_POST[$prefix.$field] = encodeMultienumValue($_POST[$prefix.$field]);
}
$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;
}
开发者ID:thsonvt,项目名称:sugarcrm_dev,代码行数:86,代码来源:formbase.php
示例17: bpminbox_get_display_text
function bpminbox_get_display_text($temp_module, $field, $field_value, $adv_type = null, $ext1 = null, $context = null)
{
global $app_list_strings, $current_user;
if ($temp_module->field_defs[$field]['type'] == "relate") {
//echo $field;
//bug 23502, assigned user should be displayed as username here. But I don't know if created user, modified user or even other module should display names instead of ids.
if ($temp_module->field_defs[$field]['name'] == 'assigned_user_id' && !empty($field_value) && !empty($context['for_action_display'])) {
if ($adv_type != 'exist_user') {
return bpminbox_get_username_by_id($field_value);
} else {
$target_type = "assigned_user_name";
}
} else {
if (!empty($temp_module->field_defs[$field]['dbType'])) {
$target_type = $temp_module->field_defs[$field]['dbType'];
} else {
return $field_value;
}
}
} elseif (!empty($temp_module->field_defs[$field]['calculated']) && !empty($context['for_action_display'])) {
//Cannot set the value of calculated fields.
return false;
} else {
$target_type = $temp_module->field_defs[$field]['type'];
}
//Land of the "one offs"
//This is for meetings and calls, the reminder time
if ($temp_module->field_defs[$field]['name'] == "reminder_time") {
$target_type = "enum";
$temp_module->field_defs[$field]['options'] = "reminder_time_options";
}
if ($target_type == "assigned_user_name") {
if ($adv_type == null) {
$user_array = get_user_array(true, "Active", $field_value, true);
if (!isset($user_array[$field_value])) {
return false;
}
return $user_array[$field_value];
}
if ($adv_type == "exist_user") {
if ($ext1 == "Manager") {
return "Manager of the " . $app_list_strings['wflow_adv_user_type_dom'][$field_value];
} else {
return $app_list_strings['wflow_adv_user_type_dom'][$field_value];
}
}
}
if ($adv_type == "datetime") {
if (empty($field_value)) {
$field_value = 0;
}
return $app_list_strings['tselect_type_dom'][$field_value] . " from " . $app_list_strings['wflow_action_datetime_type_dom'][$ext1];
}
if ($adv_type == "exist_team") {
return $app_list_strings['wflow_adv_team_type_dom'][$field_value];
}
if ($adv_type == "value_calc") {
return "existing value" . $app_list_strings['query_calc_oper_dom'][$ext1] . " by " . $field_value;
}
if ($adv_type == "enum_step") {
return $app_list_strings['wflow_adv_enum_type_dom'][$ext1] . " " . $field_value . " step(s)";
}
if ($target_type === 'bool') {
$field_value = (bool) $field_value;
}
require_once 'include/SugarFields/SugarFieldHandler.php';
$sugarField = SugarFieldHandler::getSugarField($target_type);
//$GLOBALS['log']->debug("Field: $field is of type $target_type, before: $field_value");
$field_value = $sugarField->getEmailTemplateValue($field_value, $temp_module->field_defs[$field], $context);
//$GLOBALS['log']->debug("after: $field_value");
return $field_value;
}
开发者ID:jglaine,项目名称:sugar761-ent,代码行数:72,代码来源:PMSEFieldsUtils.php
示例18: process_dynamic_listview_rows
//.........这里部分代码省略.........
//AG$subpanel_data = $this->list_field_defs;
//$bla = array_pop($subpanel_data);
//select which sub-panel to display here, the decision will be made based on the type of
//the sub-panel and panel in the bean being processed.
if ($subpanel_def->isCollection()) {
$thepanel = $subpanel_def->sub_subpanels[$aItem->panel_name];
} else {
$thepanel = $subpanel_def;
}
//get data source name
$linked_field = $thepanel->get_data_source_name();
$linked_field_set = $thepanel->get_data_source_name(true);
foreach ($thepanel->get_list_fields() as $field_name => $list_field) {
//add linked field attribute to the array.
$list_field['linked_field'] = $linked_field;
$list_field['linked_field_set'] = $linked_field_set;
$usage = empty($list_field['usage']) ? '' : $list_field['usage'];
if ($usage != 'query_only') {
$list_field['name'] = $field_name;
$module_field = $field_name . '_mod';
$owner_field = $field_name . '_owner';
if (!empty($aItem->{$module_field})) {
$list_field['owner_id'] = $aItem->{$owner_field};
$list_field['owner_module'] = $aItem->{$module_field};
} else {
$list_field['owner_id'] = false;
$list_field['owner_module'] = false;
}
if (isset($list_field['alias'])) {
$list_field['name'] = $list_field['alias'];
} else {
$list_field['name'] = $field_name;
}
$list_field['fields'] = $fields;
$list_field['module'] = $aItem->module_dir;
$list_field['start_link_wrapper'] = $this->start_link_wrapper;
$list_field['end_link_wrapper'] = $this->end_link_wrapper;
$list_field['subpanel_id'] = $this->subpanel_id;
$list_field['DetailView'] = $aItem->ACLAccess('DetailView');
$list_field['ListView'] = $aItem->ACLAccess('ListView');
$list_field['EditView'] = $aItem->ACLAccess('EditView');
$list_field['Delete'] = $aItem->ACLAccess('Delete');
if (isset($aItem->field_defs[strtolower($list_field['name'])])) {
require_once 'include/SugarFields/SugarFieldHandler.php';
// We need to see if a sugar field exists for this field type first,
// if it doesn't, toss it at the old sugarWidgets. This is for
// backwards compatibilty and will be removed in a future release
$vardef = $aItem->field_defs[strtolower($list_field['name'])];
if (isset($vardef['type'])) {
$fieldType = isset($vardef['custom_type']) ? $vardef['custom_type'] : $vardef['type'];
$tmpField = SugarFieldHandler::getSugarField($fieldType, true);
} else {
$tmpField = NULL;
}
if ($tmpField != NULL) {
$widget_contents = SugarFieldHandler::displaySmarty($list_field['fields'], $vardef, 'ListView', $list_field);
} else {
// No SugarField for this particular type
// Use the old, icky, SugarWidget for now
$widget_contents = $layout_manager->widgetDisplay($list_field);
}
if (isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelDetailViewLink') {
// We need to call into the old SugarWidgets for the time being, so it can generate a proper link with all the various corner-cases handled
// So we'll populate the field data with the pre-rendered display for the field
$list_field['fields'][$field_name] = $widget_contents;
if ('full_name' == $field_name) {
//bug #32465
$list_field['fields'][strtoupper($field_name)] = $widget_contents;
}
$widget_contents = $layout_manager->widgetDisplay($list_field);
} else {
if (isset($list_field['widget_class']) && $list_field['widget_class'] == 'SubPanelEmailLink') {
$widget_contents = $layout_manager->widgetDisplay($list_field);
}
}
} else {
// This handles the edit and remove buttons
$widget_contents = $layout_manager->widgetDisplay($list_field);
}
static $count;
if (!isset($count)) {
$count = 0;
} else {
$count++;
}
$this->xTemplate->assign('CELL_COUNT', $count);
if (empty($widget_contents)) {
$widget_contents = ' ';
}
$this->xTemplate->assign('CELL', $widget_contents);
$this->xTemplate->parse($xtemplateSection . ".row.cell");
}
}
$aItem->setupCustomFields($aItem->module_dir);
$aItem->custom_fields->populateAllXTPL($this->xTemplate, 'detail', $html_varName, $fields);
$count++;
$this->xTemplate->parse($xtemplateSection . ".row");
}
$this->xTemplate->parse($xtemplateSection);
}
开发者ID:sysraj86,项目名称:carnivalcrm,代码行数:101,代码来源:ListView.php
示例19: pre_save
/**
* Do some processing before saving the bean to the database.
*/
public function pre_save()
{
if (!empty($_POST['assigned_user_id']) && $_POST['assigned_user_id'] != $this->bean->assigned_user_id && $_POST['assigned_user_id'] != $GLOBALS['current_user']->id && empty($GLOBALS['sugar_config']['exclude_notifications'][$this->bean->module_dir])) {
$this->bean->notify_on_save = true;
}
$GLOBALS['log']->debug("SugarController:: performing pre_save.");
require_once 'include/SugarFields/SugarFieldHandler.php';
$sfh = new SugarFieldHandler();
foreach ($this->bean->field_defs as $field => $properties) {
$type = !empty($properties['custom_type']) ? $properties['custom_type'] : $properties['type'];
$sf = $sfh->getSugarField(ucfirst($type), true);
if (isset($_POST[$field])) {
if (is_array($_POST[$field]) && !empty($properties['isMultiSelect'])) {
if (empty($_POST[$field][0])) {
unset($_POST[$field][0]);
}
$_POST[$field] = encodeMultienumValue($_POST[$field]);
}
$this->bean->{$field} = $_POST[$field];
} else {
if (!empty($properties['isMultiSelect']) && !isset($_POST[$field]) && isset($_POST[$field . '_multiselect'])) {
$this->bean->{$field} = '';
}
}
if ($sf != null) {
$sf->save($this->bean, $_POST, $field, $properties);
}
}
foreach ($this->bean->relationship_fields as $field => $link) {
if (!empty($_POST[$field])) {
$this->bean->{$field} = $_POST[$field];
}
}
if (!$this->bean->ACLAccess('save')) {
ACLController::displayNoAccess(true);
sugar_cleanup(true);
}
$this->bean->unformat_all_fields();
}
开发者ID:sunmo,项目名称:snowlotus,代码行数:42,代码来源:SugarController.php
示例20: getControl
/**
* Returns an input control for this fieldname given
*
* @param string $module
* @param string $fieldname
* @param string $vardef
* @param string $value
* @return string html for input element for this control
*/
function getControl($module, $fieldname, $vardef = null, $value = '')
{
global $current_language, $app_strings, $dictionary, $app_list_strings;
// use the mod_strings for this module
$mod_strings = return_module_language($current_language, $module);
// set the filename for this control
$file = create_cache_directory('modules/Import/') . $module . $fieldname . '.tpl';
if (!is_file($file) || !empty($GLOBALS['sugar_config']['developerMode']) || !empty($_SESSION['developerMode'])) {
if (!isset($vardef)) {
$focus = loadBean($module);
$vardef = $focus->getFieldDefinition($fieldname);
}
// if this is the id relation field, then don't have a pop-up selector.
if ($vardef['type'] == 'relate' && $vardef['id_name'] == $vardef['name']) {
$vardef['type'] = 'varchar';
}
// create the dropdowns for the parent type fields
if ($vardef['type'] == 'parent_type') {
$vardef['type'] = 'enum';
}
// remove the special text entry field function 'getEmailAddressWidget'
if (isset($vardef['function']) && ($vardef['function'] == 'getEmailAddressWidget' || $vardef['function']['name'] == 'getEmailAddressWidget')) {
unset($vardef['function']);
}
// load SugarFieldHandler to render the field tpl file
static $sfh;
if (!isset($sfh)) {
require_once 'include/SugarFields/SugarFieldHandler.php';
$sfh = new SugarFieldHandler();
}
$displayParams = array();
$displayParams['formName'] = 'importstep3';
$contents = $sfh->displaySmarty('fields', $vardef, 'ImportView', $displayParams);
// Remove all the copyright comments
$contents = preg_replace('/\\{\\*[^\\}]*?\\*\\}/', '', $contents);
// hack to disable one of the js calls in this control
if (isset($vardef['function']) && ($vardef['function'] == 'getCurrencyDropDown' || $vardef['function']['name'] == 'getCurrencyDropDown')) {
$contents .= "{literal}<script>function CurrencyConvertAll() { return; }</script>{/literal}";
}
// Save it to the cache file
if ($fh = @sugar_fopen($file, 'w')) {
fputs($fh, $contents);
fclose($fh);
}
}
// Now render the template we received
$ss = new Sugar_Smarty();
// Create Smarty variables for the Calendar picker widget
global $timedate;
$time_format = $timedate->get_user_time_format();
$date_format = $timedate->get_cal_date_format();
$ss->assign('USER_DATEFORMAT', $timedate->get_user_date_format());
$ss->assign('TIME_FORMAT', $time_format);
$time_separator = ":";
$match = array();
if (preg_match('/\\d+([^\\d])\\d+([^\\d]*)/s', $time_format, $match)) {
$time_separator = $match[1];
}
$t23 = strpos($time_format, '23') !== false ? '%H' : '%I';
if (!isset($match[2]) || $match[2] == '') {
$ss->assign('CALENDAR_FORMAT', $date_format . ' ' . $t23
|
请发表评论