當前位置: 首頁>>代碼示例>>PHP>>正文


PHP UrlHelper::getParameterFromQueryString方法代碼示例

本文整理匯總了PHP中Piwik\UrlHelper::getParameterFromQueryString方法的典型用法代碼示例。如果您正苦於以下問題:PHP UrlHelper::getParameterFromQueryString方法的具體用法?PHP UrlHelper::getParameterFromQueryString怎麽用?PHP UrlHelper::getParameterFromQueryString使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Piwik\UrlHelper的用法示例。


在下文中一共展示了UrlHelper::getParameterFromQueryString方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。

示例1: getKeywordPosition

 public function getKeywordPosition()
 {
     if ($this->getReferrerType() == 'search' && strpos($this->getReferrerName(), 'Google') !== false) {
         $url = @parse_url($this->details['referer_url']);
         if (empty($url['query'])) {
             return null;
         }
         $position = UrlHelper::getParameterFromQueryString($url['query'], 'cd');
         if (!empty($position)) {
             return $position;
         }
     }
     return null;
 }
開發者ID:dorelljames,項目名稱:piwik,代碼行數:14,代碼來源:Visitor.php

示例2: getParameterValueFromReferrerUrl

 /**
  * @return string
  */
 protected function getParameterValueFromReferrerUrl($adsenseReferrerParameter)
 {
     $value = trim(urldecode(UrlHelper::getParameterFromQueryString($this->referrerUrlParse['query'], $adsenseReferrerParameter)));
     return $value;
 }
開發者ID:diosmosis,項目名稱:piwik,代碼行數:8,代碼來源:Base.php

示例3: extractInformationFromUrl

 /**
  * Extracts a keyword from a raw not encoded URL.
  * Will only extract keyword if a known search engine has been detected.
  * Returns the keyword:
  * - in UTF8: automatically converted from other charsets when applicable
  * - strtolowered: "QUErY test!" will return "query test!"
  * - trimmed: extra spaces before and after are removed
  *
  * The function returns false when a keyword couldn't be found.
  *     eg. if the url is "http://www.google.com/partners.html" this will return false,
  *       as the google keyword parameter couldn't be found.
  *
  * @see unit tests in /tests/core/Common.test.php
  * @param string $referrerUrl URL referrer URL, eg. $_SERVER['HTTP_REFERER']
  * @return array|bool   false if a keyword couldn't be extracted,
  *                        or array(
  *                            'name' => 'Google',
  *                            'keywords' => 'my searched keywords')
  */
 public function extractInformationFromUrl($referrerUrl)
 {
     $referrerParsed = @parse_url($referrerUrl);
     $referrerHost = '';
     if (isset($referrerParsed['host'])) {
         $referrerHost = $referrerParsed['host'];
     }
     if (empty($referrerHost)) {
         return false;
     }
     // some search engines (eg. Bing Images) use the same domain
     // as an existing search engine (eg. Bing), we must also use the url path
     $referrerPath = '';
     if (isset($referrerParsed['path'])) {
         $referrerPath = $referrerParsed['path'];
     }
     $query = '';
     if (isset($referrerParsed['query'])) {
         $query = $referrerParsed['query'];
     }
     // Google Referrers URLs sometimes have the fragment which contains the keyword
     if (!empty($referrerParsed['fragment'])) {
         $query .= '&' . $referrerParsed['fragment'];
     }
     $referrerHost = $this->getEngineHostFromUrl($referrerHost, $referrerPath, $query);
     if (empty($referrerHost)) {
         return false;
     }
     $definitions = $this->getDefinitionByHost($referrerHost);
     $searchEngineName = $definitions['name'];
     $variableNames = $definitions['params'];
     $key = null;
     if ($searchEngineName === 'Google Images' || $searchEngineName === 'Google' && strpos($referrerUrl, '/imgres') !== false) {
         if (strpos($query, '&prev') !== false) {
             $query = urldecode(trim(UrlHelper::getParameterFromQueryString($query, 'prev')));
             $query = str_replace('&', '&', strstr($query, '?'));
         }
         $searchEngineName = 'Google Images';
     } elseif ($searchEngineName === 'Google' && (strpos($query, '&as_') !== false || strpos($query, 'as_') === 0)) {
         $keys = array();
         $key = UrlHelper::getParameterFromQueryString($query, 'as_q');
         if (!empty($key)) {
             array_push($keys, $key);
         }
         $key = UrlHelper::getParameterFromQueryString($query, 'as_oq');
         if (!empty($key)) {
             array_push($keys, str_replace('+', ' OR ', $key));
         }
         $key = UrlHelper::getParameterFromQueryString($query, 'as_epq');
         if (!empty($key)) {
             array_push($keys, "\"{$key}\"");
         }
         $key = UrlHelper::getParameterFromQueryString($query, 'as_eq');
         if (!empty($key)) {
             array_push($keys, "-{$key}");
         }
         $key = trim(urldecode(implode(' ', $keys)));
     }
     if ($searchEngineName === 'Google') {
         // top bar menu
         $tbm = UrlHelper::getParameterFromQueryString($query, 'tbm');
         switch ($tbm) {
             case 'isch':
                 $searchEngineName = 'Google Images';
                 break;
             case 'vid':
                 $searchEngineName = 'Google Video';
                 break;
             case 'shop':
                 $searchEngineName = 'Google Shopping';
                 break;
         }
     }
     if (empty($key)) {
         foreach ($variableNames as $variableName) {
             if ($variableName[0] == '/') {
                 // regular expression match
                 if (preg_match($variableName, $referrerUrl, $matches)) {
                     $key = trim(urldecode($matches[1]));
                     break;
                 }
//.........這裏部分代碼省略.........
開發者ID:dorelljames,項目名稱:piwik,代碼行數:101,代碼來源:SearchEngine.php

示例4: testGetParameterFromQueryString

 /**
  * @dataProvider getQueryStrings
  * @group Core
  */
 public function testGetParameterFromQueryString($queryString, $parameter, $expected)
 {
     $this->assertSame($expected, UrlHelper::getParameterFromQueryString($queryString, $parameter));
 }
開發者ID:ahdinosaur,項目名稱:analytics.dinosaur.is,代碼行數:8,代碼來源:UrlHelperTest.php

示例5: test_getQueryFromUrl_whenUrlParameterIsDuplicatedInQueryString_returnsLastFoundValue

 public function test_getQueryFromUrl_whenUrlParameterIsDuplicatedInQueryString_returnsLastFoundValue()
 {
     // Currently when the same parameter is used several times in the query string,
     // only the last set value is returned by UrlHelper::getParameterFromQueryString
     // refs https://github.com/piwik/piwik/issues/9842#issue-136043409
     $this->assertEquals('blue', UrlHelper::getParameterFromQueryString('selected_colors=red&selected_colors=blue&par3=1', 'selected_colors'));
     $this->assertEquals('selected_colors=red&selected_colors=blue&par3=1', UrlHelper::getQueryFromUrl('http:/mydomain.com?selected_colors=red&selected_colors=blue&par3=1', array()));
 }
開發者ID:diosmosis,項目名稱:piwik,代碼行數:8,代碼來源:UrlHelperTest.php


注:本文中的Piwik\UrlHelper::getParameterFromQueryString方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。