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


PHP UtfNormal::toNFC方法代码示例

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


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

示例1: getNodePathForTitlePath

 /**
  * Converts a path consisting of object titles into a path consisting of tree
  * nodes. The comparison is non-case sensitive.
  *
  * Note: this function returns the same result as getNodePath, 
  * but takes a title path as parameter.
  *
  * @access	public
  * @param	Array	Path array with object titles.
  *                       e.g. array('ILIAS','English','Course A')
  * @param	ref_id	Startnode of the relative path. 
  *                       Specify null, if the title path is an absolute path.
  *                       Specify a ref id, if the title path is a relative 
  *                       path starting at this ref id.
  * @return	array	ordered path info (depth,parent,child,obj_id,type,title)
  *               or null, if the title path can not be converted into a node path.
  */
 function getNodePathForTitlePath($titlePath, $a_startnode_id = null)
 {
     global $ilDB, $log;
     //$log->write('getNodePathForTitlePath('.implode('/',$titlePath));
     // handle empty title path
     if ($titlePath == null || count($titlePath) == 0) {
         if ($a_startnode_id == 0) {
             return null;
         } else {
             return $this->getNodePath($a_startnode_id);
         }
     }
     // fetch the node path up to the startnode
     if ($a_startnode_id != null && $a_startnode_id != 0) {
         // Start using the node path to the root of the relative path
         $nodePath = $this->getNodePath($a_startnode_id);
         $parent = $a_startnode_id;
     } else {
         // Start using the root of the tree
         $nodePath = array();
         $parent = 0;
     }
     // Convert title path into Unicode Normal Form C
     // This is needed to ensure that we can compare title path strings with
     // strings from the database.
     require_once 'include/Unicode/UtfNormal.php';
     include_once './Services/Utilities/classes/class.ilStr.php';
     $inClause = 'd.title IN (';
     for ($i = 0; $i < count($titlePath); $i++) {
         $titlePath[$i] = ilStr::strToLower(UtfNormal::toNFC($titlePath[$i]));
         if ($i > 0) {
             $inClause .= ',';
         }
         $inClause .= $ilDB->quote($titlePath[$i], 'text');
     }
     $inClause .= ')';
     // Fetch all rows that are potential path elements
     if ($this->table_obj_reference) {
         $joinClause = 'JOIN ' . $this->table_obj_reference . '  r ON t.child = r.' . $this->ref_pk . ' ' . 'JOIN ' . $this->table_obj_data . ' d ON r.' . $this->obj_pk . ' = d.' . $this->obj_pk;
     } else {
         $joinClause = 'JOIN ' . $this->table_obj_data . '  d ON t.child = d.' . $this->obj_pk;
     }
     // The ORDER BY clause in the following SQL statement ensures that,
     // in case of a multiple objects with the same title, always the Object
     // with the oldest ref_id is chosen.
     // This ensure, that, if a new object with the same title is added,
     // WebDAV clients can still work with the older object.
     $q = 'SELECT t.depth, t.parent, t.child, d.' . $this->obj_pk . ' obj_id, d.type, d.title ' . 'FROM ' . $this->table_tree . '  t ' . $joinClause . ' ' . 'WHERE ' . $inClause . ' ' . 'AND t.depth <= ' . (count($titlePath) + count($nodePath)) . ' ' . 'AND t.tree = 1 ' . 'ORDER BY t.depth, t.child ASC';
     $r = $ilDB->query($q);
     $rows = array();
     while ($row = $r->fetchRow(DB_FETCHMODE_ASSOC)) {
         $row['title'] = UtfNormal::toNFC($row['title']);
         $row['ref_id'] = $row['child'];
         $rows[] = $row;
     }
     // Extract the path elements from the fetched rows
     for ($i = 0; $i < count($titlePath); $i++) {
         $pathElementFound = false;
         foreach ($rows as $row) {
             if ($row['parent'] == $parent && ilStr::strToLower($row['title']) == $titlePath[$i]) {
                 // FIXME - We should test here, if the user has
                 // 'visible' permission for the object.
                 $nodePath[] = $row;
                 $parent = $row['child'];
                 $pathElementFound = true;
                 break;
             }
         }
         // Abort if we haven't found a path element for the current depth
         if (!$pathElementFound) {
             //$log->write('ilTree.getNodePathForTitlePath('.var_export($titlePath,true).','.$a_startnode_id.'):null');
             return null;
         }
     }
     // Return the node path
     //$log->write('ilTree.getNodePathForTitlePath('.var_export($titlePath,true).','.$a_startnode_id.'):'.var_export($nodePath,true));
     return $nodePath;
 }
