/** * This function will replace fields taken from the fields variable * and insert them into the passed string replacing [variableName] * tokens where found. * * @param unknown_type $params * @param unknown_type $smarty * @return unknown */ function smarty_function_sugar_replace_vars($params, &$smarty) { if (empty($params['subject'])) { $smarty->trigger_error("sugarvar: missing 'subject' parameter"); return; } $fields = empty($params['fields']) ? $smarty->get_template_vars('fields') : $params['fields']; $subject = replace_sugar_vars($params['subject'], $fields, !empty($params['use_curly'])); if (!empty($params['assign'])) { $smarty->assign($params['assign'], $subject); return ''; } return $subject; }
/** * {@inheritDoc} */ public function apiFormatField(array &$data, SugarBean $bean, array $args, $fieldName, $properties, array $fieldList = null, ServiceBase $service = null) { $this->ensureApiFormatFieldArguments($fieldList, $service); // this is only for generated links if (isset($bean->field_defs[$fieldName]['gen']) && isTruthy($bean->field_defs[$fieldName]['gen'])) { $subject = $bean->field_defs[$fieldName]['default']; if (!empty($subject)) { $data[$fieldName] = replace_sugar_vars($subject, $bean->toArray(), true); } else { $data[$fieldName] = ""; } } else { parent::apiFormatField($data, $bean, $args, $fieldName, $properties, $fieldList, $service); } }