當前位置: 首頁>>代碼示例>>PHP>>正文


PHP StringUtils::jsEscape方法代碼示例

本文整理匯總了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') {
//.........這裏部分代碼省略.........
開發者ID:wb-crowdfusion,項目名稱:crowdfusion,代碼行數:101,代碼來源:AbstractCmsBuilder.php

示例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'));
 }
開發者ID:wb-crowdfusion,項目名稱:crowdfusion,代碼行數:15,代碼來源:DisplayFilterer.php


注:本文中的StringUtils::jsEscape方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。