开发者ID:khanhnnvn,项目名称:ilias_E-learning,代码行数:95,代码来源:class.ilTree.php

示例2: getNormalizedMetadata

 /**
  * Get Normalized metadata in PHP-serialized form
  *
  * @param stdClass $video
  * @return string
  */
 protected static function getNormalizedMetadata($video)
 {
     // image.img_metadata
     $metadata = unserialize($video->img_metadata);
     foreach (self::$metadataFieldsContainingName as $field) {
         if (isset($metadata[$field])) {
             $metadata[$field] = \UtfNormal::toNFC($metadata[$field]);
         }
     }
     return serialize($metadata);
 }
开发者ID:Tjorriemorrie,项目名称:app,代码行数:17,代码来源:nfcNormalizeVideos.php

示例3: getNormalizedDestinationTitle

 /**
  * Get the normalized composed version of the title
  *
  * @return string
  */
 public function getNormalizedDestinationTitle()
 {
     return \UtfNormal::toNFC($this->getSanitizedTitleText());
 }
开发者ID:yusufchang,项目名称:app,代码行数:9,代码来源:VideoFileUploader.class.php

示例4: davDeslashify

 /**
  * davDeslashify - make sure path does not end in a slash
  *
  * @param   string directory path
  * @returns string directory path without trailing slash
  */
 private function davDeslashify($path)
 {
     $path = UtfNormal::toNFC($path);
     if ($path[strlen($path) - 1] == '/') {
         $path = substr($path, 0, strlen($path) - 1);
     }
     $this->writelog('davDeslashify:' . $path);
     return $path;
 }
开发者ID:arlendotcn,项目名称:ilias,代码行数:15,代码来源:class.ilDAVServer.php

示例5: normalize_form_c_php

/**
 * This set of functions is only useful if youve added a param to the
 * following functions to force pure PHP usage.  I decided not to
 * commit that code since might produce a slowdown in the UTF
 * normalization code just for the sake of these tests. -- hexmode
 * @return string
 */
function normalize_form_c_php($c)
{
    return UtfNormal::toNFC($c, "php");
}
开发者ID:seedbank,项目名称:old-repo,代码行数:11,代码来源:UtfNormalTest2.php

示例6: ustringToNFC

 public function ustringToNFC($s)
 {
     $this->checkString('toNFC', $s, false);
     if (!$this->checkEncoding($s)) {
         return array(null);
     }
     return array(UtfNormal::toNFC($s));
 }
开发者ID:negati-ve,项目名称:openshift-mediawiki,代码行数:8,代码来源:UstringLibrary.php

示例7: transliterate

	/**
	 * Transliterate a word using the given map's rules and flags.
	 *
	 * @param $word  raw user input
	 * @param $map  as returned by getMap()
	 * @return String ready to output
	 */
	static function transliterate( $word, $map )
	{
		// Add bookends and combining character markers
		$word = self::forTransliteration( $word, $map['flags'] );

		// Perform transliteration
		$output = $map['rules']->replace( $word );

		// Maintain MediaWiki invariant of NFC
		return UtfNormal::toNFC( $output );
	}
开发者ID:realsoc,项目名称:mediawiki-extensions,代码行数:18,代码来源:Transliterator_body.php


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