printJsValue() 공개 정적인 메소드

Prints an javascript assignment with proper escaping of a value and support for assigning array of strings.
public static printJsValue ( string $key, mixed $value ) : void
$key string Name of value to set
$value mixed Value to set, can be either string or array of strings
리턴 void
예제 #1
0
}
$response = Response::getInstance();
$header = $response->getHeader();
$scripts = $header->getScripts();
$scripts->addFile('config.js');
require 'libraries/user_preferences.inc.php';
if ($error) {
    if (!$error instanceof Message) {
        $error = Message::error($error);
    }
    $error->display();
}
?>
<script type="text/javascript">
<?php 
Sanitize::printJsValue("PMA_messages['strSavedOn']", __('Saved on: @DATE@'));
?>
</script>
<div id="maincontainer">
    <div id="main_pane_left">
        <div class="group">
<?php 
echo '<h2>', __('Import'), '</h2>', '<form class="group-cnt prefs-form disableAjax" name="prefs_import"', ' action="prefs_manage.php" method="post" enctype="multipart/form-data">', Util::generateHiddenMaxFileSize($GLOBALS['max_upload_size']), URL::getHiddenInputs(), '<input type="hidden" name="json" value="" />', '<input type="radio" id="import_text_file" name="import_type"', ' value="text_file" checked="checked" />', '<label for="import_text_file">' . __('Import from file') . '</label>', '<div id="opts_import_text_file" class="prefsmanage_opts">', '<label for="input_import_file">', __('Browse your computer:'), '</label>', '<input type="file" name="import_file" id="input_import_file" />', '</div>', '<input type="radio" id="import_local_storage" name="import_type"', ' value="local_storage" disabled="disabled" />', '<label for="import_local_storage">', __('Import from browser\'s storage'), '</label>', '<div id="opts_import_local_storage" class="prefsmanage_opts disabled">', '<div class="localStorage-supported">', __('Settings will be imported from your browser\'s local storage.'), '<br />', '<div class="localStorage-exists">', __('Saved on: @DATE@'), '</div>', '<div class="localStorage-empty">';
Message::notice(__('You have no saved settings!'))->display();
echo '</div>', '</div>', '<div class="localStorage-unsupported">';
Message::notice(__('This feature is not supported by your web browser'))->display();
echo '</div>', '</div>', '<input type="checkbox" id="import_merge" name="import_merge" />', '<label for="import_merge">', __('Merge with current configuration') . '</label>', '<br /><br />', '<input type="submit" name="submit_import" value="', __('Go') . '" />', '</form>', '</div>';
if (file_exists('setup/index.php')) {
    // show only if setup script is available, allows to disable this message
    // by simply removing setup directory
    ?>
예제 #2
0
/* l10n: Column header for week of the year in calendar */
Sanitize::printJsValue("\$.datepicker.regional['']['weekHeader']", __('Wk'));
Sanitize::printJsValue("\$.datepicker.regional['']['showMonthAfterYear']", __('calendar-month-year') == 'calendar-year-month');
/* l10n: Year suffix for calendar, "none" is empty. */
$year_suffix = _pgettext('Year suffix', 'none');
Sanitize::printJsValue("\$.datepicker.regional['']['yearSuffix']", $year_suffix == 'none' ? '' : $year_suffix);
?>
$.extend($.datepicker._defaults, $.datepicker.regional['']);
} /* if ($.datepicker) */

<?php 
echo "if (\$.timepicker) {\n";
Sanitize::printJsValue("\$.timepicker.regional['']['timeText']", __('Time'));
Sanitize::printJsValue("\$.timepicker.regional['']['hourText']", __('Hour'));
Sanitize::printJsValue("\$.timepicker.regional['']['minuteText']", __('Minute'));
Sanitize::printJsValue("\$.timepicker.regional['']['secondText']", __('Second'));
?>
$.extend($.timepicker._defaults, $.timepicker.regional['']);
} /* if ($.timepicker) */

<?php 
/* Form validation */
echo "function extendingValidatorMessages() {\n";
echo "\$.extend(\$.validator.messages, {\n";
/* Default validation functions */
Sanitize::printJsValueForFormValidation('required', __('This field is required'));
Sanitize::printJsValueForFormValidation('remote', __('Please fix this field'));
Sanitize::printJsValueForFormValidation('email', __('Please enter a valid email address'));
Sanitize::printJsValueForFormValidation('url', __('Please enter a valid URL'));
Sanitize::printJsValueForFormValidation('date', __('Please enter a valid date'));
Sanitize::printJsValueForFormValidation('dateISO', __('Please enter a valid date ( ISO )'));