当前位置: 首页>>代码示例>>PHP>>正文


PHP Request::getBrowserLanguage方法代码示例

本文整理汇总了PHP中Piwik\Tracker\Request::getBrowserLanguage方法的典型用法代码示例。如果您正苦于以下问题:PHP Request::getBrowserLanguage方法的具体用法?PHP Request::getBrowserLanguage怎么用?PHP Request::getBrowserLanguage使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Piwik\Tracker\Request的用法示例。


在下文中一共展示了Request::getBrowserLanguage方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: onNewVisit

 /**
  * @param Request $request
  * @param Visitor $visitor
  * @param Action|null $action
  * @return mixed
  */
 public function onNewVisit(Request $request, Visitor $visitor, $action)
 {
     $language = $request->getBrowserLanguage();
     if (empty($language)) {
         return '';
     }
     return substr($language, 0, 20);
 }
开发者ID:a4tunado,项目名称:piwik,代码行数:14,代码来源:Language.php

示例2: getUserSettingsInformation

 /**
  * Gets the UserSettings information and returns them in an array of name => value
  *
  * @return array
  */
 protected function getUserSettingsInformation()
 {
     // we already called this method before, simply returns the result
     if (is_array($this->userSettingsInformation)) {
         return $this->userSettingsInformation;
     }
     require_once PIWIK_INCLUDE_PATH . '/libs/UserAgentParser/UserAgentParser.php';
     list($plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie) = $this->request->getPlugins();
     $resolution = $this->request->getParam('res');
     $userAgent = $this->request->getUserAgent();
     $aBrowserInfo = UserAgentParser::getBrowser($userAgent);
     $browserName = $aBrowserInfo !== false && $aBrowserInfo['id'] !== false ? $aBrowserInfo['id'] : 'UNK';
     $browserVersion = $aBrowserInfo !== false && $aBrowserInfo['version'] !== false ? $aBrowserInfo['version'] : '';
     $os = UserAgentParser::getOperatingSystem($userAgent);
     $os = $os === false ? 'UNK' : $os['id'];
     $browserLang = substr($this->request->getBrowserLanguage(), 0, 20);
     // limit the length of this string to match db
     $configurationHash = $this->getConfigHash($os, $browserName, $browserVersion, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $this->getVisitorIp(), $browserLang);
     $this->userSettingsInformation = array('config_id' => $configurationHash, 'config_os' => $os, 'config_browser_name' => $browserName, 'config_browser_version' => $browserVersion, 'config_resolution' => $resolution, 'config_pdf' => $plugin_PDF, 'config_flash' => $plugin_Flash, 'config_java' => $plugin_Java, 'config_director' => $plugin_Director, 'config_quicktime' => $plugin_Quicktime, 'config_realplayer' => $plugin_RealPlayer, 'config_windowsmedia' => $plugin_WindowsMedia, 'config_gears' => $plugin_Gears, 'config_silverlight' => $plugin_Silverlight, 'config_cookie' => $plugin_Cookie, 'location_browser_lang' => $browserLang);
     return $this->userSettingsInformation;
 }
开发者ID:KiwiJuicer,项目名称:handball-dachau,代码行数:26,代码来源:Visit.php

示例3: getConfigId

 public function getConfigId(Request $request, $ipAddress)
 {
     list($plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie) = $request->getPlugins();
     $userAgent = $request->getUserAgent();
     $deviceDetector = DeviceDetectorFactory::getInstance($userAgent);
     $aBrowserInfo = $deviceDetector->getClient();
     if ($aBrowserInfo['type'] != 'browser') {
         // for now only track browsers
         unset($aBrowserInfo);
     }
     $browserName = !empty($aBrowserInfo['short_name']) ? $aBrowserInfo['short_name'] : 'UNK';
     $browserVersion = !empty($aBrowserInfo['version']) ? $aBrowserInfo['version'] : '';
     if ($deviceDetector->isBot()) {
         $os = self::OS_BOT;
     } else {
         $os = $deviceDetector->getOS();
         $os = empty($os['short_name']) ? 'UNK' : $os['short_name'];
     }
     $browserLang = substr($request->getBrowserLanguage(), 0, 20);
     // limit the length of this string to match db
     return $this->getConfigHash($request, $os, $browserName, $browserVersion, $plugin_Flash, $plugin_Java, $plugin_Director, $plugin_Quicktime, $plugin_RealPlayer, $plugin_PDF, $plugin_WindowsMedia, $plugin_Gears, $plugin_Silverlight, $plugin_Cookie, $ipAddress, $browserLang);
 }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:22,代码来源:Settings.php

示例4: onNewVisit

 /**
  * @param Request $request
  * @param Visitor $visitor
  * @param Action|null $action
  * @return mixed
  */
 public function onNewVisit(Request $request, Visitor $visitor, $action)
 {
     return substr($request->getBrowserLanguage(), 0, 20);
 }
开发者ID:pombredanne,项目名称:ArcherSys,代码行数:10,代码来源:Language.php

