本文整理汇总了PHP中StringUtils::jsEscape方法的典型用法代码示例。如果您正苦于以下问题:PHP StringUtils::jsEscape方法的具体用法?PHP StringUtils::jsEscape怎么用?PHP StringUtils::jsEscape使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类StringUtils
的用法示例。
在下文中一共展示了StringUtils::jsEscape方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _buildWidgetOptions
protected function _buildWidgetOptions($schemafield, $attributes)
{
$partial = $schemafield->Partial;
$filter = $schemafield->Filter;
$is_multiple = $schemafield->isMultiple();
$is_quickadd = $schemafield->isQuickadd();
$is_sortable = $schemafield->isSortable();
$tag_direction = $schemafield->Direction;
if (empty($tag_direction)) {
$tag_direction = 'out';
}
if (!empty($attributes['title'])) {
$title = $attributes['title'];
} else {
$title = $schemafield->Title;
}
$value_opts = $schemafield->ValueOptions;
$value_is_multiple = false;
$pre_values = array();
$values_name = 'role';
if (!empty($value_opts)) {
$value_mode = $value_opts->Mode;
$values_name = $value_opts->Name;
$value_is_multiple = $value_opts->isMultiple();
if ($value_mode != 'none') {
$pre_values = $value_opts->Values;
}
} else {
$value_mode = 'none';
}
$title = StringUtils::jsEscape($title);
$title_plural = $title;
//StringUtils::pluralize($title);
$opt[] = "\t\t\tLabel: '{$title}'";
$opt[] = "\t\t\tLabelPlural: '{$title_plural}'";
$opt[] = "\t\t\tActivateButtonLabel: '{$title}'";
$element = $partial->getTagElement();
if (empty($element)) {
$element = '@' . $partial->getTagAspect();
}
$quickaddelement = $element;
if (!empty($attributes['quick-add-element'])) {
$quickaddelement = $attributes['quick-add-element'];
}
$quickaddaction = 'node-quick-add';
if (!empty($attributes['quick-add-action'])) {
$quickaddaction = $attributes['quick-add-action'];
}
if (!empty($attributes['search-parameters'])) {
$str = array();
$params = explode('&', urldecode($attributes['search-parameters']));
foreach ($params as $param) {
list($k, $v) = explode('=', $param, 2);
$str[] = "'" . $k . "' : '" . $v . "'";
}
$opt[] = "\t\t\tSearchParameters: {" . implode(',', $str) . "}";
} else {
$opt[] = "\t\t\tSearchParameters: {'Elements.in' : '{$element}'}";
//Title keyword is auto-added by widget
}
if (!empty($attributes['search-url'])) {
$opt[] = "\t\t\tSearchURL: '{$attributes['search-url']}'";
}
if (!empty($attributes['show-element'])) {
$opt[] = "\t\t\tShowElementInChosenList: true";
$opt[] = "\t\t\tShowElementInSearchResults: true";
}
if ($tag_direction != 'out') {
$opt[] = "\t\tTagDirection: '{$tag_direction}'";
}
if (!empty($filter)) {
$opt[] = "\t\tTagFilter: '" . $filter . "'";
}
if ($is_quickadd) {
$opt[] = "\t\t\tAllowQuickAdd: true";
$opt[] = "\t\t\tQuickAddNonce: '{% filter nonce?action={$quickaddaction} %}'";
$opt[] = "\t\t\tAddTagNonce: '{% filter nonce?action=node-add-tag %}'";
$opt[] = "\t\t\tReplaceNonce: '{% filter nonce?action=node-replace %}'";
$opt[] = "\t\t\tQuickAddElement : '{$quickaddelement}'";
$opt[] = "\t\t\tEditNonce: '{% filter nonce?action=node-edit %}'";
}
if ($is_multiple) {
$opt[] = "\t\t\tAllowMultiple: " . ($is_multiple ? 'true' : 'false') . "";
}
if ($is_sortable) {
$opt[] = "\t\t\tAllowReorderChosenList: " . ($is_sortable ? 'true' : 'false') . "";
}
if ($value_mode != 'none') {
$opt[] = "\t\tValueMode: '{$value_mode}'";
$opt[] = "\t\tAllowMultipleValues: " . ($value_is_multiple ? 'true' : 'false') . "";
if (!empty($pre_values)) {
foreach ((array) $pre_values as $dname => $dvalue) {
$array[] = array('value' => $dname, 'display' => $dvalue);
}
$opt[] = "\t\tValues: " . json_encode($array) . "";
}
if (count($pre_values) == 1) {
$opt[] = "\t\tShowExistingValues: false";
} else {
if ($value_mode == 'typein') {
//.........这里部分代码省略.........
示例2: jsEscape
/**
* Escapes the specified parameter in 'value' for use in javascript
*
* Expected Param:
* value string
*
* @return string
*/
public function jsEscape()
{
if ($this->getParameter('value') == null) {
return;
}
return StringUtils::jsEscape($this->getParameter('value'));
}