本文整理汇总了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;
}
示例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);
}
示例3: getNormalizedDestinationTitle
/**
* Get the normalized composed version of the title
*
* @return string
*/
public function getNormalizedDestinationTitle()
{
return \UtfNormal::toNFC($this->getSanitizedTitleText());
}
示例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;
}
示例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");
}
示例6: ustringToNFC
public function ustringToNFC($s)
{
$this->checkString('toNFC', $s, false);
if (!$this->checkEncoding($s)) {
return array(null);
}
return array(UtfNormal::toNFC($s));
}
示例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 );
}