本文整理汇总了PHP中WURFL_Handlers_Utils::indexOfOrLength方法的典型用法代码示例。如果您正苦于以下问题:PHP WURFL_Handlers_Utils::indexOfOrLength方法的具体用法?PHP WURFL_Handlers_Utils::indexOfOrLength怎么用?PHP WURFL_Handlers_Utils::indexOfOrLength使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类WURFL_Handlers_Utils
的用法示例。
在下文中一共展示了WURFL_Handlers_Utils::indexOfOrLength方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: applyConclusiveMatch
public function applyConclusiveMatch($userAgent)
{
$tolerance = WURFL_Handlers_Utils::ordinalIndexOf($userAgent, '/', 2);
if ($tolerance === -1) {
// DoCoMo/2.0 F01A(c100;TB;W24H17)
$tolerance = WURFL_Handlers_Utils::indexOfOrLength('(', $userAgent);
}
return $this->getDeviceIDFromRIS($userAgent, $tolerance);
}
示例2: lookForMatchingUserAgent
/**
* If the User Agent contains the String Nokia, apply TokensMatcher strategy
* using the Nokia Tokens Provider else
* Apply then LD with a threshold of 3
*
* @param string $userAgent
* @return string
*/
function lookForMatchingUserAgent($userAgent)
{
$userAgents = array_keys($this->userAgentsWithDeviceID);
if (WURFL_Handlers_Utils::checkIfContains($userAgent, "Nokia")) {
$tollearnce = WURFL_Handlers_Utils::indexOfOrLength($userAgent, "/", strpos($userAgent, "Nokia"));
return parent::applyRisWithTollerance($userAgents, $userAgent, $tollearnce);
}
return WURFL_Handlers_Utils::ldMatch($userAgents, $userAgent, self::TOLLERANCE);
}
示例3: applyConclusiveMatch
public function applyConclusiveMatch($userAgent)
{
$idx = strpos($userAgent, 'MobilePhone');
if ($idx !== false) {
$tolerance = WURFL_Handlers_Utils::indexOfOrLength($userAgent, '/', $idx);
} else {
$tolerance = WURFL_Handlers_Utils::firstSlash($userAgent);
}
return $this->getDeviceIDFromRIS($userAgent, $tolerance);
}
示例4: applyRecoveryMatch
public function applyRecoveryMatch($userAgent)
{
if (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'SAMSUNG')) {
$tolerance = 8;
return $this->getDeviceIDFromLD($userAgent, $tolerance);
} else {
$tolerance = WURFL_Handlers_Utils::indexOfOrLength($userAgent, '/', strpos($userAgent, 'Samsung'));
return $this->getDeviceIDFromRIS($userAgent, $tolerance);
}
}
示例5: applyConclusiveMatch
public function applyConclusiveMatch($userAgent)
{
// The tolerance is after UCWEB7, not before
$find = 'UCWEB7';
$tolerance = WURFL_Handlers_Utils::indexOfOrLength($userAgent, $find) + strlen($find);
if ($tolerance > strlen($userAgent)) {
$tolerance = strlen($userAgent);
}
$this->getDeviceIDFromRIS($userAgent, $tolerance);
}
示例6: tolerance
private function tolerance($userAgent)
{
if (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, "KDDI/")) {
return WURFL_Handlers_Utils::secondSlash($userAgent);
}
if (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, "KDDI")) {
return WURFL_Handlers_Utils::firstSlash($userAgent);
}
return WURFL_Handlers_Utils::indexOfOrLength($userAgent, ")");
}
示例7: applyConclusiveMatch
public function applyConclusiveMatch($userAgent)
{
if (WURFL_Handlers_Utils::checkIfContains($userAgent, 'BB10')) {
$tolerance = WURFL_Handlers_Utils::indexOfOrLength($userAgent, ')');
} elseif (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'Mozilla/4')) {
$tolerance = WURFL_Handlers_Utils::secondSlash($userAgent);
} elseif (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'Mozilla/5')) {
$tolerance = WURFL_Handlers_Utils::ordinalIndexOf($userAgent, ';', 3);
} elseif (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, 'PlayBook')) {
$tolerance = WURFL_Handlers_Utils::firstCloseParen($userAgent);
} else {
$tolerance = WURFL_Handlers_Utils::firstSlash($userAgent);
}
return $this->getDeviceIDFromRIS($userAgent, $tolerance);
}
示例8: applyConclusiveMatch
public function applyConclusiveMatch($userAgent)
{
$matches = array();
if (preg_match('/^Mozilla\\/5\\.0 \\(.+?Trident.+?; rv:(\\d\\d)\\.(\\d+)\\)/', $userAgent, $matches) || preg_match('/^Mozilla\\/[45]\\.0 \\(compatible; MSIE (\\d+)\\.(\\d+);/', $userAgent, $matches)) {
$major = (int) $matches[1];
$minor = (int) $matches[2];
// MSIE 5.5 is handled specifically
if ($major == 5 && $minor == 5) {
return 'msie_5_5';
}
// Look for version in constant ID array
if (array_key_exists($major, self::$constantIDs)) {
return self::$constantIDs[$major];
}
}
return $this->getDeviceIDFromRIS($userAgent, WURFL_Handlers_Utils::indexOfOrLength($userAgent, 'Trident'));
}
示例9: applyConclusiveMatch
public function applyConclusiveMatch($userAgent)
{
if (WURFL_Handlers_Utils::checkIfContains($userAgent, ' Build/')) {
return $this->getDeviceIDFromRIS($userAgent, WURFL_Handlers_Utils::indexOfOrLength($userAgent, ' Build/'));
}
$prefixes = array('Opera/9.80 (J2ME/MIDP; Opera Mini/5' => 'uabait_opera_mini_android_v50', 'Opera/9.80 (Android; Opera Mini/5.0' => 'uabait_opera_mini_android_v50', 'Opera/9.80 (Android; Opera Mini/5.1' => 'uabait_opera_mini_android_v51');
foreach ($prefixes as $prefix => $defaultID) {
if (WURFL_Handlers_Utils::checkIfStartsWith($userAgent, $prefix)) {
// If RIS returns a non-generic match, return it, else, return the default
$tolerance = strlen($prefix);
$deviceID = $this->getDeviceIDFromRIS($userAgent, $tolerance);
if ($deviceID == WURFL_Constants::NO_MATCH) {
return $defaultID;
}
return $deviceID;
}
}
return WURFL_Constants::NO_MATCH;
}
示例10: applyConclusiveMatch
public function applyConclusiveMatch($userAgent)
{
$model = self::getOperaModel($userAgent, false);
if ($model !== null) {
$prefix = $model . WURFL_Constants::RIS_DELIMITER;
$userAgent = $prefix . $userAgent;
return $this->getDeviceIDFromRIS($userAgent, strlen($prefix));
}
$opera_mini_idx = WURFL_Handlers_Utils::indexOfOrLength($userAgent, 'Opera Mini');
if ($opera_mini_idx !== false) {
// Match up to the first '.' after 'Opera Mini'
$tolerance = strpos($userAgent, '.', $opera_mini_idx);
if ($tolerance !== false) {
// +1 to match just after the '.'
return $this->getDeviceIDFromRIS($userAgent, $tolerance + 1);
}
}
$tolerance = WURFL_Handlers_Utils::firstSlash($userAgent);
return $this->getDeviceIDFromRIS($userAgent, $tolerance);
}
示例11: lookForMatchingUserAgent
function lookForMatchingUserAgent($userAgent) {
$tollerance = WURFL_Handlers_Utils::indexOfOrLength ( $userAgent, ";", strpos ( $userAgent, "SPV" ) );
return parent::applyRisWithTollerance ( array_keys ( $this->userAgentsWithDeviceID ), $userAgent, $tollerance );
}
示例12: applyConclusiveMatch
public function applyConclusiveMatch($userAgent)
{
$skyfire_idx = strpos($userAgent, 'Skyfire');
// Matches the first decimal point after the Skyfire keyword: Skyfire/2.0
return $this->getDeviceIDFromRIS($userAgent, WURFL_Handlers_Utils::indexOfOrLength($userAgent, '.', $skyfire_idx));
}
示例13: indexOfAnyOrLength
/**
* Lowest char index of the first instance of any of the $needles found in $userAgent, starting at $startIndex;
* if no match is found, the length of the string is returned
* @param string $userAgent haystack
* @param array $needles Array of (string)needles to search for in $userAgent
* @param int $startingIndex Char index for start of search
* @return int Char index of left-most match or length of string
*/
public static function indexOfAnyOrLength($userAgent, $needles = array(), $startingIndex = 0)
{
if (count($needles) === 0) {
return strlen($userAgent);
}
$min = strlen($userAgent);
foreach ($needles as $needle) {
$index = WURFL_Handlers_Utils::indexOfOrLength($userAgent, $needle, $startingIndex);
if ($index < $min) {
$min = $index;
}
}
return $min;
}
示例14: applyConclusiveMatch
public function applyConclusiveMatch($userAgent)
{
$tolerance = WURFL_Handlers_Utils::indexOfOrLength($userAgent, '/', stripos($userAgent, 'LG'));
return $this->getDeviceIDFromRIS($userAgent, $tolerance);
}
示例15: applyConclusiveMatch
public function applyConclusiveMatch($userAgent)
{
return $this->getDeviceIDFromRIS($userAgent, WURFL_Handlers_Utils::indexOfOrLength($userAgent, '.'));
}