示例5: recordGoals

 /**
  * Records one or several goals matched in this request.
  *
  * @param int $idSite
  * @param array $visitorInformation
  * @param array $visitCustomVariables
  * @param Action $action
  */
 public function recordGoals($idSite, $visitorInformation, $visitCustomVariables, $action)
 {
     $referrerTimestamp = $this->request->getParam('_refts');
     $referrerUrl = $this->request->getParam('_ref');
     $referrerCampaignName = trim(urldecode($this->request->getParam('_rcn')));
     $referrerCampaignKeyword = trim(urldecode($this->request->getParam('_rck')));
     $browserLanguage = $this->request->getBrowserLanguage();
     $location_country = isset($visitorInformation['location_country']) ? $visitorInformation['location_country'] : Common::getCountry($browserLanguage, $enableLanguageToCountryGuess = Config::getInstance()->Tracker['enable_language_to_country_guess'], $visitorInformation['location_ip']);
     $goal = array('idvisit' => $visitorInformation['idvisit'], 'idsite' => $idSite, 'idvisitor' => $visitorInformation['idvisitor'], 'server_time' => Tracker::getDatetimeFromTimestamp($visitorInformation['visit_last_action_time']), 'location_country' => $location_country, 'visitor_returning' => $visitorInformation['visitor_returning'], 'visitor_days_since_first' => $visitorInformation['visitor_days_since_first'], 'visitor_days_since_order' => $visitorInformation['visitor_days_since_order'], 'visitor_count_visits' => $visitorInformation['visitor_count_visits']);
     $extraLocationCols = array('location_region', 'location_city', 'location_latitude', 'location_longitude');
     foreach ($extraLocationCols as $col) {
         if (isset($visitorInformation[$col])) {
             $goal[$col] = $visitorInformation[$col];
         }
     }
     // Copy Custom Variables from Visit row to the Goal conversion
     // Otherwise, set the Custom Variables found in the cookie sent with this request
     $goal += $visitCustomVariables;
     $maxCustomVariables = CustomVariables::getMaxCustomVariables();
     for ($i = 1; $i <= $maxCustomVariables; $i++) {
         if (isset($visitorInformation['custom_var_k' . $i]) && strlen($visitorInformation['custom_var_k' . $i])) {
             $goal['custom_var_k' . $i] = $visitorInformation['custom_var_k' . $i];
         }
         if (isset($visitorInformation['custom_var_v' . $i]) && strlen($visitorInformation['custom_var_v' . $i])) {
             $goal['custom_var_v' . $i] = $visitorInformation['custom_var_v' . $i];
         }
     }
     // Attributing the correct Referrer to this conversion.
     // Priority order is as follows:
     // 0) In some cases, the campaign is not passed from the JS so we look it up from the current visit
     // 1) Campaign name/kwd parsed in the JS
     // 2) Referrer URL stored in the _ref cookie
     // 3) If no info from the cookie, attribute to the current visit referrer
     // 3) Default values: current referrer
     $type = $visitorInformation['referer_type'];
     $name = $visitorInformation['referer_name'];
     $keyword = $visitorInformation['referer_keyword'];
     $time = $visitorInformation['visit_first_action_time'];
     // 0) In some (unknown!?) cases the campaign is not found in the attribution cookie, but the URL ref was found.
     //    In this case we look up if the current visit is credited to a campaign and will credit this campaign rather than the URL ref (since campaigns have higher priority)
     if (empty($referrerCampaignName) && $type == Common::REFERRER_TYPE_CAMPAIGN && !empty($name)) {
         // Use default values per above
     } elseif (!empty($referrerCampaignName)) {
         $type = Common::REFERRER_TYPE_CAMPAIGN;
         $name = $referrerCampaignName;
         $keyword = $referrerCampaignKeyword;
         $time = $referrerTimestamp;
     } elseif (!empty($referrerUrl)) {
         $referrer = new Referrer();
         $referrer = $referrer->getReferrerInformation($referrerUrl, $currentUrl = '', $idSite);
         // if the parsed referrer is interesting enough, ie. website or search engine
         if (in_array($referrer['referer_type'], array(Common::REFERRER_TYPE_SEARCH_ENGINE, Common::REFERRER_TYPE_WEBSITE))) {
             $type = $referrer['referer_type'];
             $name = $referrer['referer_name'];
             $keyword = $referrer['referer_keyword'];
             $time = $referrerTimestamp;
         }
     }
     $this->setCampaignValuesToLowercase($type, $name, $keyword);
     $goal += array('referer_type' => $type, 'referer_name' => $name, 'referer_keyword' => $keyword, 'referer_visit_server_date' => date("Y-m-d", $time));
     // some goals are converted, so must be ecommerce Order or Cart Update
     if ($this->requestIsEcommerce) {
         $this->recordEcommerceGoal($goal, $visitorInformation);
     } else {
         $this->recordStandardGoals($goal, $action, $visitorInformation);
     }
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:75,代码来源:GoalManager.php

示例6: onNewVisit

 /**
  * @param Request $request
  * @param Visitor $visitor
  * @param Action|null $action
  * @return mixed
  */
 public function onNewVisit(Request $request, Visitor $visitor, $action)
 {
     return $this->getSingleLanguageFromAcceptedLanguages($request->getBrowserLanguage());
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:10,代码来源:Language.php

示例7: onAnyGoalConversion

 /**
  * @param Request $request
  * @param Visitor $visitor
  * @param Action|null $action
  * @return mixed
  */
 public function onAnyGoalConversion(Request $request, Visitor $visitor, $action)
 {
     $country = $visitor->getVisitorColumn($this->columnName);
     if (isset($country) && false !== $country) {
         return $country;
     }
     $browserLanguage = $request->getBrowserLanguage();
     $enableLanguageToCountryGuess = Config::getInstance()->Tracker['enable_language_to_country_guess'];
     $locationIp = $visitor->getVisitorColumn('location_ip');
     $country = Common::getCountry($browserLanguage, $enableLanguageToCountryGuess, $locationIp);
     return $country;
 }
开发者ID:piwik,项目名称:piwik,代码行数:18,代码来源:Country.php

示例8: getLocale

 private function getLocale(Visitor $visitor, Request $request)
 {
     return \Locale::acceptFromHttp($request->getBrowserLanguage());
 }
开发者ID:ThaDafinser,项目名称:Piwik-GeoIpChain,代码行数:4,代码来源:AbstractVisitDimension.php


注:本文中的Piwik\Tracker\Request::getBrowserLanguage方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。