本文整理汇总了PHP中FlexicontentFields::indexFieldsByIds方法的典型用法代码示例。如果您正苦于以下问题:PHP FlexicontentFields::indexFieldsByIds方法的具体用法?PHP FlexicontentFields::indexFieldsByIds怎么用?PHP FlexicontentFields::indexFieldsByIds使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FlexicontentFields
的用法示例。
在下文中一共展示了FlexicontentFields::indexFieldsByIds方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: onDisplayField
function onDisplayField(&$field, &$item)
{
if (!in_array($field->field_type, self::$field_types)) {
return;
}
$field->label = JText::_($field->label);
$use_ingroup = $field->parameters->get('use_ingroup', 0);
$ajax = !empty($field->isAjax);
if ($use_ingroup) {
$field->formhidden = 3;
}
if ($use_ingroup && empty($field->ingroup) && !$ajax) {
return;
}
// initialize framework objects and other variables
$document = JFactory::getDocument();
// some parameter shortcuts
$sql_mode = $field->parameters->get('sql_mode', 0);
$field_elements = $field->parameters->get('field_elements');
$cascade_after = (int) $field->parameters->get('cascade_after', 0);
// ****************
// Number of values
// ****************
$multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
$max_values = $use_ingroup ? 0 : (int) $field->parameters->get('max_values', 0);
$required = $field->parameters->get('required', 0);
$required = $required ? ' required' : '';
$add_position = (int) $field->parameters->get('add_position', 3);
// **************
// Value handling
// **************
// Default value
$value_usage = $field->parameters->get('default_value_use', 0);
$default_value = $item->version == 0 || $value_usage > 0 ? trim($field->parameters->get('default_value', '')) : '';
// *************************
// Input field configuration
// *************************
// DISPLAY using prettyCheckable JS
$use_jslib = $field->parameters->get('use_jslib', 2);
$use_prettycheckable = $use_jslib == 2;
static $prettycheckable_added = null;
if ($use_prettycheckable && $prettycheckable_added === null) {
$prettycheckable_added = flexicontent_html::loadFramework('prettyCheckable');
}
// Display text label, use checkbox/radio image field for more
$form_vals_display = $field->parameters->get('form_vals_display', 1);
// this field includes image but it can be more convenient/compact not to be display image in item form
// when field is displayed as drop-down select (item edit form only)
$firstoptiontext = $field->parameters->get('firstoptiontext', 'FLEXI_SELECT');
$usefirstoption = $field->parameters->get('usefirstoption', 1);
// Prefix - Suffix - Separator (item FORM) parameters, for the checkbox/radio elements
$pretext = $field->parameters->get('pretext_form', '');
$posttext = $field->parameters->get('posttext_form', '');
$separator = $field->parameters->get('separator', 0);
$opentag = $field->parameters->get('opentag_form', '');
$closetag = $field->parameters->get('closetag_form', '');
switch ($separator) {
case 0:
$separator = ' ';
break;
case 1:
$separator = '<br />';
break;
case 2:
$separator = ' | ';
break;
case 3:
$separator = ', ';
break;
case 4:
$separator = $closetag . $opentag;
break;
default:
$separator = ' ';
break;
}
// Initialise property with default value
if (!$field->value) {
$field->value = array($default_value);
}
// CSS classes of value container
$value_classes = 'fcfieldval_container valuebox fcfieldval_container_' . $field->id;
// Field name and HTML TAG id
$valueholder_nm = 'custom[_fcfield_valueholder_][' . $field->name . ']';
$valueholder_id = 'custom__fcfield_valueholder__' . $field->name;
$fieldname = 'custom[' . $field->name . ']';
$elementid = 'custom_' . $field->name;
$js = "";
$css = "";
// *********************************************************************************************
// Handle adding the needed JS code to CASCADE (listen to) changes of the dependent master field
// *********************************************************************************************
if ($cascade_after && !$ajax) {
$byIds = FlexicontentFields::indexFieldsByIds($item->fields);
if (isset($byIds[$cascade_after])) {
$cascade_prompt = $field->parameters->get('cascade_prompt', '');
$cascade_prompt = $cascade_prompt ? JText::_($cascade_prompt) : JText::_('FLEXI_PLEASE_SELECT') . ': ' . $byIds[$cascade_after]->label;
$srcELid = 'custom_' . $byIds[$cascade_after]->name;
$trgELid = $elementid;
// Get values of cascade (on) source field
//.........这里部分代码省略.........
示例2: onDisplayField
function onDisplayField(&$field, &$item)
{
if (!in_array($field->field_type, self::$field_types)) {
return;
}
$field->label = JText::_($field->label);
$use_ingroup = $field->parameters->get('use_ingroup', 0);
$ajax = !empty($field->isAjax);
if ($use_ingroup) {
$field->formhidden = 3;
}
if ($use_ingroup && empty($field->ingroup) && !$ajax) {
return;
}
// initialize framework objects and other variables
$document = JFactory::getDocument();
// some parameter shortcuts
$sql_mode = $field->parameters->get('sql_mode', 0);
$field_elements = $field->parameters->get('field_elements');
$cascade_after = (int) $field->parameters->get('cascade_after', 0);
// ****************
// Number of values
// ****************
$multiple = $use_ingroup || (int) $field->parameters->get('allow_multiple', 0);
$max_values = $use_ingroup ? 0 : (int) $field->parameters->get('max_values', 0);
$required = $field->parameters->get('required', 0);
$required = $required ? ' required' : '';
$add_position = (int) $field->parameters->get('add_position', 3);
// **************
// Value handling
// **************
// Default value
$value_usage = $field->parameters->get('default_value_use', 0);
$default_value = $item->version == 0 || $value_usage > 0 ? trim($field->parameters->get('default_value', '')) : '';
// *************************
// Input field configuration
// *************************
// DISPLAY using select2 JS
$use_jslib = $field->parameters->get('use_jslib', 1);
$use_select2 = $use_jslib == 1;
static $select2_added = null;
if ($use_select2 && $select2_added === null) {
$select2_added = flexicontent_html::loadFramework('select2');
}
// Parameters for DISPLAY with / without using select2 JS
// ... none such parameters
// Custom HTML placed before / after form field
$opentag = $field->parameters->get('opentag_form', '');
$closetag = $field->parameters->get('closetag_form', '');
// Initialise property with default value
if (!$field->value) {
$field->value = array($default_value);
}
// CSS classes of value container
$value_classes = 'fcfieldval_container valuebox fcfieldval_container_' . $field->id;
// Field name and HTML TAG id
$valueholder_nm = 'custom[_fcfield_valueholder_][' . $field->name . ']';
$valueholder_id = 'custom__fcfield_valueholder__' . $field->name;
$fieldname = 'custom[' . $field->name . ']';
$elementid = 'custom_' . $field->name;
$js = "";
$css = "";
// *********************************************************************************************
// Handle adding the needed JS code to CASCADE (listen to) changes of the dependent master field
// *********************************************************************************************
if ($cascade_after && !$ajax) {
$byIds = FlexicontentFields::indexFieldsByIds($item->fields);
if (isset($byIds[$cascade_after])) {
$cascade_prompt = $field->parameters->get('cascade_prompt', '');
$cascade_prompt = $cascade_prompt ? JText::_($cascade_prompt) : JText::_('FLEXI_PLEASE_SELECT') . ': ' . $byIds[$cascade_after]->label;
$srcELid = 'custom_' . $byIds[$cascade_after]->name;
$trgELid = $elementid;
// Get values of cascade (on) source field
$field->valgrps = $byIds[$cascade_after]->value ? $byIds[$cascade_after]->value : array();
foreach ($field->valgrps as &$vg) {
if (is_array($vg)) {
} else {
if (@unserialize($vg) !== false || $vg === 'b:0;') {
$vg = unserialize($vg);
} else {
$vg = array($vg);
}
}
}
unset($vg);
} else {
$cascade_after = 0;
echo 'Error in field ' . $field->label . ' [' . $field->id . ']' . ' cannot cascaded after field no: ' . $cascade_after . ', field was not found <br/>';
}
} else {
if ($cascade_after && $ajax) {
$field->valgrps = isset($field->valgrps) ? $field->valgrps : array();
$field->valgrps = is_array($field->valgrps) ? $field->valgrps : preg_split("/\\s*,\\s*/u", trim($field->valgrps));
}
}
// ***********************
// Handle multiple records
// ***********************
if ($multiple && !$ajax) {
// Add the drag and drop sorting feature
//.........这里部分代码省略.........