本文整理汇总了PHP中escape_js函数的典型用法代码示例。如果您正苦于以下问题:PHP escape_js函数的具体用法?PHP escape_js怎么用?PHP escape_js使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了escape_js函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generate_autocomplete
function generate_autocomplete($id, $options)
{
global $autocomplete_length_breaks;
$js = '';
// Turn the array into a simple, numerically indexed, array
$options = array_values($options);
$n_options = count($options);
if ($n_options > 0) {
// Work out a suitable value for the autocomplete minLength
// option, ie the number of characters that must be typed before
// a list of options appears. We want to avoid presenting a huge
// list of options.
$min_length = 0;
if (isset($autocomplete_length_breaks) && is_array($autocomplete_length_breaks)) {
foreach ($autocomplete_length_breaks as $break) {
if ($n_options < $break) {
break;
}
$min_length++;
}
}
// Start forming the array literal
// Escape the options
for ($i = 0; $i < $n_options; $i++) {
$options[$i] = escape_js($options[$i]);
}
$options_string = "'" . implode("','", $options) . "'";
// Build the JavaScript. We don't support autocomplete in IE6 and below
// because the browser doesn't render the autocomplete box properly - it
// gets hidden behind other elements. Although there are fixes for this,
// it's not worth it ...
$js .= "if (!lteIE6)\n";
$js .= "{\n";
$js .= " \$('#{$id}').autocomplete({\n";
$js .= " source: [{$options_string}],\n";
$js .= " minLength: {$min_length}\n";
$js .= " })";
// If the minLength is 0, then the autocomplete widget doesn't do
// quite what you might expect and you need to force it to display
// the available options when it receives focus
if ($min_length == 0) {
$js .= ".focus(function() {\n";
$js .= " \$(this).autocomplete('search', '');\n";
$js .= " })";
}
$js .= " ;\n";
$js .= "}\n";
}
return $js;
}
示例2: create_field_entry_areas
function create_field_entry_areas($disabled = FALSE)
{
global $areas, $area_id, $rooms;
echo "<div id=\"div_areas\">\n";
echo "</div>\n";
// if there is more than one area then give the option
// to choose areas.
if (count($areas) > 1) {
?>
<script type="text/javascript">
//<![CDATA[
var area = <?php
echo $area_id;
?>
;
function changeRooms( formObj )
{
areasObj = eval( "formObj.area" );
area = areasObj[areasObj.selectedIndex].value;
roomsObj = eval( "formObj.elements['rooms']" );
// remove all entries
roomsNum = roomsObj.length;
for (i=(roomsNum-1); i >= 0; i--)
{
roomsObj.options[i] = null;
}
// add entries based on area selected
switch (area){
<?php
foreach ($areas as $a) {
print "case \"" . $a['id'] . "\":\n";
// get rooms for this area
$i = 0;
foreach ($rooms as $r) {
if ($r['area_id'] == $a['id']) {
print "roomsObj.options[{$i}] = new Option(\"" . escape_js($r['room_name']) . "\"," . $r['id'] . ");\n";
$i++;
}
}
// select the first entry by default to ensure
// that one room is selected to begin with
if ($i > 0) {
print "roomsObj.options[0].selected = true;\n";
}
print "break;\n";
}
?>
} //switch
<?php
// Replace the start and end selectors with those for the new area
// (1) We set the display for the old elements to "none" and the new
// elements to "block". (2) We also need to disable the old selectors and
// enable the new ones: they all have the same name, so we only want
// one passed through with the form. (3) We take a note of the currently
// selected start and end values so that we can have a go at finding a
// similar time/period in the new area. (4) We also take a note of the old
// area id because we'll need that when trying to match up slots: it only
// makes sense to match up slots if both old and new area used the same
// mode (periods/times).
// For the "all day" checkbox, the process is slightly different. This
// is because the checkboxes themselves are visible or not depending on
// the time restrictions for that particular area. (1) We set the display
// for the old *container* element to "none" and the new elements to
// "block". (2) We disable the old checkboxes and enable the new ones for
// the same reasons as above. (3) We copy the value of the old check box
// to the new check box
?>
var oldStartId = "start_seconds" + currentArea;
var oldEndId = "end_seconds" + currentArea;
var newStartId = "start_seconds" + area;
var newEndId = "end_seconds" + area;
var oldAllDayId = "ad" + currentArea;
var newAllDayId = "ad" + area;
var oldAreaStartValue = formObj[oldStartId].options[formObj[oldStartId].selectedIndex].value;
var oldAreaEndValue = formObj[oldEndId].options[formObj[oldEndId].selectedIndex].value;
$("#" + oldStartId).hide()
.attr('disabled', 'disabled');
$("#" + oldEndId).hide()
.attr('disabled', 'disabled');
$("#" + newStartId).show()
.removeAttr('disabled');
$("#" + newEndId).show()
.removeAttr('disabled');
+ $("#" + oldAllDayId).hide();
$("#" + newAllDayId).show();
if($("#all_day" + currentArea).attr('checked') == 'checked')
{
$("#all_day" + area).attr('checked', 'checked').removeAttr('disabled');
}
else
{
$("#all_day" + area).removeAttr('checked').removeAttr('disabled');
}
$("#all_day" + currentArea).removeAttr('disabled');
//.........这里部分代码省略.........
示例3: escape_js
defaultOptions.bProcessing = true;
defaultOptions.bScrollCollapse = true;
defaultOptions.bStateSave = true;
defaultOptions.iDisplayLength = 25;
defaultOptions.sDom = 'C<"clear">lfrtip';
defaultOptions.sScrollX = "100%";
defaultOptions.sPaginationType = "full_numbers";
defaultOptions.oColReorder = {};
defaultOptions.oColVis = {sSize: "auto",
buttonText: '<?php
echo escape_js(get_vocab("show_hide_columns"));
?>
',
bRestore: true,
sRestore: '<?php
echo escape_js(get_vocab("restore_original"));
?>
'};
defaultOptions.fnInitComplete = function(){
if (((leftCol !== undefined) && (leftCol !== null)) ||
((rightCol !== undefined) && (rightCol !== null)) )
{
<?php
// Fix the left and/or right columns. This has to be done when
// initialisation is complete as the language files are loaded
// asynchronously
?>
var options = {};
if ((leftCol !== undefined) && (leftCol !== null))
示例4: escape_js
{
alertMessage += '<?php
echo escape_js(mrbs_entity_decode(get_vocab("conflict")));
?>
' + ": \n\n";
var conflictsList = getErrorList(result.conflicts);
alertMessage += conflictsList.text;
}
if (result.rules_broken.length > 0)
{
if (result.conflicts.length > 0)
{
alertMessage += "\n\n";
}
alertMessage += '<?php
echo escape_js(mrbs_entity_decode(get_vocab("rules_broken")));
?>
' + ": \n\n";
var rulesList = getErrorList(result.rules_broken);
alertMessage += rulesList.text;
}
window.alert(alertMessage);
}
turnOnPageRefresh();
},
'json');
} <?php
// if (rectanglesIdentical(r1, r2))
?>
}; <?php
示例5: my_name_is
/**
* AJAX response handler for the 'my_name_is' step
*/
static function my_name_is()
{
// Grab the new name from POST data
$in = ps('my_name');
// ...further processing might go here: Database updates, input validation, ...
self::$my_name = $in;
// Prepare response string
$in = escape_js($in);
// Send a javascript response to render this posted data back into the document's headline.
// Find the target HTML fragment via jQuery through its selector '#my_name_output'
// and replace its text.
send_script_response(<<<EOS
\t\t\$('#my_name_output').text('{$in}');
EOS
);
}
示例6: section_save
function section_save()
{
global $txpcfg, $app_mode;
extract(doSlash(psa(array('page', 'css', 'old_name'))));
extract(psa(array('name', 'title')));
$prequel = '';
$sequel = '';
if (empty($title)) {
$title = $name;
}
// Prevent non url chars on section names
include_once txpath . '/lib/classTextile.php';
$textile = new Textile();
$title = doSlash($textile->TextileThis($title, 1));
$name = doSlash(sanitizeForUrl($name));
if ($old_name && strtolower($name) != strtolower($old_name)) {
if (safe_field('name', 'txp_section', "name='{$name}'")) {
$message = array(gTxt('section_name_already_exists', array('{name}' => $name)), E_ERROR);
if ($app_mode == 'async') {
// TODO: Better/themeable popup
send_script_response('window.alert("' . escape_js(strip_tags(gTxt('section_name_already_exists', array('{name}' => $name)))) . '")');
} else {
sec_section_list($message);
return;
}
}
}
if ($name == 'default') {
safe_update('txp_section', "page = '{$page}', css = '{$css}'", "name = 'default'");
update_lastmod();
} else {
extract(array_map('assert_int', psa(array('is_default', 'on_frontpage', 'in_rss', 'searchable'))));
// note this means 'selected by default' not 'default page'
if ($is_default) {
safe_update("txp_section", "is_default = 0", "name != '{$old_name}'");
// switch off $is_default for all sections in async app_mode
if ($app_mode == 'async') {
$prequel = '$("input[name=\\"is_default\\"][value=\\"1\\"]").attr("checked", false);' . '$("input[name=\\"is_default\\"][value=\\"0\\"]").attr("checked", true);';
}
}
safe_update('txp_section', "\n\t\t\t\tname = '{$name}',\n\t\t\t\ttitle = '{$title}',\n\t\t\t\tpage = '{$page}',\n\t\t\t\tcss = '{$css}',\n\t\t\t\tis_default = {$is_default},\n\t\t\t\ton_frontpage = {$on_frontpage},\n\t\t\t\tin_rss = {$in_rss},\n\t\t\t\tsearchable = {$searchable}\n\t\t\t", "name = '{$old_name}'");
safe_update('textpattern', "Section = '{$name}'", "Section = '{$old_name}'");
update_lastmod();
}
$message = gTxt('section_updated', array('{name}' => $name));
if ($app_mode == 'async') {
// Caveat: Use unslashed params for DTO
$s = psa(array('name', 'title', 'page', 'css')) + compact('is_default', 'on_frontpage', 'in_rss', 'searchable');
$s = section_detail_partial($s);
send_script_response($prequel . '$("#section-form-' . $name . '").replaceWith("' . escape_js($s) . '");' . $sequel);
} else {
sec_section_list($message);
}
}
示例7: article_edit
//.........这里部分代码省略.........
// Next record?
$rs['next_id'] = checkIfNeighbour('next', $sPosted);
} else {
$rs['prev_id'] = $rs['next_id'] = 0;
}
// Let plugins chime in on partials meta data.
callback_event_ref('article_ui', 'partials_meta', 0, $rs, $partials);
$rs['partials_meta'] =& $partials;
// Get content for volatile partials.
foreach ($partials as $k => $p) {
if ($p['mode'] == PARTIAL_VOLATILE || $p['mode'] == PARTIAL_VOLATILE_VALUE) {
$cb = $p['cb'];
$partials[$k]['html'] = is_array($cb) ? call_user_func($cb, $rs, $k) : $cb($rs, $k);
}
}
if ($refresh_partials) {
$response[] = announce($message);
$response[] = '$("#article_form [type=submit]").val(textpattern.gTxt("save"))';
if ($Status < STATUS_LIVE) {
$response[] = '$("#article_form").addClass("saved").removeClass("published")';
} else {
$response[] = '$("#article_form").addClass("published").removeClass("saved")';
}
// Update the volatile partials.
foreach ($partials as $k => $p) {
// Volatile partials need a target DOM selector.
if (empty($p['selector']) && $p['mode'] != PARTIAL_STATIC) {
trigger_error("Empty selector for partial '{$k}'", E_USER_ERROR);
} else {
// Build response script.
if ($p['mode'] == PARTIAL_VOLATILE) {
// Volatile partials replace *all* of the existing HTML
// fragment for their selector.
$response[] = '$("' . $p['selector'] . '").replaceWith("' . escape_js($p['html']) . '")';
} elseif ($p['mode'] == PARTIAL_VOLATILE_VALUE) {
// Volatile partial values replace the *value* of elements
// matching their selector.
$response[] = '$("' . $p['selector'] . '").val("' . escape_js($p['html']) . '")';
}
}
}
send_script_response(join(";\n", $response));
// Bail out.
return;
}
foreach ($partials as $k => $p) {
if ($p['mode'] == PARTIAL_STATIC) {
$cb = $p['cb'];
$partials[$k]['html'] = is_array($cb) ? call_user_func($cb, $rs, $k) : $cb($rs, $k);
}
}
$page_title = $ID ? $Title : gTxt('write');
pagetop($page_title, $message);
$class = array();
if ($Status >= STATUS_LIVE) {
$class[] = 'published';
} elseif ($ID) {
$class[] = 'saved';
}
if ($step !== 'create') {
$class[] = 'async';
}
echo n . tag_start('form', array('class' => $class, 'id' => 'article_form', 'name' => 'article_form', 'method' => 'post', 'action' => 'index.php'));
if (!empty($store_out)) {
echo hInput('store', base64_encode(serialize($store_out)));
}
示例8: article_edit
//.........这里部分代码省略.........
$textile_body = $use_textile;
$textile_excerpt = $use_textile;
}
if ($step != 'create' && isset($sPosted)) {
// Previous record?
$rs['prev_id'] = checkIfNeighbour('prev', $sPosted);
// Next record?
$rs['next_id'] = checkIfNeighbour('next', $sPosted);
} else {
$rs['prev_id'] = $rs['next_id'] = 0;
}
// let plugins chime in on partials meta data
callback_event_ref('article_ui', 'partials_meta', 0, $rs, $partials);
$rs['partials_meta'] =& $partials;
// get content for volatile partials
foreach ($partials as $k => $p) {
if ($p['mode'] == PARTIAL_VOLATILE || $p['mode'] == PARTIAL_VOLATILE_VALUE) {
$cb = $p['cb'];
$partials[$k]['html'] = is_array($cb) ? call_user_func($cb, $rs, $k) : $cb($rs, $k);
}
}
if ($refresh_partials) {
global $theme;
$response[] = $theme->announce_async($message);
// update the volatile partials
foreach ($partials as $k => $p) {
// volatile partials need a target DOM selector
if (empty($p['selector']) && $p['mode'] != PARTIAL_STATIC) {
trigger_error("Empty selector for partial '{$k}'", E_USER_ERROR);
} else {
// build response script
if ($p['mode'] == PARTIAL_VOLATILE) {
// volatile partials replace *all* of the existing HTML fragment for their selector
$response[] = '$("' . $p['selector'] . '").replaceWith("' . escape_js($p['html']) . '")';
} elseif ($p['mode'] == PARTIAL_VOLATILE_VALUE) {
// volatile partial values replace the *value* of elements matching their selector
$response[] = '$("' . $p['selector'] . '").val("' . escape_js($p['html']) . '")';
}
}
}
send_script_response(join(";\n", $response));
// bail out
return;
}
foreach ($partials as $k => $p) {
if ($p['mode'] == PARTIAL_STATIC) {
$cb = $p['cb'];
$partials[$k]['html'] = is_array($cb) ? call_user_func($cb, $rs, $k) : $cb($rs, $k);
}
}
$page_title = $Title ? $Title : gTxt('write');
pagetop($page_title, $message);
echo n . '<div id="' . $event . '_container" class="txp-container">';
echo n . n . '<form id="article_form" name="article_form" method="post" action="index.php" ' . ($step == 'create' ? '>' : ' class="async">');
if (!empty($store_out)) {
echo hInput('store', base64_encode(serialize($store_out)));
}
echo hInput('ID', $ID) . n . eInput('article') . n . sInput($step) . n . hInput('sPosted', $sPosted) . n . hInput('sLastMod', $sLastMod) . n . hInput('AuthorID', $AuthorID) . n . hInput('LastModID', $LastModID) . '<input type="hidden" name="view" />' . startTable('', '', 'txp-columntable') . '<tr>' . n . '<td id="article-col-1"><div id="configuration_content">';
if ($view == 'text') {
//-- markup help --------------
echo pluggable_ui('article_ui', 'sidehelp', side_help($textile_body, $textile_excerpt), $rs);
//-- custom menu entries --------------
echo pluggable_ui('article_ui', 'extend_col_1', '', $rs);
//-- advanced --------------
echo '<div id="advanced_group"><h3 class="lever' . (get_pref('pane_article_advanced_visible') ? ' expanded' : '') . '"><a href="#advanced">' . gTxt('advanced_options') . '</a></h3>' . '<div id="advanced" class="toggle" style="display:' . (get_pref('pane_article_advanced_visible') ? 'block' : 'none') . '">';
// markup selection
示例9: escape_js
return false;
}
<?php
// Remove the <colgroup>. This is only needed to assist in the formatting
// of the non-datatable version of the table. When we have a datatable,
// the datatable sorts out its own formatting.
?>
table.find('colgroup').remove();
<?php
// Set up the default options
?>
defaultOptions = {
buttons: [{extend: 'colvis',
text: '<?php
echo escape_js(get_vocab("show_hide_columns"));
?>
'}],
deferRender: true,
paging: true,
pageLength: 25,
pagingType: 'full_numbers',
processing: true,
scrollCollapse: true,
stateSave: true,
dom: 'B<"clear">lfrtip',
scrollX: '100%',
colReorder: {}
};
<?php
示例10: escape_js
if (preg_match("~{$search}~i", $row['address'])) {
$descriptions[$row['id']] = escape_js(trans('Address:') . ' ' . $row['address']);
continue;
} else {
if (preg_match("~{$search}~i", $row['post_name'])) {
$descriptions[$row['id']] = escape_js(trans('Name:') . ' ' . $row['post_name']);
continue;
} else {
if (preg_match("~{$search}~i", $row['post_address'])) {
$descriptions[$row['id']] = escape_js(trans('Address:') . ' ' . $row['post_address']);
continue;
}
}
}
if (preg_match("~{$search}~i", $row['email'])) {
$descriptions[$row['id']] = escape_js(trans('E-mail:') . ' ' . $row['email']);
continue;
}
$descriptions[$row['id']] = '';
}
}
header('Content-type: text/plain');
if ($eglible) {
print "this.eligible = [\"" . implode('","', $eglible) . "\"];\n";
print "this.descriptions = [\"" . implode('","', $descriptions) . "\"];\n";
print "this.actions = [\"" . implode('","', $actions) . "\"];\n";
} else {
print "false;\n";
}
exit;
}
示例11: escape_js
return false;
}
}
}
<?php
}
?>
if ((thisValue > startValue) ||
((thisValue === startValue) && enablePeriods) ||
(dateDifference !== 0))
{
optionClone = $(this).clone();
if (dateDifference < 0)
{
optionClone.text('<?php
echo escape_js(get_vocab("start_after_end"));
?>
');
}
else
{
optionClone.text($(this).text() + nbsp + nbsp +
'(' + getDuration(startValue, thisValue, dateDifference) +
')');
}
endSelect.append(optionClone);
}
});
endValue = Math.min(endValue, parseInt(endSelect.find('option').last().val(), 10));
endSelect.val(endValue);
示例12: function
area_select.setAttribute('name', 'area');
area_select.onchange = function(){changeRooms(this.form)}; // setAttribute doesn't work for onChange with IE6
// populated with options
var option;
var option_text
<?php
// go through the areas and create the options
foreach ($areas as $a) {
?>
option = document.createElement('option');
option.value = <?php
echo $a['id'];
?>
;
option_text = document.createTextNode('<?php
echo escape_js($a['area_name']);
?>
');
<?php
if ($a['id'] == $area_id) {
?>
option.selected = true;
<?php
}
?>
option.appendChild(option_text);
area_select.appendChild(option);
<?php
}
?>
// insert the <select> which we've just assembled into the <div>
示例13: update
/**
* Hooks to article saving process and updates short URLs
*/
public static function update()
{
global $prefs;
if (empty($prefs['rah_bitly_login']) || empty($prefs['rah_bitly_apikey']) || empty($prefs['rah_bitly_field'])) {
return;
}
static $old = array();
static $updated = false;
$id = !empty($GLOBALS['ID']) ? $GLOBALS['ID'] : ps('ID');
if (!$id || ps('_txp_token') != form_token() || intval(ps('Status')) < 4) {
$old = array('permlink' => NULL, 'status' => NULL);
return;
}
include_once txpath . '/publish/taghandlers.php';
/*
Get the old article permlink before anything is saved
*/
if (!$old) {
$old = array('permlink' => permlinkurl_id($id), 'status' => fetch('Status', 'textpattern', 'ID', $id));
return;
}
/*
Clear the permlink cache
*/
unset($GLOBALS['permlinks'][$id]);
/*
Generate a new if permlink has changed or if article is published
*/
if (callback_event('rah_bitly.update') !== '') {
return;
}
if ($updated == false && ($permlink = permlinkurl_id($id)) && ($old['permlink'] != $permlink || !ps('custom_' . $prefs['rah_bitly_field']) || $old['status'] != ps('Status'))) {
$uri = self::fetch($permlink);
if ($uri) {
$fields = getCustomFields();
if (!isset($fields[$prefs['rah_bitly_field']])) {
return;
}
safe_update('textpattern', 'custom_' . intval($prefs['rah_bitly_field']) . "='" . doSlash($uri) . "'", "ID='" . doSlash($id) . "'");
$_POST['custom_' . $prefs['rah_bitly_field']] = $uri;
}
$updated = true;
}
if (!empty($uri)) {
echo script_js('$(\'input[name="custom_' . $prefs['rah_bitly_field'] . '"]\').val("' . escape_js($uri) . '");');
}
}
示例14: header
return $JSResponse;
}
$LMS->InitXajax();
$LMS->RegisterXajaxFunction(array('getGroupTableRow'));
$SMARTY->assign('xajax', $LMS->RunXajax());
if (isset($_GET['ajax'])) {
header('Content-type: text/plain');
$search = urldecode(trim($_GET['what']));
$result = $DB->GetAll('SELECT id, name as item
FROM voip_prefix_groups
WHERE name ?LIKE? ?
LIMIT 20', array('%' . $search . '%'));
$eglible = $descriptions = array();
if ($result) {
foreach ($result as $idx => $row) {
$eglible[$row['item']] = escape_js($row['item']);
$descriptions[$row['item']] = $row['id'] . ' :id';
}
}
if ($eglible) {
print "this.eligible = [\"" . implode('","', $eglible) . "\"];\n";
print "this.descriptions = [\"" . implode('","', $descriptions) . "\"];\n";
} else {
print "false;\n";
}
exit;
}
$rule = isset($_POST['rule']) ? $_POST['rule'] : NULL;
$rule_id = isset($_GET['id']) ? (int) $_GET['id'] : 0;
$error = array();
if (isset($_GET['action']) && $_GET['action'] == 'delete') {
示例15: escape_js
// Check whether everything has finished
?>
if (results.length >= nBatches)
{
$('#report_table_processing').css('visibility', 'hidden');
<?php
// If all's gone well the result will contain the number of entries deleted
?>
nDeleted = 0;
isInt = /^\s*\d+\s*$/;
for (i=0; i<results.length; i++)
{
if (!isInt.test(results[i]))
{
window.alert("<?php
echo escape_js(get_vocab('delete_entries_failed'));
?>
");
break;
}
nDeleted += parseInt(results[i], 10);
}
<?php
// Reload the page to get the new dataset. If we're using
// an Ajax data source (for true Ajax data sources, not server
// side processing) and there's no summary table we can be
// slightly more elegant and just reload the Ajax data source.
?>
oSettings = reportTable.fnSettings();
if (oSettings.ajax &&
!oSettings.bServerSide &&