本文整理汇总了PHP中WT_I18N::textScript方法的典型用法代码示例。如果您正苦于以下问题:PHP WT_I18N::textScript方法的具体用法?PHP WT_I18N::textScript怎么用?PHP WT_I18N::textScript使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WT_I18N
的用法示例。
在下文中一共展示了WT_I18N::textScript方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: DMSoundex
private static function DMSoundex($name)
{
// Apply special transformation rules to the input string
$name = WT_I18N::strtoupper($name);
foreach (self::$transformNameTable as $transformRule) {
$name = str_replace($transformRule[0], $transformRule[1], $name);
}
// Initialize
$name_script = WT_I18N::textScript($name);
if ($name_script == 'Hebr' || $name_script == 'Arab') {
$noVowels = true;
} else {
$noVowels = false;
}
$lastPos = strlen($name) - 1;
$currPos = 0;
$state = 1;
// 1: start of input string, 2: before vowel, 3: other
$result = array();
// accumulate complete 6-digit D-M codes here
$partialResult = array();
// accumulate incomplete D-M codes here
$partialResult[] = array('!');
// initialize 1st partial result ('!' stops "duplicate sound" check)
// Loop through the input string.
// Stop when the string is exhausted or when no more partial results remain
while (count($partialResult) != 0 && $currPos <= $lastPos) {
// Find the DM coding table entry for the chunk at the current position
$thisEntry = substr($name, $currPos, self::MAXCHAR);
// Get maximum length chunk
while ($thisEntry != '') {
if (isset(self::$dmsounds[$thisEntry])) {
break;
}
$thisEntry = substr($thisEntry, 0, -1);
// Not in table: try a shorter chunk
}
if ($thisEntry == '') {
$currPos++;
// Not in table: advance pointer to next byte
continue;
// and try again
}
$soundTableEntry = self::$dmsounds[$thisEntry];
$workingResult = $partialResult;
$partialResult = array();
$currPos += strlen($thisEntry);
if ($state != 1) {
// Not at beginning of input string
if ($currPos <= $lastPos) {
// Determine whether the next chunk is a vowel
$nextEntry = substr($name, $currPos, self::MAXCHAR);
// Get maximum length chunk
while ($nextEntry != '') {
if (isset(self::$dmsounds[$nextEntry])) {
break;
}
$nextEntry = substr($nextEntry, 0, -1);
// Not in table: try a shorter chunk
}
} else {
$nextEntry = '';
}
if ($nextEntry != '' && self::$dmsounds[$nextEntry][0] != '0') {
$state = 2;
} else {
$state = 3;
}
}
while ($state < count($soundTableEntry)) {
if ($soundTableEntry[$state] == '') {
// empty means 'ignore this sound in this state'
foreach ($workingResult as $workingEntry) {
$tempEntry = $workingEntry;
$tempEntry[count($tempEntry) - 1] .= '!';
// Prevent false 'doubles'
$partialResult[] = $tempEntry;
}
} else {
foreach ($workingResult as $workingEntry) {
if ($soundTableEntry[$state] !== $workingEntry[count($workingEntry) - 1]) {
// Incoming sound isn't a duplicate of the previous sound
$workingEntry[] = $soundTableEntry[$state];
} else {
// Incoming sound is a duplicate of the previous sound
// For Hebrew and Arabic, we need to create a pair of D-M sound codes,
// one of the pair with only a single occurrence of the duplicate sound,
// the other with both occurrences
if ($noVowels) {
//$partialResult[] = $workingEntry;
$workingEntry[] = $soundTableEntry[$state];
}
}
if (count($workingEntry) < 7) {
$partialResult[] = $workingEntry;
} else {
// This is the 6th code in the sequence
// We're looking for 7 entries because the first is '!' and doesn't count
$tempResult = str_replace('!', '', implode('', $workingEntry));
// Only return codes from recognisable sounds
//.........这里部分代码省略.........
示例2: getSecondaryName
public function getSecondaryName()
{
if (is_null($this->_getSecondaryName)) {
// Generally, the primary and secondary names are the same
$this->_getSecondaryName = $this->getPrimaryName();
// ....except when there are names with different character sets
$all_names = $this->getAllNames();
if (count($all_names) > 1) {
$primary_script = WT_I18N::textScript($all_names[$this->getPrimaryName()]['sort']);
foreach ($all_names as $n => $name) {
if ($n != $this->getPrimaryName() && $name['type'] != '_MARNM' && WT_I18N::textScript($name['sort']) != $primary_script) {
$this->_getSecondaryName = $n;
break;
}
}
}
}
return $this->_getSecondaryName;
}
示例3: getAllNames
public function getAllNames()
{
global $UNKNOWN_NN, $UNKNOWN_PN;
if (is_null($this->_getAllNames)) {
// Check the script used by each name, so we can match cyrillic with cyrillic, greek with greek, etc.
if ($this->husb) {
$husb_names = $this->husb->getAllNames();
} else {
$husb_names = array(0 => array('type' => 'BIRT', 'sort' => '@N.N.', 'full' => $UNKNOWN_PN, ' ', $UNKNOWN_NN));
}
foreach ($husb_names as $n => $husb_name) {
$husb_names[$n]['script'] = WT_I18N::textScript($husb_name['full']);
}
if ($this->wife) {
$wife_names = $this->wife->getAllNames();
} else {
$wife_names = array(0 => array('type' => 'BIRT', 'sort' => '@N.N.', 'full' => $UNKNOWN_PN, ' ', $UNKNOWN_NN));
}
foreach ($wife_names as $n => $wife_name) {
$wife_names[$n]['script'] = WT_I18N::textScript($wife_name['full']);
}
// Add the matched names first
foreach ($husb_names as $husb_name) {
foreach ($wife_names as $wife_name) {
if ($husb_name['type'] != '_MARNM' && $wife_name['type'] != '_MARNM' && $husb_name['script'] == $wife_name['script']) {
$this->_getAllNames[] = array('type' => $husb_name['type'], 'sort' => $husb_name['sort'] . ' + ' . $wife_name['sort'], 'full' => $husb_name['full'] . ' + ' . $wife_name['full']);
}
}
}
// Add the unmatched names second (there may be no matched names)
foreach ($husb_names as $husb_name) {
foreach ($wife_names as $wife_name) {
if ($husb_name['type'] != '_MARNM' && $wife_name['type'] != '_MARNM' && $husb_name['script'] != $wife_name['script']) {
$this->_getAllNames[] = array('type' => $husb_name['type'], 'sort' => $husb_name['sort'] . ' + ' . $wife_name['sort'], 'full' => $husb_name['full'] . ' + ' . $wife_name['full']);
}
}
}
}
return $this->_getAllNames;
}
示例4: spanLTRRTL
//.........这里部分代码省略.........
if ($waitingText == '') {
if ($currentState == 'RTL') {
$result .= WT_UTF8_PDF;
}
} else {
if ($currentState == 'RTL') {
$waitingText .= WT_UTF8_PDF;
}
}
}
finishCurrentSpan($result, true);
// Get rid of any waiting text
if ($waitingText != '') {
if ($TEXT_DIRECTION == 'rtl' && $currentState == 'LTR') {
$result .= $startRTL;
$result .= $waitingText;
$result .= $endRTL;
} else {
$result .= $startLTR;
$result .= $waitingText;
$result .= $endLTR;
}
$waitingText = '';
}
// Lastly, do some more cleanups
// Move leading RTL numeric strings to following LTR text
// (this happens when the page direction is RTL and the original text begins with a number and is followed by LTR text)
while (substr($result, 0, $lenStart + 3) == $startRTL . WT_UTF8_LRE) {
$spanEnd = strpos($result, $endRTL . $startLTR);
if ($spanEnd === false) {
break;
}
$textSpan = stripLRMRLM(substr($result, $lenStart + 3, $spanEnd - $lenStart - 3));
$langSpan = WT_I18N::textScript($textSpan);
if ($langSpan == 'Hebr' || $langSpan == 'Arab') {
break;
}
$result = $startLTR . substr($result, $lenStart, $spanEnd - $lenStart) . substr($result, $spanEnd + $lenStart + $lenEnd);
break;
}
// On RTL pages, put trailing "." in RTL numeric strings into its own RTL span
if ($TEXT_DIRECTION == 'rtl') {
$result = str_replace(WT_UTF8_PDF . '.' . $endRTL, WT_UTF8_PDF . $endRTL . $startRTL . '.' . $endRTL, $result);
}
// Trim trailing blanks preceding <br> in LTR text
while ($previousState != 'RTL') {
if (strpos($result, ' <LTRbr>') !== false) {
$result = str_replace(' <LTRbr>', '<LTRbr>', $result);
continue;
}
if (strpos($result, ' <LTRbr>') !== false) {
$result = str_replace(' <LTRbr>', '<LTRbr>', $result);
continue;
}
if (strpos($result, ' <br>') !== false) {
$result = str_replace(' <br>', '<br>', $result);
continue;
}
if (strpos($result, ' <br>') !== false) {
$result = str_replace(' <br>', '<br>', $result);
continue;
}
break;
// Neither space nor : we're done
}
// Trim trailing blanks preceding <br> in RTL text