本文整理汇总了PHP中FLEXIUtilities::uniord方法的典型用法代码示例。如果您正苦于以下问题:PHP FLEXIUtilities::uniord方法的具体用法?PHP FLEXIUtilities::uniord怎么用?PHP FLEXIUtilities::uniord使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FLEXIUtilities
的用法示例。
在下文中一共展示了FLEXIUtilities::uniord方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: _buildAlphaIndexWhere
/**
* Method to build the part of WHERE clause related to Alpha Index
*
* @access private
* @return array
*/
function _buildAlphaIndexWhere()
{
// Get alpha index request variable and do some security checks, by removing any quotes and other non-valid characters
$alpha = JRequest::getVar('letter', NULL, 'request', 'string');
$alpha = preg_replace("/(\\(|\\)\\'|\"|\\\\)/u", "", $alpha);
if (JString::strlen($alpha) == 0) {
// nothing to do
return '';
}
// Detect and handle character groups and character ranges, WARNING: The following is needed because
// utf8 is multibyte and MySQL regexp doesnot support multibyte, thus we can not use [] with utf8
$range = explode("-", $alpha);
if (count($range) > 2) {
echo "Error in Alpha Index please correct letter range: " . $alpha . "<br>";
return '';
} else {
if (count($range) == 1) {
$regexp = '"^(' . JString::substr($alpha, 0, 1);
for ($i = 1; $i < JString::strlen($alpha); $i++) {
$regexp .= '|' . JString::substr($alpha, $i, 1);
}
$regexp .= ')"';
} else {
if (count($range) == 2) {
// Get range characters
$startletter = $range[0];
$endletter = $range[1];
// ERROR CHECK: Range START and END are single character strings
if (JString::strlen($startletter) != 1 || JString::strlen($endletter) != 1) {
echo "Error in Alpha Index<br>letter range: " . $alpha . " start and end must be one character<br>";
return '';
}
// Get ord of characters and their rangle length
$startord = FLEXIUtilities::uniord($startletter);
$endord = FLEXIUtilities::uniord($endletter);
$range_length = $endord - $startord;
// ERROR CHECK: Character range has at least one character
if ($range_length > 50 || $range_length < 1) {
// A sanity check that the range is something logical and that
echo "Error in Alpha Index<br>letter range: " . $alpha . ", is incorrect or contains more that 50 characters<br>";
return '';
}
// Check if any character out of the range characters exists
// Meaning (There is at least on item title starting with one of the range characters)
$regexp = '"^(' . $startletter;
for ($uord = $startord + 1; $uord <= $endord; $uord++) {
$regexp .= '|' . FLEXIUtilities::unichr($uord);
}
$regexp .= ')"';
} else {
echo "Error in Alpha Index<br>incorrect letter range: " . $alpha . "<br>";
return '';
}
}
}
$where = '';
if (!empty($regexp)) {
if ($alpha == '0') {
$where = ' AND ( CONVERT (( i.title ) USING BINARY) REGEXP CONVERT (' . $regexp . ' USING BINARY) )';
} elseif (!empty($alpha)) {
$where = ' AND ( CONVERT (LOWER( i.title ) USING BINARY) REGEXP CONVERT (' . $regexp . ' USING BINARY) )';
}
//$alpha_term = $this->_db->escape( '^['.$alpha.']', true );
//$where = ' AND LOWER( i.title ) RLIKE '.$this->_db->Quote( $alpha_term, false );
}
return $where;
}
示例2:
// ERROR CHECK: Character range has only one minus(-)
if (count($range) != 2) {
echo "Error in Alpha Index<br>incorrect letter range: " . $letter . "<br>";
continue;
}
// Get range characters
$startletter = $range[0];
$endletter = $range[1];
// ERROR CHECK: Range START and END are single character strings
if (JString::strlen($startletter) != 1 || JString::strlen($endletter) != 1) {
echo "Error in Alpha Index<br>letter range: " . $letter . " start and end must be one character<br>";
continue;
}
// Get ord of characters and their rangle length
$startord = FLEXIUtilities::uniord($startletter);
$endord = FLEXIUtilities::uniord($endletter);
$range_length = $endord - $startord;
// ERROR CHECK: Character range has at least one character
if ($range_length > 200 || $range_length < 1) {
// A sanity check that the range is something logical and that
echo "Error in Alpha Index<br>letter range: " . $letter . ", is incorrect or contains more that 200 characters<br>";
continue;
}
// Check if any character out of the range characters exists
// Meaning (There is at least on item title starting with one of the range characters)
for ($uord = $startord; $uord <= $endord; $uord++) {
$uchar = FLEXIUtilities::unichr($uord);
if (in_array($uchar, $this->alpha)) {
$has_item = true;
break;
}