本文整理汇总了PHP中SFUtils::getLabelsFromCargoField方法的典型用法代码示例。如果您正苦于以下问题:PHP SFUtils::getLabelsFromCargoField方法的具体用法?PHP SFUtils::getLabelsFromCargoField怎么用?PHP SFUtils::getLabelsFromCargoField使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFUtils
的用法示例。
在下文中一共展示了SFUtils::getLabelsFromCargoField方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formHTML
//.........这里部分代码省略.........
$field_args['default filename'] = $default_filename;
} elseif ($sub_components[0] == 'restricted') {
$is_restricted = !array_intersect($wgUser->getEffectiveGroups(), array_map('trim', explode(',', $sub_components[1])));
}
}
}
// end for
if (array_key_exists('delimiter', $field_args)) {
$delimiter = $field_args['delimiter'];
} else {
$delimiter = ",";
}
// If the 'values' parameter was set, separate it based on the
// 'delimiter' parameter, if any.
if (!empty($values)) {
// Remove whitespaces, and un-escape characters
$possible_values = array_map('trim', explode($delimiter, $values));
$possible_values = array_map('htmlspecialchars_decode', $possible_values);
}
// If we're using Cargo, there's no
// equivalent for "values from property"
// - instead, we just always get the
// values if a field and table have
// been specified.
if (is_null($possible_values) && defined('CARGO_VERSION') && $cargo_table != null && $cargo_field != null) {
$possible_values = SFUtils::getValuesForCargoField($cargo_table, $cargo_field, $cargo_field . " IS NOT NULL");
}
if (!is_null($possible_values)) {
if (array_key_exists('mapping template', $field_args)) {
$possible_values = SFUtils::getLabelsFromTemplate($possible_values, $field_args['mapping template']);
} elseif (array_key_exists('mapping property', $field_args)) {
$possible_values = SFUtils::getLabelsFromProperty($possible_values, $field_args['mapping property']);
} elseif (array_key_exists('mapping cargo table', $field_args) && array_key_exists('mapping cargo field', $field_args)) {
$possible_values = SFUtils::getLabelsFromCargoField($possible_values, $field_args['mapping cargo table'], $field_args['mapping cargo field']);
}
}
// Backwards compatibility
if ($input_type == 'datetime with timezone') {
$input_type = 'datetime';
$field_args['include timezone'] = true;
} elseif ($input_type == 'text' || $input_type == 'textarea') {
// Also for backwards compatibility,
// in that once b/c goes away,
// this will no longer be
// necessary.
$field_args['no autocomplete'] = true;
}
if ($allow_multiple) {
$field_args['part_of_multiple'] = $allow_multiple;
}
if (count($show_on_select) > 0) {
$field_args['show on select'] = $show_on_select;
}
// Get the value from the request, if
// it's there, and if it's not an array.
$cur_value = null;
$escaped_field_name = str_replace("'", "\\'", $field_name);
if (isset($template_instance_query_values) && $template_instance_query_values != null && is_array($template_instance_query_values)) {
// If the field name contains an
// apostrophe, the array sometimes
// has the apostrophe escaped, and
// sometimes not. For now, just check
// for both versions.
// @TODO - figure this out.
$field_query_val = null;
if (array_key_exists($escaped_field_name, $template_instance_query_values)) {
示例2: newFromFormFieldTag
//.........这里部分代码省略.........
} elseif ($sub_components[0] == 'restricted') {
$f->mIsRestricted = !array_intersect($wgUser->getEffectiveGroups(), array_map('trim', explode(',', $sub_components[1])));
}
}
}
// end for
if (!array_key_exists('delimiter', $f->mFieldArgs)) {
$f->mFieldArgs['delimiter'] = ",";
}
$delimiter = $f->mFieldArgs['delimiter'];
// If the 'values' parameter was set, separate it based on the
// 'delimiter' parameter, if any.
if (!empty($values)) {
// Remove whitespaces, and un-escape characters
$valuesArray = array_map('trim', explode($delimiter, $values));
$f->mPossibleValues = array_map('htmlspecialchars_decode', $valuesArray);
}
// If we're using Cargo, there's no equivalent for "values from
// property" - instead, we just always get the values if a
// field and table have been specified.
if (is_null($f->mPossibleValues) && defined('CARGO_VERSION') && $cargo_table != null && $cargo_field != null) {
// We only want the non-null values. Ideally this could
// be done by calling getValuesForCargoField() with
// an "IS NOT NULL" clause, but unfortunately that fails
// for array/list fields.
// Instead of getting involved with all that, we'll just
// remove the null/blank values afterward.
$cargoValues = SFUtils::getAllValuesForCargoField($cargo_table, $cargo_field);
$f->mPossibleValues = array_filter($cargoValues, 'strlen');
}
if (!is_null($f->mPossibleValues)) {
if (array_key_exists('mapping template', $f->mFieldArgs)) {
$f->mPossibleValues = SFUtils::getLabelsFromTemplate($f->mPossibleValues, $f->mFieldArgs['mapping template']);
} elseif (array_key_exists('mapping property', $f->mFieldArgs)) {
$f->mPossibleValues = SFUtils::getLabelsFromProperty($f->mPossibleValues, $f->mFieldArgs['mapping property']);
} elseif (array_key_exists('mapping cargo table', $f->mFieldArgs) && array_key_exists('mapping cargo field', $f->mFieldArgs)) {
$f->mPossibleValues = SFUtils::getLabelsFromCargoField($f->mPossibleValues, $f->mFieldArgs['mapping cargo table'], $f->mFieldArgs['mapping cargo field']);
}
}
// Backwards compatibility.
if ($f->mInputType == 'datetime with timezone') {
$f->mInputType = 'datetime';
$f->mFieldArgs['include timezone'] = true;
} elseif ($f->mInputType == 'text' || $f->mInputType == 'textarea') {
// Backwards compatibility.
$f->mFieldArgs['no autocomplete'] = true;
}
if ($template_in_form->allowsMultiple()) {
$f->mFieldArgs['part_of_multiple'] = true;
}
if (count($show_on_select) > 0) {
$f->mFieldArgs['show on select'] = $show_on_select;
}
// Disable this field if either the whole form is disabled, or
// it's a restricted field and user doesn't have sysop privileges.
$f->mIsDisabled = $form_is_disabled || $f->mIsRestricted;
// Do some data storage specific to the Semantic MediaWiki and
// Cargo extensions.
if (defined('SMW_VERSION')) {
// If a property was set in the form definition,
// overwrite whatever is set in the template field -
// this is somewhat of a hack, since parameters set in
// the form definition are meant to go into the
// SFFormField object, not the SFTemplateField object
// it contains;
// it seemed like too much work, though, to create an
// SFFormField::setSemanticProperty() function just for
// this call.
if (!is_null($semantic_property)) {
$f->template_field->setSemanticProperty($semantic_property);
} else {
$semantic_property = $f->template_field->getSemanticProperty();
}
if (!is_null($semantic_property)) {
global $sfgFieldProperties;
$sfgFieldProperties[$fullFieldName] = $semantic_property;
}
}
if (defined('CARGO_VERSION')) {
if ($cargo_table != null && $cargo_field != null) {
$f->template_field->setCargoFieldData($cargo_table, $cargo_field);
}
$fullCargoField = $f->template_field->getFullCargoField();
if (!is_null($fullCargoField)) {
global $sfgCargoFields;
$sfgCargoFields[$fullFieldName] = $fullCargoField;
}
}
if ($template_in_form->getTemplateName() == null || $template_in_form->getTemplateName() === '') {
$f->mInputName = $field_name;
} elseif ($template_in_form->allowsMultiple()) {
// 'num' will get replaced by an actual index, either in PHP
// or in Javascript, later on
$f->mInputName = $template_in_form->getTemplateName() . '[num][' . $field_name . ']';
$f->setFieldArg('origName', $template_in_form->getTemplateName() . '[' . $field_name . ']');
} else {
$f->mInputName = $template_in_form->getTemplateName() . '[' . $field_name . ']';
}
return $f;
}