本文整理汇总了PHP中CRM_Core_BAO_UFGroup::getCreateLinks方法的典型用法代码示例。如果您正苦于以下问题:PHP CRM_Core_BAO_UFGroup::getCreateLinks方法的具体用法?PHP CRM_Core_BAO_UFGroup::getCreateLinks怎么用?PHP CRM_Core_BAO_UFGroup::getCreateLinks使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CRM_Core_BAO_UFGroup
的用法示例。
在下文中一共展示了CRM_Core_BAO_UFGroup::getCreateLinks方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: outputLocalizationJS
/**
* Create dynamic script for localizing js widgets.
*/
public static function outputLocalizationJS()
{
CRM_Core_Page_AJAX::setJsHeaders();
$config = CRM_Core_Config::singleton();
$vars = array('moneyFormat' => json_encode(CRM_Utils_Money::format(1234.56)), 'contactSearch' => json_encode($config->includeEmailInName ? ts('Start typing a name or email...') : ts('Start typing a name...')), 'otherSearch' => json_encode(ts('Enter search term...')), 'entityRef' => array('contactCreate' => CRM_Core_BAO_UFGroup::getCreateLinks(), 'filters' => self::getEntityRefFilters()), 'ajaxPopupsEnabled' => self::singleton()->ajaxPopupsEnabled);
print CRM_Core_Smarty::singleton()->fetchWith('CRM/common/l10n.js.tpl', $vars);
CRM_Utils_System::civiExit();
}
示例2: buildQuickForm
//.........这里部分代码省略.........
//make location type required for inline edit
$form->addField("address[{$blockId}][location_type_id]", array('entity' => 'address', 'class' => 'eight') + $js, $inlineEdit);
if (!$inlineEdit) {
$js = array('id' => 'Address_' . $blockId . '_IsPrimary', 'onClick' => 'singleSelect( this.id );');
}
$form->addField("address[{$blockId}][is_primary]", array('entity' => 'address', 'label' => ts('Primary location for this contact'), 'text' => ts('Primary location for this contact')) + $js);
if (!$inlineEdit) {
$js = array('id' => 'Address_' . $blockId . '_IsBilling', 'onClick' => 'singleSelect( this.id );');
}
$form->addField("address[{$blockId}][is_billing]", array('entity' => 'address', 'label' => ts('Primary location for this contact'), 'text' => ts('Primary location for this contact')) + $js);
// hidden element to store master address id
$form->addField("address[{$blockId}][master_id]", array('entity' => 'address', 'type' => 'hidden'));
$addressOptions = CRM_Core_BAO_Setting::valueOptions(CRM_Core_BAO_Setting::SYSTEM_PREFERENCES_NAME, 'address_options', TRUE, NULL, TRUE);
$attributes = CRM_Core_DAO::getAttribute('CRM_Core_DAO_Address');
$elements = array('address_name', 'street_address', 'supplemental_address_1', 'supplemental_address_2', 'city', 'postal_code', 'postal_code_suffix', 'country_id', 'state_province_id', 'county_id', 'geo_code_1', 'geo_code_2', 'street_number', 'street_name', 'street_unit');
foreach ($elements as $name) {
//Remove id from name, to allow comparison against enabled addressOtions.
$nameWithoutID = strpos($name, '_id') !== FALSE ? substr($name, 0, -3) : $name;
// Skip fields which are not enabled in the address options.
if (empty($addressOptions[$nameWithoutID])) {
$continue = TRUE;
//Don't skip street parsed fields when parsing is enabled.
if (in_array($nameWithoutID, array('street_number', 'street_name', 'street_unit')) && !empty($addressOptions['street_address_parsing'])) {
$continue = FALSE;
}
if ($continue) {
continue;
}
}
if ($name == 'address_name') {
$name = 'name';
}
$params = array('entity' => 'address');
if ($name == 'postal_code_suffix') {
$params['label'] = ts('Suffix');
}
$form->addField("address[{$blockId}][{$name}]", $params);
}
$entityId = NULL;
if (!empty($form->_values['address']) && !empty($form->_values['address'][$blockId])) {
$entityId = $form->_values['address'][$blockId]['id'];
}
// CRM-11665 geocode override option
$geoCode = FALSE;
if (!empty($config->geocodeMethod)) {
$geoCode = TRUE;
$form->addElement('checkbox', "address[{$blockId}][manual_geo_code]", ts('Override automatic geocoding'));
}
$form->assign('geoCode', $geoCode);
// Process any address custom data -
$groupTree = CRM_Core_BAO_CustomGroup::getTree('Address', $form, $entityId);
if (isset($groupTree) && is_array($groupTree)) {
// use simplified formatted groupTree
$groupTree = CRM_Core_BAO_CustomGroup::formatGroupTree($groupTree, 1, $form);
// make sure custom fields are added /w element-name in the format - 'address[$blockId][custom-X]'
foreach ($groupTree as $id => $group) {
foreach ($group['fields'] as $fldId => $field) {
$groupTree[$id]['fields'][$fldId]['element_custom_name'] = $field['element_name'];
$groupTree[$id]['fields'][$fldId]['element_name'] = "address[{$blockId}][{$field['element_name']}]";
}
}
$defaults = array();
CRM_Core_BAO_CustomGroup::setDefaults($groupTree, $defaults);
// since we change element name for address custom data, we need to format the setdefault values
$addressDefaults = array();
foreach ($defaults as $key => $val) {
if (empty($val)) {
continue;
}
// inorder to set correct defaults for checkbox custom data, we need to converted flat key to array
// this works for all types custom data
$keyValues = explode('[', str_replace(']', '', $key));
$addressDefaults[$keyValues[0]][$keyValues[1]][$keyValues[2]] = $val;
}
$form->setDefaults($addressDefaults);
// we setting the prefix to 'dnc_' below, so that we don't overwrite smarty's grouptree var.
// And we can't set it to 'address_' because we want to set it in a slightly different format.
CRM_Core_BAO_CustomGroup::buildQuickForm($form, $groupTree, FALSE, 'dnc_');
// during contact editing : if no address is filled
// required custom data must not produce 'required' form rule error
// more handling done in formRule func
if (!$inlineEdit) {
CRM_Contact_Form_Edit_Address::storeRequiredCustomDataInfo($form, $groupTree);
}
$template = CRM_Core_Smarty::singleton();
$tplGroupTree = $template->get_template_vars('address_groupTree');
$tplGroupTree = empty($tplGroupTree) ? array() : $tplGroupTree;
$form->assign('address_groupTree', $tplGroupTree + array($blockId => $groupTree));
// unset the temp smarty var that got created
$form->assign('dnc_groupTree', NULL);
}
// address custom data processing ends ..
if ($sharing) {
// shared address
$form->addElement('checkbox', "address[{$blockId}][use_shared_address]", NULL, ts('Use another contact\'s address'));
// Override the default profile links to add address form
$profileLinks = CRM_Core_BAO_UFGroup::getCreateLinks(array('new_individual', 'new_organization', 'new_household'), 'shared_address');
$form->addEntityRef("address[{$blockId}][master_contact_id]", ts('Share With'), array('create' => $profileLinks));
}
}
示例3: createLocalizationJs
/**
* Create dynamic script for localizing js widgets
*
* @return string javascript content
*/
private function createLocalizationJs()
{
$config = CRM_Core_Config::singleton();
$vars = array('moneyFormat' => json_encode(CRM_Utils_Money::format(1234.56)), 'contactSearch' => json_encode($config->includeEmailInName ? ts('Start typing a name or email...') : ts('Start typing a name...')), 'otherSearch' => json_encode(ts('Enter search term...')), 'contactCreate' => CRM_Core_BAO_UFGroup::getCreateLinks());
return CRM_Core_Smarty::singleton()->fetchWith('CRM/common/localization.js.tpl', $vars);
}