当前位置: 首页>>代码示例>>PHP>>正文


PHP Lang::isUnicodeCompiled方法代码示例

本文整理汇总了PHP中Lang::isUnicodeCompiled方法的典型用法代码示例。如果您正苦于以下问题:PHP Lang::isUnicodeCompiled方法的具体用法?PHP Lang::isUnicodeCompiled怎么用?PHP Lang::isUnicodeCompiled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Lang的用法示例。


在下文中一共展示了Lang::isUnicodeCompiled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: checkFields

 /**
  * Check the field's settings to ensure they are valid on the section
  * editor
  *
  * @param array $errors
  *	the array to populate with the errors found.
  * @param boolean $checkForDuplicates (optional)
  *	if set to true, duplicate Field name's in the same section will be flagged
  *  as errors. Defaults to true.
  * @return integer
  *	returns the status of the checking. if errors has been populated with
  *	any errors `self::__ERROR__`, `self::__OK__` otherwise.
  */
 public function checkFields(array &$errors, $checkForDuplicates = true)
 {
     $parent_section = $this->get('parent_section');
     $element_name = $this->get('element_name');
     if (Lang::isUnicodeCompiled()) {
         $valid_name = preg_match('/^[\\p{L}]([0-9\\p{L}\\.\\-\\_]+)?$/u', $this->get('element_name'));
     } else {
         $valid_name = preg_match('/^[A-z]([\\w\\d-_\\.]+)?$/i', $this->get('element_name'));
     }
     if ($this->get('label') == '') {
         $errors['label'] = __('This is a required field.');
     }
     if ($this->get('element_name') == '') {
         $errors['element_name'] = __('This is a required field.');
     } elseif (!$valid_name) {
         $errors['element_name'] = __('Invalid element name. Must be valid %s.', array('<code>QName</code>'));
     } elseif ($checkForDuplicates) {
         if (FieldManager::fetchFieldIDFromElementName($element_name, $parent_section) != $this->get('id')) {
             $errors['element_name'] = __('A field with that element name already exists. Please choose another.');
         }
     }
     return !empty($errors) ? self::__ERROR__ : self::__OK__;
 }
开发者ID:readona,项目名称:symphonyno5,代码行数:36,代码来源:class.field.php

示例2: checkFields

 /**
  * Check the field's settings to ensure they are valid on the section
  * editor
  *
  * @param array $errors
  *	the array to populate with the errors found.
  * @param boolean $checkForDuplicates (optional)
  *	if set to true, duplicate Field name's in the same section will be flagged
  *  as errors. Defaults to true.
  * @return integer
  *	returns the status of the checking. if errors has been populated with
  *	any errors `self::__ERROR__`, `self::__OK__` otherwise.
  */
 public function checkFields(array &$errors, $checkForDuplicates = true)
 {
     $parent_section = $this->get('parent_section');
     $element_name = $this->get('element_name');
     if (Lang::isUnicodeCompiled()) {
         $valid_name = preg_match('/^[\\p{L}]([0-9\\p{L}\\.\\-\\_]+)?$/u', $this->get('element_name'));
     } else {
         $valid_name = preg_match('/^[A-z]([\\w\\d-_\\.]+)?$/i', $this->get('element_name'));
     }
     if ($this->get('label') == '') {
         $errors['label'] = __('This is a required field.');
     }
     if ($this->get('element_name') == '') {
         $errors['element_name'] = __('This is a required field.');
     } elseif (!$valid_name) {
         $errors['element_name'] = __('Invalid element name. Must be valid QName.');
     } elseif ($checkForDuplicates) {
         $sql_id = $this->get('id') ? " AND f.id != '" . $this->get('id') . "' " : '';
         $sql = "\n\t\t\t\t\tSELECT\n\t\t\t\t\t\tf.*\n\t\t\t\t\tFROM\n\t\t\t\t\t\t`tbl_fields` AS f\n\t\t\t\t\tWHERE\n\t\t\t\t\t\tf.element_name = '{$element_name}'\n\t\t\t\t\t\t{$sql_id}\n\t\t\t\t\t\tAND f.parent_section = '{$parent_section}'\n\t\t\t\t\tLIMIT 1\n\t\t\t\t";
         if (Symphony::Database()->fetchRow(0, $sql)) {
             $errors['element_name'] = __('A field with that element name already exists. Please choose another.');
         }
     }
     return !empty($errors) ? self::__ERROR__ : self::__OK__;
 }
开发者ID:benesch,项目名称:hilton-unar,代码行数:38,代码来源:class.field.php

