本文整理汇总了PHP中JavaScriptHelper::escapeString方法的典型用法代码示例。如果您正苦于以下问题:PHP JavaScriptHelper::escapeString方法的具体用法?PHP JavaScriptHelper::escapeString怎么用?PHP JavaScriptHelper::escapeString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类JavaScriptHelper
的用法示例。
在下文中一共展示了JavaScriptHelper::escapeString方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: remoteFunction
/**
* Creates JavaScript function for remote AJAX call
*
* This function creates the javascript needed to make a remote call
* it is primarily used as a helper for AjaxHelper::link.
*
* @param array $options options for javascript
* @return string html code for link to remote action
* @see AjaxHelper::link() for docs on options parameter.
*/
function remoteFunction($options)
{
if (isset($options['update'])) {
if (!is_array($options['update'])) {
$func = "new Ajax.Updater('{$options['update']}',";
} else {
$func = "new Ajax.Updater(document.createElement('div'),";
}
if (!isset($options['requestHeaders'])) {
$options['requestHeaders'] = array();
}
if (is_array($options['update'])) {
$options['update'] = join(' ', $options['update']);
}
$options['requestHeaders']['X-Update'] = $options['update'];
} else {
$func = "new Ajax.Request(";
}
$func .= "'" . $this->url(isset($options['url']) ? $options['url'] : "") . "'";
$func .= ", " . $this->__optionsForAjax($options) . ")";
if (isset($options['before'])) {
$func = "{$options['before']}; {$func}";
}
if (isset($options['after'])) {
$func = "{$func}; {$options['after']};";
}
if (isset($options['condition'])) {
$func = "if ({$options['condition']}) { {$func}; }";
}
if (isset($options['confirm'])) {
$func = "if (confirm('" . $this->Javascript->escapeString($options['confirm']) . "')) { {$func}; } else { event.returnValue = false; return false; }";
}
return $func;
}
示例2: remoteFunction
/**
* Creates JavaScript function for remote AJAX call
*
* This function creates the javascript needed to make a remote call
* it is primarily used as a helper for AjaxHelper::link.
*
* @param array $options options for javascript
* @return string html code for link to remote action
* @see AjaxHelper::link() for docs on options parameter.
*/
function remoteFunction($options) {
if (isset($options['update'])) {
if (isset($options['position'])){
$position = $options['position'];
unset($options['position']);
}
else{
$position = 'html';
}
if (!is_array($options['update'])) {
$func = "$.ajax(";
if (!isset($options['complete'])){
$options['complete'] = '';
}
$options['complete'] = "$('#" . $options['update'] . "').$position(request.responseText); " . $options['complete'];
} else {
$func = "$.ajax(";
if (!isset($options['complete'])){
$options['complete'] = '';
}
$selectors = '';
foreach($options['update'] as $selector){
$selectors .= '#' . $selector . ', ';
}
$options['complete'] = "$('" . $selectors . "').$position(request.responseText); " . $options['complete'];
}
if (is_array($options['update'])) {
$options['update'] = join(' ', $options['update']);
}
} else {
$func = "$.ajax(";
}
$options['url'] = $this->url(isset($options['url']) ? $options['url'] : "");
$func .= $this->__optionsForAjax($options) . ")";
if (isset($options['before'])) {
$func = "{$options['before']}; $func";
}
if (isset($options['after'])) {
$func = "$func; {$options['after']};";
}
if (isset($options['condition'])) {
$func = "if ({$options['condition']}) { $func; }";
}
if (isset($options['confirm'])) {
$func = "if (confirm('" . $this->Javascript->escapeString($options['confirm'])
. "')) { $func; } else { return false; }";
}
return $func;
}