本文整理汇总了PHP中SFUtils::getWordForYesOrNo方法的典型用法代码示例。如果您正苦于以下问题:PHP SFUtils::getWordForYesOrNo方法的具体用法?PHP SFUtils::getWordForYesOrNo怎么用?PHP SFUtils::getWordForYesOrNo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SFUtils
的用法示例。
在下文中一共展示了SFUtils::getWordForYesOrNo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: formHTML
//.........这里部分代码省略.........
$free_text_was_included = true;
// add a similar placeholder to the data text
$data_text .= "!free_text!\n";
}
if ( $template_name === '' || $field_name == '<freetext>' ) {
$section = substr_replace( $section, $new_text, $brackets_loc, $brackets_end_loc + 3 - $brackets_loc );
} else {
if ( is_array( $cur_value ) ) {
// first, check if it's a list
if ( array_key_exists( 'is_list', $cur_value ) &&
$cur_value['is_list'] == true ) {
$cur_value_in_template = "";
if ( array_key_exists( 'delimiter', $field_args ) ) {
$delimiter = $field_args['delimiter'];
} else {
$delimiter = ",";
}
foreach ( $cur_value as $key => $val ) {
if ( $key !== "is_list" ) {
if ( $cur_value_in_template != "" ) {
$cur_value_in_template .= $delimiter . " ";
}
$cur_value_in_template .= $val;
}
}
} else {
// otherwise:
// if it has 1 or 2 elements, assume it's a checkbox; if it has
// 3 elements, assume it's a date
// - this handling will have to get more complex if other
// possibilities get added
if ( count( $cur_value ) == 1 ) {
$cur_value_in_template = SFUtils::getWordForYesOrNo( false );
} elseif ( count( $cur_value ) == 2 ) {
$cur_value_in_template = SFUtils::getWordForYesOrNo( true );
// if it's 3 or greater, assume it's a date or datetime
} elseif ( count( $cur_value ) >= 3 ) {
$month = $cur_value['month'];
$day = $cur_value['day'];
if ( $day !== '' ) {
global $wgAmericanDates;
if ( $wgAmericanDates == false ) {
// pad out day to always be two digits
$day = str_pad( $day, 2, "0", STR_PAD_LEFT );
}
}
$year = $cur_value['year'];
$hour = $minute = $second = $ampm24h = $timezone = null;
if ( isset( $cur_value['hour'] ) ) $hour = $cur_value['hour'];
if ( isset( $cur_value['minute'] ) ) $minute = $cur_value['minute'];
if ( isset( $cur_value['second'] ) ) $second = $cur_value['second'];
if ( isset( $cur_value['ampm24h'] ) ) $ampm24h = $cur_value['ampm24h'];
if ( isset( $cur_value['timezone'] ) ) $timezone = $cur_value['timezone'];
if ( $month !== '' && $day !== '' && $year !== '' ) {
// special handling for American dates - otherwise, just
// the standard year/month/day (where month is a number)
global $wgAmericanDates;
if ( $wgAmericanDates == true ) {
$cur_value_in_template = "$month $day, $year";
} else {
$cur_value_in_template = "$year/$month/$day";
}
// include whatever time information we have
if ( ! is_null( $hour ) )
$cur_value_in_template .= " " . str_pad( intval( substr( $hour, 0, 2 ) ), 2, '0', STR_PAD_LEFT ) . ":" . str_pad( intval( substr( $minute, 0, 2 ) ), 2, '0', STR_PAD_LEFT );
示例2: getHTML
public static function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args)
{
global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect;
// Standardize $cur_value
if (is_null($cur_value)) {
$cur_value = '';
}
if (($possible_values = $other_args['possible_values']) == null) {
// If it's a Boolean property, display 'Yes' and 'No'
// as the values.
if (array_key_exists('property_type', $other_args) && $other_args['property_type'] == '_boo') {
$possible_values = array(SFUtils::getWordForYesOrNo(true), SFUtils::getWordForYesOrNo(false));
} else {
$possible_values = array();
}
}
// Add a "None" value at the beginning, unless this is a
// mandatory field and there's a current value in place (either
// through a default value or because we're editing an existing
// page).
if (!$is_mandatory || $cur_value === '') {
array_unshift($possible_values, '');
}
// Set $cur_value to be one of the allowed options, if it isn't
// already - that makes it easier to automatically have one of
// the radiobuttons be checked at the beginning.
if (!in_array($cur_value, $possible_values)) {
if (in_array('', $possible_values)) {
$cur_value = '';
} elseif (count($possible_values) == 0) {
$cur_value = '';
} else {
$cur_value = $possible_values[0];
}
}
$text = '';
$itemClass = 'radioButtonItem';
if (array_key_exists('class', $other_args)) {
$itemClass .= ' ' . $other_args['class'];
}
$itemAttrs = array('class' => $itemClass);
foreach ($possible_values as $possible_value) {
$sfgTabIndex++;
$sfgFieldNum++;
$input_id = "input_{$sfgFieldNum}";
$radiobutton_attrs = array('id' => $input_id, 'tabindex' => $sfgTabIndex);
if ($cur_value == $possible_value) {
$radiobutton_attrs['checked'] = true;
}
if ($is_disabled) {
$radiobutton_attrs['disabled'] = true;
}
if ($possible_value === '') {
// blank/"None" value
$label = wfMsg('sf_formedit_none');
} elseif (array_key_exists('value_labels', $other_args) && is_array($other_args['value_labels']) && array_key_exists($possible_value, $other_args['value_labels'])) {
$label = htmlspecialchars($other_args['value_labels'][$possible_value]);
} else {
$label = $possible_value;
}
$text .= "\t" . Html::rawElement('span', $itemAttrs, Html::input($input_name, $possible_value, 'radio', $radiobutton_attrs) . " {$label}") . "\n";
}
$spanClass = 'radioButtonSpan';
if (array_key_exists('class', $other_args)) {
$spanClass .= ' ' . $other_args['class'];
}
if ($is_mandatory) {
$spanClass .= ' mandatoryFieldSpan';
}
$spanID = "span_{$sfgFieldNum}";
// Do the 'show on select' handling.
if (array_key_exists('show on select', $other_args)) {
$spanClass .= ' sfShowIfChecked';
foreach ($other_args['show on select'] as $div_id => $options) {
if (array_key_exists($spanID, $sfgShowOnSelect)) {
$sfgShowOnSelect[$spanID][] = array($options, $div_id);
} else {
$sfgShowOnSelect[$spanID] = array(array($options, $div_id));
}
}
}
$spanAttrs = array('id' => $spanID, 'class' => $spanClass);
$text = Html::rawElement('span', $spanAttrs, $text);
return $text;
}
示例3: getStringFromPassedInArray
/**
* If the value passed in for a certain field, when a form is
* submitted, is an array, then it might be from a checkbox
* or date input - in that case, convert it into a string.
*/
function getStringFromPassedInArray($value, $delimiter)
{
// If it's just a regular list, concatenate it.
// This is needed due to some strange behavior
// in SF, where, if a preload page is passed in
// in the query string, the form ends up being
// parsed twice.
if (array_key_exists('is_list', $value)) {
unset($value['is_list']);
return implode("{$delimiter} ", $value);
}
// if it has 1 or 2 elements, assume it's a checkbox; if it has
// 3 elements, assume it's a date
// - this handling will have to get more complex if other
// possibilities get added
if (count($value) == 1) {
return SFUtils::getWordForYesOrNo(false);
} elseif (count($value) == 2) {
return SFUtils::getWordForYesOrNo(true);
// if it's 3 or greater, assume it's a date or datetime
} elseif (count($value) >= 3) {
$month = $value['month'];
$day = $value['day'];
if ($day !== '') {
global $wgAmericanDates;
if ($wgAmericanDates == false) {
// pad out day to always be two digits
$day = str_pad($day, 2, "0", STR_PAD_LEFT);
}
}
$year = $value['year'];
$hour = $minute = $second = $ampm24h = $timezone = null;
if (isset($value['hour'])) {
$hour = $value['hour'];
}
if (isset($value['minute'])) {
$minute = $value['minute'];
}
if (isset($value['second'])) {
$second = $value['second'];
}
if (isset($value['ampm24h'])) {
$ampm24h = $value['ampm24h'];
}
if (isset($value['timezone'])) {
$timezone = $value['timezone'];
}
//if ( $month !== '' && $day !== '' && $year !== '' ) {
// We can accept either year, or year + month, or year + month + day.
//if ( $month !== '' && $day !== '' && $year !== '' ) {
if ($year !== '') {
// special handling for American dates - otherwise, just
// the standard year/month/day (where month is a number)
global $wgAmericanDates;
if ($month == '') {
return $year;
} elseif ($day == '') {
if ($wgAmericanDates == true) {
return "{$month} {$year}";
} else {
return "{$year}/{$month}";
}
} else {
if ($wgAmericanDates == true) {
$new_value = "{$month} {$day}, {$year}";
} else {
$new_value = "{$year}/{$month}/{$day}";
}
// If there's a day, include whatever
// time information we have.
if (!is_null($hour)) {
$new_value .= " " . str_pad(intval(substr($hour, 0, 2)), 2, '0', STR_PAD_LEFT) . ":" . str_pad(intval(substr($minute, 0, 2)), 2, '0', STR_PAD_LEFT);
}
if (!is_null($second)) {
$new_value .= ":" . str_pad(intval(substr($second, 0, 2)), 2, '0', STR_PAD_LEFT);
}
if (!is_null($ampm24h)) {
$new_value .= " {$ampm24h}";
}
if (!is_null($timezone)) {
$new_value .= " {$timezone}";
}
return $new_value;
}
}
}
return '';
}
示例4: getHTML
public static function getHTML($cur_value, $input_name, $is_mandatory, $is_disabled, $other_args)
{
global $sfgTabIndex, $sfgFieldNum, $sfgShowOnSelect;
// Standardize $cur_value
if (is_null($cur_value)) {
$cur_value = '';
}
$className = $is_mandatory ? 'mandatoryField' : 'createboxInput';
if (array_key_exists('class', $other_args)) {
$className .= ' ' . $other_args['class'];
}
$input_id = "input_{$sfgFieldNum}";
if (array_key_exists('show on select', $other_args)) {
$className .= ' sfShowIfSelected';
foreach ($other_args['show on select'] as $div_id => $options) {
if (array_key_exists($input_id, $sfgShowOnSelect)) {
$sfgShowOnSelect[$input_id][] = array($options, $div_id);
} else {
$sfgShowOnSelect[$input_id] = array(array($options, $div_id));
}
}
}
$innerDropdown = '';
// Add a blank value at the beginning, unless this is a
// mandatory field and there's a current value in place
// (either through a default value or because we're editing
// an existing page).
if (!$is_mandatory || $cur_value === '') {
$innerDropdown .= "\t<option value=\"\"></option>\n";
}
if (($possible_values = $other_args['possible_values']) == null) {
// If it's a Boolean property, display 'Yes' and 'No'
// as the values.
if (array_key_exists('property_type', $other_args) && $other_args['property_type'] == '_boo') {
$possible_values = array(SFUtils::getWordForYesOrNo(true), SFUtils::getWordForYesOrNo(false));
} else {
$possible_values = array();
}
}
foreach ($possible_values as $possible_value) {
$optionAttrs = array('value' => $possible_value);
if ($possible_value == $cur_value) {
$optionAttrs['selected'] = "selected";
}
if (array_key_exists('value_labels', $other_args) && is_array($other_args['value_labels']) && array_key_exists($possible_value, $other_args['value_labels'])) {
$label = $other_args['value_labels'][$possible_value];
} else {
$label = $possible_value;
}
$innerDropdown .= Html::element('option', $optionAttrs, $label);
}
$selectAttrs = array('id' => $input_id, 'tabindex' => $sfgTabIndex, 'name' => $input_name, 'class' => $className);
if ($is_disabled) {
$selectAttrs['disabled'] = 'disabled';
}
if (array_key_exists('origName', $other_args)) {
$selectAttrs['origname'] = $other_args['origName'];
}
$text = Html::rawElement('select', $selectAttrs, $innerDropdown);
$spanClass = 'inputSpan';
if ($is_mandatory) {
$spanClass .= ' mandatoryFieldSpan';
}
$text = Html::rawElement('span', array('class' => $spanClass), $text);
return $text;
}