示例3: stripInvalidXMLCharacters

 /**
  * This function strips characters that are not allowed in XML
  *
  * @since Symphony 2.3
  * @link http://www.w3.org/TR/xml/#charsets
  * @link http://www.phpedit.net/snippet/Remove-Invalid-XML-Characters
  * @param string $value
  * @return string
  */
 public static function stripInvalidXMLCharacters($value)
 {
     if (Lang::isUnicodeCompiled()) {
         return preg_replace('/[^\\x{0009}\\x{000a}\\x{000d}\\x{0020}-\\x{D7FF}\\x{E000}-\\x{FFFD}]+/u', ' ', $value);
     } else {
         $ret = '';
         if (empty($value)) {
             return $ret;
         }
         $length = strlen($value);
         for ($i = 0; $i < $length; $i++) {
             $current = ord($value[$i]);
             if ($current == 0x9 || $current == 0xa || $current == 0xd || $current >= 0x20 && $current <= 0xd7ff || $current >= 0xe000 && $current <= 0xfffd || $current >= 0x10000 && $current <= 0x10ffff) {
                 $ret .= chr($current);
             }
         }
         return $ret;
     }
 }
开发者ID:hananils,项目名称:pompodium,代码行数:28,代码来源:class.xmlelement.php

示例4: checkFields

 /**
  * Check the field's settings to ensure they are valid on the section
  * editor
  *
  * @param array $errors
  *  the array to populate with the errors found.
  * @param boolean $checkForDuplicates (optional)
  *  if set to true, duplicate Field name's in the same section will be flagged
  *  as errors. Defaults to true.
  * @return integer
  *  returns the status of the checking. if errors has been populated with
  *  any errors `self::__ERROR__`, `self::__OK__` otherwise.
  */
 public function checkFields(array &$errors, $checkForDuplicates = true)
 {
     $parent_section = $this->get('parent_section');
     $label = $this->get('label');
     $element_name = $this->get('element_name');
     if (Lang::isUnicodeCompiled()) {
         $valid_name = preg_match('/^[\\p{L}]([0-9\\p{L}\\.\\-\\_]+)?$/u', $element_name);
     } else {
         $valid_name = preg_match('/^[A-z]([\\w\\d-_\\.]+)?$/i', $element_name);
     }
     if ($label === '') {
         $errors['label'] = __('This is a required field.');
     } elseif (strtolower($label) === 'id') {
         $errors['label'] = __('%s is a reserved name used by the system and is not allowed for a field handle. Try using %s instead.', array('<code>ID</code>', '<code>UID</code>'));
     }
     if ($element_name === '') {
         $errors['element_name'] = __('This is a required field.');
     } elseif ($element_name === 'id') {
         $errors['element_name'] = __('%s is a reserved name used by the system and is not allowed for a field handle. Try using %s instead.', array('<code>id</code>', '<code>uid</code>'));
     } elseif (!$valid_name) {
         $errors['element_name'] = __('Invalid element name. Must be valid %s.', array('<code>QName</code>'));
     } elseif ($checkForDuplicates) {
         if (FieldManager::fetchFieldIDFromElementName($element_name, $parent_section) !== $this->get('id')) {
             $errors['element_name'] = __('A field with that element name already exists. Please choose another.');
         }
     }
     // Check that if the validator is provided that it's a valid regular expression
     if (!is_null($this->get('validator')) && $this->get('validator') !== '') {
         if (@preg_match($this->get('validator'), 'teststring') === false) {
             $errors['validator'] = __('Validation rule is not a valid regular expression');
         }
     }
     return !empty($errors) ? self::__ERROR__ : self::__OK__;
 }
开发者ID:roshinebagha,项目名称:Symphony-Test,代码行数:47,代码来源:class.field.php

示例5: _valid_element_name

 /**
  * This function takes a string and returns an empty DOMElement
  * with a valid name. If the passed `$name` is a valid QName, the handle of
  * this name will be the name of the element, otherwise this will fallback to 'key'.
  *
  * @see toolkit.Lang#createHandle
  * @param string $name
  *  If the `$name` is not a valid QName it will be ignored and replaced with
  *  'key'. If this happens, a `@value` attribute will be set with the original
  *  `$name`. If `$name` is a valid QName, it will be run through `Lang::createHandle`
  *  to create a handle for the element.
  * @return DOMElement
  *  An empty DOMElement with `@handle` and `@value` attributes.
  */
 private static function _valid_element_name($name)
 {
     if (Lang::isUnicodeCompiled()) {
         $valid_name = preg_match('/^[\\p{L}]([0-9\\p{L}\\.\\-\\_]+)?$/u', $name);
     } else {
         $valid_name = preg_match('/^[A-z]([\\w\\d-_\\.]+)?$/i', $name);
     }
     if ($valid_name) {
         $xKey = self::$dom->createElement(Lang::createHandle($name));
     } else {
         $xKey = self::$dom->createElement('key');
     }
     $xKey->setAttribute('handle', Lang::createHandle($name));
     $xKey->setAttribute('value', General::sanitize($name));
     return $xKey;
 }
开发者ID:jurajkapsz,项目名称:symphony-2,代码行数:30,代码来源:class.json.php


注:本文中的Lang::isUnicodeCompiled方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。