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


PHP Piwik_Common::getParameterFromQueryString方法代码示例

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


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

示例1: test_getParameterFromQueryString

 function test_getParameterFromQueryString()
 {
     $tests = array('x' => false, 'x=1' => '1', '?x=1' => '1', '?x=y==1' => 'y==1', 'x[]=' => array(''), 'x[]=1' => array('1'), 'x[]=y==1' => array('y==1'), '?x[]=1&x[]=2' => array('1', '2'), '?x%5b%5d=3&x[]=4' => array('3', '4'), '?x%5B]=5&x[%5D=6' => array('5', '6'), '?x%5B%5D=A%26y%3D1' => array('A%26y%3D1'), '?z=y%26x%5b%5d%3d1' => null);
     // use $i as the test index because simpletest uses sprintf() internally and the percent encoding causes an error
     $i = 0;
     foreach ($tests as $test => $expected) {
         $i++;
         $this->assertTrue(Piwik_Common::getParameterFromQueryString($test, 'y') === null, $i);
         $this->assertTrue(Piwik_Common::getParameterFromQueryString($test, 'x') === $expected, $i);
     }
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:11,代码来源:Common.test.php

示例2: test_getParameterFromQueryString_strangeChars

 /**
  * normal use case with a string with many strange characters
  */
 function test_getParameterFromQueryString_strangeChars()
 {
     $urlQuery = 'toto=mama&mama=&tuytyt=Поиск в Интернете  Поиск страниц на русском _*()!$!£$^!£$%&toto=mama second value';
     $parameter = "tuytyt";
     $result = Piwik_Common::getParameterFromQueryString($urlQuery, $parameter);
     $expectedResult = 'Поиск в Интернете  Поиск страниц на русском _*()!$!£$^!£$%';
     $this->assertEqual($result, $expectedResult);
 }
开发者ID:klando,项目名称:pgpiwik,代码行数:11,代码来源:Common.test.php

示例3: detectRefererCampaign

 protected function detectRefererCampaign()
 {
     if (isset($this->currentUrlParse['query'])) {
         $campaignVariableName = Piwik_Tracker_Config::getInstance()->Tracker['campaign_var_name'];
         $campaignName = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $campaignVariableName);
         if (!empty($campaignName)) {
             $campaignKeywordVariableName = Piwik_Tracker_Config::getInstance()->Tracker['campaign_keyword_var_name'];
             $campaignKeyword = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $campaignKeywordVariableName);
             $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_CAMPAIGN;
             $this->nameRefererAnalyzed = $campaignName;
             if (!empty($campaignKeyword)) {
                 $this->keywordRefererAnalyzed = $campaignKeyword;
             }
             return true;
         }
     }
     return false;
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:18,代码来源:Visit.php

