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