本文整理汇总了PHP中SFUtils::valuesToLabels方法的典型用法代码示例。如果您正苦于以下问题:PHP SFUtils::valuesToLabels方法的具体用法?PHP SFUtils::valuesToLabels怎么用?PHP SFUtils::valuesToLabels使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFUtils
的用法示例。
在下文中一共展示了SFUtils::valuesToLabels方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formHTML
//.........这里部分代码省略.........
$generated_page_name = str_ireplace("<{$escaped_input_name}>", $cur_value_in_template, $generated_page_name);
// once the substitution is done, replace underlines back
// with spaces
$generated_page_name = str_replace('_', ' ', $generated_page_name);
}
// disable this field if either the whole form is disabled, or
// it's a restricted field and user doesn't have sysop privileges
$is_disabled = $form_is_disabled || $is_restricted;
// Create an SFFormField instance based on all the parameters
// in the form definition, and any information from the template
// definition (contained in the $all_fields parameter).
$form_field = SFFormField::createFromDefinition($field_name, $input_name, $is_mandatory, $is_hidden, $is_uploadable, $possible_values, $is_disabled, $is_list, $input_type, $field_args, $all_fields, $strict_parsing);
// 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 ($semantic_property != null) {
$form_field->template_field->setSemanticProperty($semantic_property);
}
$semantic_property = $form_field->template_field->getSemanticProperty();
if (!is_null($semantic_property)) {
global $sfgFieldProperties;
$sfgFieldProperties[$fullFieldName] = $semantic_property;
}
// call hooks - unfortunately this has to be split into two
// separate calls, because of the different variable names in
// each case
if ($form_submitted) {
wfRunHooks('sfCreateFormField', array(&$form_field, &$cur_value_in_template, true));
} else {
if (!empty($cur_value) && array_key_exists('mapping template', $field_args)) {
$cur_value = SFUtils::valuesToLabels($cur_value, $field_args['mapping template'], $delimiter, $possible_values);
}
wfRunHooks('sfCreateFormField', array(&$form_field, &$cur_value, false));
}
// if this is not part of a 'multiple' template, increment the
// global tab index (used for correct tabbing)
if (!array_key_exists('part_of_multiple', $field_args)) {
$sfgTabIndex++;
}
// increment the global field number regardless
$sfgFieldNum++;
// If the field is a date field, and its default value was set
// to 'now', and it has no current value, set $cur_value to be
// the current date.
if ($default_value == 'now' && ($cur_value == '' || $cur_value == 'now')) {
if ($input_type == 'date' || $input_type == 'datetime' || $input_type == 'year' || $input_type == '' && $form_field->getTemplateField()->getPropertyType() == '_dat') {
// Get current time, for the time zone specified in the wiki.
global $wgLocaltimezone;
if (isset($wgLocaltimezone)) {
$serverTimezone = date_default_timezone_get();
date_default_timezone_set($wgLocaltimezone);
}
$cur_time = time();
$year = date("Y", $cur_time);
$month = date("n", $cur_time);
$day = date("j", $cur_time);
global $wgAmericanDates, $sfg24HourTime;
if ($wgAmericanDates == true) {
$month_names = SFFormUtils::getMonthNames();
$month_name = $month_names[$month - 1];
$cur_value_in_template = "{$month_name} {$day}, {$year}";
} else {
$cur_value_in_template = "{$year}/{$month}/{$day}";
示例2: formHTML
//.........这里部分代码省略.........
}
$cur_value_in_template .= $val;
}
}
} else {
// If it's not a list, it's probably from a checkbox or date input -
// convert the values into a string.
$cur_value_in_template = self::getStringFromPassedInArray($cur_value, $delimiter);
}
} else {
// value is not an array
$cur_value_in_template = $cur_value;
}
// If we're creating the page name from a formula based on
// form values, see if the current input is part of that formula,
// and if so, substitute in the actual value.
if ($form_submitted && $generated_page_name !== '') {
// This line appears to be unnecessary.
// $generated_page_name = str_replace('.', '_', $generated_page_name);
$generated_page_name = str_replace(' ', '_', $generated_page_name);
$escaped_input_name = str_replace(' ', '_', $form_field->getInputName());
$generated_page_name = str_ireplace("<{$escaped_input_name}>", $cur_value_in_template, $generated_page_name);
// Once the substitution is done, replace underlines back
// with spaces.
$generated_page_name = str_replace('_', ' ', $generated_page_name);
}
// Call hooks - unfortunately this has to be split into two
// separate calls, because of the different variable names in
// each case.
if ($form_submitted) {
Hooks::run('sfCreateFormField', array(&$form_field, &$cur_value_in_template, true));
} else {
if (!empty($cur_value) && ($form_field->hasFieldArg('mapping template') || $form_field->hasFieldArg('mapping property') || $form_field->hasFieldArg('mapping cargo table') && $form_field->hasFieldArg('mapping cargo field'))) {
$cur_value = SFUtils::valuesToLabels($cur_value, $delimiter, $form_field->getPossibleValues());
}
Hooks::run('sfCreateFormField', array(&$form_field, &$cur_value, false));
}
// if this is not part of a 'multiple' template, increment the
// global tab index (used for correct tabbing)
if (!$form_field->hasFieldArg('part_of_multiple')) {
$sfgTabIndex++;
}
// increment the global field number regardless
$sfgFieldNum++;
// If the field is a date field, and its default value was set
// to 'now', and it has no current value, set $cur_value to be
// the current date.
if ($form_field->getDefaultValue() == 'now' && ($cur_value == '' || $cur_value == 'now')) {
$input_type = $form_field->getInputType();
if ($input_type == 'date' || $input_type == 'datetime' || $input_type == 'year' || $input_type == '' && $form_field->getTemplateField()->getPropertyType() == '_dat') {
$cur_value_in_template = self::getStringForCurrentTime($input_type == 'datetime', $form_field->hasFieldArg('include timezone'));
}
}
// If the field is a text field, and its default value was set
// to 'current user', and it has no current value, set $cur_value
// to be the current user.
if ($form_field->getDefaultValue() == 'current user' && ($cur_value === '' || $cur_value == 'current user')) {
$cur_value_in_template = $wgUser->getName();
$cur_value = $cur_value_in_template;
}
// If all instances have been
// printed, that means we're
// now printing a "starter"
// div - set the current value
// to null.
// (Ideally it wouldn't get