Permalink
Browse files

* Simplify hasAcceptType()

git-svn-id: http://svn.php.net/repository/pear/packages/Net_UserAgent/trunk@184637 c90b9560-bf6c-de11-be94-00142212c4b1
  • Loading branch information...
1 parent 1df67f5 commit 74f6630d7e0a470ba553dd834c77a251dc0c8eee Jason Rust committed Apr 18, 2005
Showing with 3 additions and 12 deletions.
  1. +1 −10 Detect.php
  2. +2 −2 tests/example.php
View
@@ -881,16 +881,7 @@ function setAcceptType($in_values, $in_type)
*/
function hasAcceptType($in_value, $in_type)
{
- Net_UserAgent_Detect::detect();
- $type = strtolower($in_type);
-
- if ($type == 'mimetype' || $type == 'language' || $type == 'charset' || $type == 'encoding') {
- $typeArray = &Net_UserAgent_Detect::_getStaticProperty($type);
- return !empty($typeArray[$in_value]);
- }
- else {
- return false;
- }
+ return (bool) Net_UserAgent_Detect::getAcceptType((array) $in_value, $in_type);
}
// }}}
View
@@ -24,7 +24,7 @@ function println($in_string) {
if (in_array(php_sapi_name(), array('cli', 'cgi')) && empty($_SERVER['REMOTE_ADDR'])) {
Net_UserAgent_Detect::setOption('re-evaluate', true);
- foreach (array('en' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0rc1) Gecko/20020417',
+ foreach (array('en-us' => 'Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.0rc1) Gecko/20020417',
'fr' => 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; SV1; .NET CLR 1.1.4322)') as $lang => $brwsr) {
putenv("HTTP_ACCEPT_LANGUAGE=$lang");
Net_UserAgent_Detect::setOption('userAgent', $brwsr);
@@ -47,7 +47,7 @@ function print_info()
println('Has "popups disabled" quirk: ' . (Net_UserAgent_Detect::hasQuirk('popups_disabled') ? 'Yes' : 'No'));
println('Has "dom" feature: ' . (Net_UserAgent_Detect::hasFeature('dom') ? 'Yes' : 'No'));
println('Javascript version: ' . Net_UserAgent_Detect::getFeature('javascript'));
- $languages = array('fr', 'de', 'en');
+ $languages = array('fr', 'de', 'en-us');
println('Accept Language: ' . Net_UserAgent_Detect::getAcceptType($languages, 'language'));
}
?>

0 comments on commit 74f6630

Please sign in to comment.