示例4: getKeywordPosition

 function getKeywordPosition()
 {
     if ($this->getRefererType() == 'search' && strpos($this->getRefererName(), 'Google') !== false) {
         $url = $this->getRefererUrl();
         $url = @parse_url($url);
         if (empty($url['query'])) {
             return null;
         }
         $position = Piwik_Common::getParameterFromQueryString($url['query'], 'cd');
         if (!empty($position)) {
             return $position;
         }
     }
     return null;
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:15,代码来源:Visitor.php

示例5: extractSearchEngineInformationFromUrl

 /**
  * 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
  * 
  * Lists of supported search engines can be found in /core/DataFiles/SearchEngines.php
  * 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 URL referer URL, eg. $_SERVER['HTTP_REFERER']
  * @return array|false false if a keyword couldn't be extracted,
  * 						or array(
  * 							'name' => 'Google', 
  * 							'keywords' => 'my searched keywords') 
  */
 public static function extractSearchEngineInformationFromUrl($refererUrl)
 {
     $refererParsed = @parse_url($refererUrl);
     $refererHost = '';
     if (isset($refererParsed['host'])) {
         $refererHost = $refererParsed['host'];
     }
     if (empty($refererHost)) {
         return false;
     }
     if (!isset($refererParsed['query'])) {
         return false;
     }
     require_once PIWIK_INCLUDE_PATH . '/core/DataFiles/SearchEngines.php';
     if (!array_key_exists($refererHost, $GLOBALS['Piwik_SearchEngines'])) {
         return false;
     }
     $searchEngineName = $GLOBALS['Piwik_SearchEngines'][$refererHost][0];
     $variableNames = $GLOBALS['Piwik_SearchEngines'][$refererHost][1];
     if (!is_array($variableNames)) {
         $variableNames = array($variableNames);
     }
     $query = $refererParsed['query'];
     if ($searchEngineName == 'Google Images') {
         $query = urldecode(trim(strtolower(Piwik_Common::getParameterFromQueryString($query, 'prev'))));
         $query = str_replace('&', '&', strstr($query, '?'));
     }
     foreach ($variableNames as $variableName) {
         // search for keywords now &vname=keyword
         $key = strtolower(Piwik_Common::getParameterFromQueryString($query, $variableName));
         $key = trim(urldecode($key));
         if (!empty($key)) {
             break;
         }
     }
     if (empty($key)) {
         return false;
     }
     if (function_exists('iconv') && isset($GLOBALS['Piwik_SearchEngines'][$refererHost][3])) {
         $charset = trim($GLOBALS['Piwik_SearchEngines'][$refererHost][3]);
         if (!empty($charset)) {
             $key = @iconv($charset, 'utf-8//IGNORE', $key);
         }
     }
     return array('name' => $searchEngineName, 'keywords' => $key);
 }
开发者ID:BackupTheBerlios,项目名称:oos-svn,代码行数:66,代码来源:Common.php

示例6: detectCampaignFromString

 /**
  * @param string $string
  * @return bool
  */
 protected function detectCampaignFromString($string)
 {
     foreach ($this->campaignNames as $campaignNameParameter) {
         $campaignName = trim(urldecode(Piwik_Common::getParameterFromQueryString($string, $campaignNameParameter)));
         if (!empty($campaignName)) {
             break;
         }
     }
     if (!empty($campaignName)) {
         $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_CAMPAIGN;
         $this->nameRefererAnalyzed = $campaignName;
         foreach ($this->campaignKeywords as $campaignKeywordParameter) {
             $campaignKeyword = Piwik_Common::getParameterFromQueryString($string, $campaignKeywordParameter);
             if (!empty($campaignKeyword)) {
                 $this->keywordRefererAnalyzed = trim(urldecode($campaignKeyword));
                 break;
             }
         }
         return true;
     }
     return false;
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:26,代码来源:Visit.php

示例7: detectRefererCampaign

 protected function detectRefererCampaign()
 {
     if (isset($this->currentUrlParse['query'])) {
         $campaignParameters = Piwik_Common::getCampaignParameters();
         $campaignNames = $campaignParameters[0];
         foreach ($campaignNames as $campaignNameParameter) {
             $campaignName = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $campaignNameParameter);
             if (!empty($campaignName)) {
                 break;
             }
         }
         if (!empty($campaignName)) {
             $this->typeRefererAnalyzed = Piwik_Common::REFERER_TYPE_CAMPAIGN;
             $this->nameRefererAnalyzed = $campaignName;
             $campaignKeywords = $campaignParameters[1];
             foreach ($campaignKeywords as $campaignKeywordParameter) {
                 $campaignKeyword = Piwik_Common::getParameterFromQueryString($this->currentUrlParse['query'], $campaignKeywordParameter);
                 if (!empty($campaignKeyword)) {
                     $this->keywordRefererAnalyzed = $campaignKeyword;
                     break;
                 }
             }
             return true;
         }
     }
     return false;
 }
开发者ID:Gninety,项目名称:Microweber,代码行数:27,代码来源:Visit.php

示例8: testGetParameterFromQueryString

 /**
  * @dataProvider getQueryStrings
  * @group Core
  * @group Common
  * @group getParameterFromQueryString
  */
 public function testGetParameterFromQueryString($queryString, $parameter, $expected)
 {
     $this->assertSame($expected, Piwik_Common::getParameterFromQueryString($queryString, $parameter));
 }
开发者ID:nnnnathann,项目名称:piwik,代码行数:10,代码来源:CommonTest.php


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