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


PHP UrlHelper::getArrayFromQueryString方法代码示例

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


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

示例1: initHostAndQueryString

 /**
  * @param InputInterface $input
  */
 protected function initHostAndQueryString(InputInterface $input)
 {
     $_GET = array();
     $hostname = $input->getOption('piwik-domain');
     Url::setHost($hostname);
     $query = $input->getArgument('url-query');
     $query = UrlHelper::getArrayFromQueryString($query);
     foreach ($query as $name => $value) {
         $_GET[$name] = $value;
     }
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:14,代码来源:RequestCommand.php

示例2: excludeQueryParametersFromUrl

 /**
  * Given the Input URL, will exclude all query parameters set for this site
  *
  * @static
  * @param $originalUrl
  * @param $idSite
  * @return bool|string
  */
 public static function excludeQueryParametersFromUrl($originalUrl, $idSite)
 {
     $originalUrl = self::cleanupUrl($originalUrl);
     $parsedUrl = @parse_url($originalUrl);
     $parsedUrl = self::cleanupHostAndHashTag($parsedUrl, $idSite);
     $parametersToExclude = self::getQueryParametersToExclude($idSite);
     if (empty($parsedUrl['query'])) {
         if (empty($parsedUrl['fragment'])) {
             return UrlHelper::getParseUrlReverse($parsedUrl);
         }
         // Exclude from the hash tag as well
         $queryParameters = UrlHelper::getArrayFromQueryString($parsedUrl['fragment']);
         $parsedUrl['fragment'] = UrlHelper::getQueryStringWithExcludedParameters($queryParameters, $parametersToExclude);
         $url = UrlHelper::getParseUrlReverse($parsedUrl);
         return $url;
     }
     $queryParameters = UrlHelper::getArrayFromQueryString($parsedUrl['query']);
     $parsedUrl['query'] = UrlHelper::getQueryStringWithExcludedParameters($queryParameters, $parametersToExclude);
     $url = UrlHelper::getParseUrlReverse($parsedUrl);
     return $url;
 }
开发者ID:bossrabbit,项目名称:piwik,代码行数:29,代码来源:PageUrl.php

示例3: generateApiUrlPermutations

 /**
  * Given a list of default parameters to set, returns the URLs of APIs to call
  * If any API was specified in $this->apiNotToCall we ensure only these are tested.
  * If any API is set as excluded (see list below) then it will be ignored.
  *
  * @param array $parametersToSet Parameters to set in api call
  * @param array $formats         Array of 'format' to fetch from API
  * @param array $periods         Array of 'period' to query API
  * @param bool  $supertableApi
  * @param bool  $setDateLastN    If set to true, the 'date' parameter will be rewritten to query instead a range of dates, rather than one period only.
  * @param bool|string $language        2 letter language code, defaults to default piwik language
  * @param bool|string $fileExtension
  *
  * @throws Exception
  *
  * @return array of API URLs query strings
  */
 protected function generateApiUrlPermutations($parametersToSet)
 {
     $formats = array($this->testConfig->format);
     $originalDate = $parametersToSet['date'];
     $requestUrls = array();
     $apiMetadata = new DocumentationGenerator();
     // Get the URLs to query against the API for all functions starting with get*
     foreach ($this->getAllApiMethods() as $apiMethodInfo) {
         list($class, $moduleName, $methodName) = $apiMethodInfo;
         $apiId = $moduleName . '.' . $methodName;
         foreach ($this->testConfig->periods as $period) {
             $parametersToSet['period'] = $period;
             // If date must be a date range, we process this date range by adding 6 periods to it
             if ($this->testConfig->setDateLastN) {
                 if (!isset($parametersToSet['dateRewriteBackup'])) {
                     $parametersToSet['dateRewriteBackup'] = $parametersToSet['date'];
                 }
                 $lastCount = $this->testConfig->setDateLastN;
                 $secondDate = date('Y-m-d', strtotime("+{$lastCount} " . $period . "s", strtotime($originalDate)));
                 $parametersToSet['date'] = $originalDate . ',' . $secondDate;
             }
             // Set response language
             if ($this->testConfig->language !== false) {
                 $parametersToSet['language'] = $this->testConfig->language;
             }
             // set idSubtable if subtable API is set
             if ($this->testConfig->supertableApi !== false) {
                 $request = new Request(array('module' => 'API', 'method' => $this->testConfig->supertableApi, 'idSite' => $parametersToSet['idSite'], 'period' => $parametersToSet['period'], 'date' => $parametersToSet['date'], 'format' => 'php', 'serialize' => 0));
                 $content = $request->process();
                 SystemTestCase::assertApiResponseHasNoError($content);
                 // find first row w/ subtable
                 foreach ($content as $row) {
                     if (isset($row['idsubdatatable'])) {
                         $parametersToSet['idSubtable'] = $row['idsubdatatable'];
                         break;
                     }
                 }
                 // if no subtable found, throw
                 if (!isset($parametersToSet['idSubtable'])) {
                     throw new Exception("Cannot find subtable to load for {$apiId} in {$this->testConfig->supertableApi}.");
                 }
             }
             // Generate for each specified format
             foreach ($formats as $format) {
                 $parametersToSet['format'] = $format;
                 $parametersToSet['hideIdSubDatable'] = 1;
                 $parametersToSet['serialize'] = 1;
                 $exampleUrl = $apiMetadata->getExampleUrl($class, $methodName, $parametersToSet);
                 if ($exampleUrl === false) {
                     continue;
                 }
                 // Remove the first ? in the query string
                 $exampleUrl = substr($exampleUrl, 1);
                 $apiRequestId = $apiId;
                 if (strpos($exampleUrl, 'period=') !== false) {
                     $apiRequestId .= '_' . $period;
                 }
                 $apiRequestId .= '.' . $format;
                 if ($this->testConfig->fileExtension) {
                     $apiRequestId .= '.' . $this->testConfig->fileExtension;
                 }
                 $requestUrls[$apiRequestId] = UrlHelper::getArrayFromQueryString($exampleUrl);
             }
         }
     }
     return $requestUrls;
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:84,代码来源:Collection.php

示例4: getArrayFromCurrentQueryString

 /**
  * Returns an array mapping query paramater names with query parameter values for
  * the current URL.
  *
  * @return array If current URL is `"http://example.org/dir1/dir2/index.php?param1=value1&param2=value2"`
  *               this will return:
  *               
  *                   array(
  *                       'param1' => string 'value1',
  *                       'param2' => string 'value2'
  *                   )
  * @api
  */
 public static function getArrayFromCurrentQueryString()
 {
     $queryString = self::getCurrentQueryString();
     $urlValues = UrlHelper::getArrayFromQueryString($queryString);
     return $urlValues;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:19,代码来源:Url.php

示例5: getRequestParametersGET

 /**
  * Returns the original request parameters in the current query string as an array mapping
  * query parameter names with values. The result of this function will not be affected
  * by any modifications to `$_GET` and will not include parameters in `$_POST`.
  *
  * @return array
  */
 public static function getRequestParametersGET()
 {
     if (empty($_SERVER['QUERY_STRING'])) {
         return array();
     }
     $GET = UrlHelper::getArrayFromQueryString($_SERVER['QUERY_STRING']);
     return $GET;
 }
开发者ID:josl,项目名称:CGE-File-Sharing,代码行数:15,代码来源:Request.php

示例6: detectSiteSearchFromUrl

 protected function detectSiteSearchFromUrl($website, $parsedUrl)
 {
     $doRemoveSearchParametersFromUrl = true;
     $separator = '&';
     $count = $actionName = $categoryName = false;
     $keywordParameters = isset($website['sitesearch_keyword_parameters']) ? $website['sitesearch_keyword_parameters'] : array();
     $queryString = (!empty($parsedUrl['query']) ? $parsedUrl['query'] : '') . (!empty($parsedUrl['fragment']) ? $separator . $parsedUrl['fragment'] : '');
     $parametersRaw = UrlHelper::getArrayFromQueryString($queryString);
     // strtolower the parameter names for smooth site search detection
     $parameters = array();
     foreach ($parametersRaw as $k => $v) {
         $parameters[Common::mb_strtolower($k)] = $v;
     }
     // decode values if they were sent from a client using another charset
     $pageEncoding = $this->request->getParam('cs');
     PageUrl::reencodeParameters($parameters, $pageEncoding);
     // Detect Site Search keyword
     foreach ($keywordParameters as $keywordParameterRaw) {
         $keywordParameter = Common::mb_strtolower($keywordParameterRaw);
         if (!empty($parameters[$keywordParameter])) {
             $actionName = $parameters[$keywordParameter];
             break;
         }
     }
     if (empty($actionName)) {
         return false;
     }
     $categoryParameters = isset($website['sitesearch_category_parameters']) ? $website['sitesearch_category_parameters'] : array();
     foreach ($categoryParameters as $categoryParameterRaw) {
         $categoryParameter = Common::mb_strtolower($categoryParameterRaw);
         if (!empty($parameters[$categoryParameter])) {
             $categoryName = $parameters[$categoryParameter];
             break;
         }
     }
     if (isset($parameters['search_count']) && $this->isValidSearchCount($parameters['search_count'])) {
         $count = $parameters['search_count'];
     }
     // Remove search kwd from URL
     if ($doRemoveSearchParametersFromUrl) {
         // @see excludeQueryParametersFromUrl()
         // Excluded the detected parameters from the URL
         $parametersToExclude = array($categoryParameterRaw, $keywordParameterRaw);
         if (isset($parsedUrl['query'])) {
             $parsedUrl['query'] = UrlHelper::getQueryStringWithExcludedParameters(UrlHelper::getArrayFromQueryString($parsedUrl['query']), $parametersToExclude);
         }
         if (isset($parsedUrl['fragment'])) {
             $parsedUrl['fragment'] = UrlHelper::getQueryStringWithExcludedParameters(UrlHelper::getArrayFromQueryString($parsedUrl['fragment']), $parametersToExclude);
         }
     }
     $url = UrlHelper::getParseUrlReverse($parsedUrl);
     if (is_array($actionName)) {
         $actionName = reset($actionName);
     }
     $actionName = trim(urldecode($actionName));
     if (empty($actionName)) {
         return false;
     }
     if (is_array($categoryName)) {
         $categoryName = reset($categoryName);
     }
     $categoryName = trim(urldecode($categoryName));
     return array($url, $actionName, $categoryName, $count);
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:64,代码来源:ActionSiteSearch.php

示例7: _testApiUrl

 protected function _testApiUrl($testName, $apiId, $requestUrl, $compareAgainst)
 {
     $isTestLogImportReverseChronological = strpos($testName, 'ImportedInRandomOrderTest') === false;
     $isLiveMustDeleteDates = (strpos($requestUrl, 'Live.getLastVisits') !== false || strpos($requestUrl, 'Live.getVisitorProfile') !== false) && $isTestLogImportReverseChronological;
     $request = new Request($requestUrl);
     $dateTime = Common::getRequestVar('date', '', 'string', UrlHelper::getArrayFromQueryString($requestUrl));
     list($processedFilePath, $expectedFilePath) = $this->getProcessedAndExpectedPaths($testName, $apiId, $format = null, $compareAgainst);
     // Cast as string is important. For example when calling
     // with format=original, objects or php arrays can be returned.
     // we also hide errors to prevent the 'headers already sent' in the ResponseBuilder (which sends Excel headers multiple times eg.)
     $response = (string) $request->process();
     if ($isLiveMustDeleteDates) {
         $response = $this->removeAllLiveDatesFromXml($response);
     }
     $response = $this->normalizePdfContent($response);
     $expected = $this->loadExpectedFile($expectedFilePath);
     $expectedContent = $expected;
     $expected = $this->normalizePdfContent($expected);
     if (empty($expected)) {
         if (empty($compareAgainst)) {
             file_put_contents($processedFilePath, $response);
         }
         print "The expected file is not found at '{$expectedFilePath}'. The Processed response was:";
         print "\n----------------------------\n\n";
         var_dump($response);
         print "\n----------------------------\n";
         return;
     }
     $expected = $this->removeXmlElement($expected, 'idsubdatatable', $testNotSmallAfter = false);
     $response = $this->removeXmlElement($response, 'idsubdatatable', $testNotSmallAfter = false);
     if ($isLiveMustDeleteDates) {
         $expected = $this->removeAllLiveDatesFromXml($expected);
     } elseif (strpos($dateTime, 'last') !== false || strpos($dateTime, 'today') !== false || strpos($dateTime, 'now') !== false) {
         if (strpos($requestUrl, 'API.getProcessedReport') !== false) {
             $expected = $this->removePrettyDateFromXml($expected);
             $response = $this->removePrettyDateFromXml($response);
         }
         $expected = $this->removeXmlElement($expected, 'visitServerHour');
         $response = $this->removeXmlElement($response, 'visitServerHour');
         if (strpos($requestUrl, 'date=') !== false) {
             $regex = "/date=[-0-9,%Ca-z]+/";
             // need to remove %2C which is encoded ,
             $expected = preg_replace($regex, 'date=', $expected);
             $response = preg_replace($regex, 'date=', $response);
         }
     }
     // if idSubtable is in request URL, make sure idSubtable values are not in any urls
     if (strpos($requestUrl, 'idSubtable=') !== false) {
         $regex = "/idSubtable=[0-9]+/";
         $expected = preg_replace($regex, 'idSubtable=', $expected);
         $response = preg_replace($regex, 'idSubtable=', $response);
     }
     // Do not test for TRUNCATE(SUM()) returning .00 on mysqli since this is not working
     // http://bugs.php.net/bug.php?id=54508
     $expected = str_replace('.000000</l', '</l', $expected);
     //lat/long
     $response = str_replace('.000000</l', '</l', $response);
     //lat/long
     $expected = str_replace('.00</revenue>', '</revenue>', $expected);
     $response = str_replace('.00</revenue>', '</revenue>', $response);
     $response = str_replace('.1</revenue>', '</revenue>', $response);
     $expected = str_replace('.1</revenue>', '</revenue>', $expected);
     $expected = str_replace('.11</revenue>', '</revenue>', $expected);
     $response = str_replace('.11</revenue>', '</revenue>', $response);
     if (empty($compareAgainst)) {
         file_put_contents($processedFilePath, $response);
     }
     try {
         if (strpos($requestUrl, 'format=xml') !== false) {
             $this->assertXmlStringEqualsXmlString($expected, $response, "Differences with expected in: {$processedFilePath}");
         } else {
             $this->assertEquals(strlen($expected), strlen($response), "Differences with expected in: {$processedFilePath}");
             $this->assertEquals($expected, $response, "Differences with expected in: {$processedFilePath}");
         }
         if (trim($response) == trim($expected) && empty($compareAgainst)) {
             if (trim($expectedContent) != trim($expected)) {
                 file_put_contents($expectedFilePath, $expected);
             }
         }
     } catch (Exception $ex) {
         $this->comparisonFailures[] = $ex;
     }
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:83,代码来源:IntegrationTestCase.php

示例8: popout

 public function popout()
 {
     header("Access-Control-Allow-Origin: *");
     $params = UrlHelper::getArrayFromQueryString($_SERVER['QUERY_STRING']);
     $request = new Tracker\Request($params);
     // the IP is needed by isExcluded() and GoalManager->recordGoals()
     $ip = $request->getIp();
     $visitorInfo['location_ip'] = $ip;
     /**
      * Triggered after visits are tested for exclusion so plugins can modify the IP address
      * persisted with a visit.
      *
      * This event is primarily used by the **PrivacyManager** plugin to anonymize IP addresses.
      *
      * @param string &$ip The visitor's IP address.
      */
     Piwik::postEvent('Tracker.setVisitorIp', array(&$visitorInfo['location_ip']));
     /***
      * Visitor recognition
      */
     $settings = new Tracker\Settings($request, $visitorInfo['location_ip']);
     $visitor = new Visitor($request, $settings->getConfigId(), $visitorInfo);
     $visitor->recognize();
     $visitorInfo = $visitor->getVisitorInfo();
     if (!isset($visitorInfo['location_browser_lang'])) {
         return "Who are you ?";
     }
     $idSite = Common::getRequestVar('idsite', null, 'int');
     $conversation = new ChatConversation($idSite, bin2hex($visitorInfo['idvisitor']));
     /***
      * Segment recognition
      */
     foreach (ChatAutomaticMessage::getAll($idSite) as $autoMsg) {
         $segment = ChatSegment::get($autoMsg['segmentID']);
         $fetchSegment = new Segment($segment['definition'], array($idSite));
         $query = $fetchSegment->getSelectQuery("idvisitor", "log_visit", "log_visit.idvisitor = ?", array($visitorInfo['idvisitor']));
         $rows = Db::fetchAll($query['sql'], $query['bind']);
         if (count($rows) == 0) {
             continue;
         }
         if ($autoMsg['segmentID'] != $segment['idsegment']) {
             continue;
         }
         $getAlreadyReceivedMsg = $conversation->getAutomaticMessageReceivedById($autoMsg['id']);
         if (count($getAlreadyReceivedMsg) > 0) {
             // If the AutoMsg is a "one shot"
             if ($autoMsg['frequency'] == 0) {
                 continue;
             }
             if ($autoMsg['frequency'] != 0) {
                 // Now, we gonna try to define when the last AutoMsg received has been sent
                 list($freqTime, $freqScale) = explode('|', $autoMsg['frequency']);
                 if ($freqScale == "w") {
                     $dayMultiplier = 7;
                 } elseif ($freqScale == "m") {
                     $dayMultiplier = 30;
                 } else {
                     $dayMultiplier = 1;
                 }
                 $secToWait = 3600 * 24 * $freqTime * $dayMultiplier;
                 // Is it older than the time range needed to wait ?
                 if ($getAlreadyReceivedMsg[0]['microtime'] + $secToWait > microtime(true)) {
                     continue;
                 }
             }
         }
         $conversation->sendMessage($autoMsg['message'], $autoMsg['transmitter'], $autoMsg['id']);
     }
     $view = new View('@Chat/popout.twig');
     $view->idvisitor = bin2hex($visitorInfo['idvisitor']);
     $view->idsite = $idSite;
     $view->timeLimit = time() - 2 * 60 * 60;
     $view->isStaffOnline = ChatPiwikUser::isStaffOnline();
     $view->siteUrl = ChatSite::getMainUrl($idSite);
     $view->lang = $visitorInfo['location_browser_lang'];
     return $view->render();
 }
开发者ID:WHATNEXTLIMITED,项目名称:piwik-chat,代码行数:77,代码来源:Controller.php

示例9: testGetArrayFromQueryString

 /**
  * @group Core
  */
 public function testGetArrayFromQueryString()
 {
     $expected = array('a' => false, 'b' => '', 'c' => '1', 'd' => array(false), 'e' => array(''), 'f' => array('a'), 'g' => array('b', 'c'));
     $this->assertEquals(serialize($expected), serialize(UrlHelper::getArrayFromQueryString('a&b=&c=1&d[]&e[]=&f[]=a&g[]=b&g[]=c')));
 }
开发者ID:ahdinosaur,项目名称:analytics.dinosaur.is,代码行数:8,代码来源:UrlHelperTest.php

示例10: foreach

<?php 
$_GET['idSite'] = $idSite;
define('PIWIK_INCLUDE_PATH', '../..');
define('PIWIK_ENABLE_DISPATCH', false);
define('PIWIK_ENABLE_ERROR_HANDLER', false);
define('PIWIK_ENABLE_SESSION_START', false);
require_once PIWIK_INCLUDE_PATH . "/index.php";
require_once PIWIK_INCLUDE_PATH . "/core/API/Request.php";
FrontController::getInstance()->init();
$widgets = WidgetsList::get();
foreach ($widgets as $category => $widgetsInCategory) {
    echo '<h2>' . $category . '</h2>';
    foreach ($widgetsInCategory as $widget) {
        echo '<h3>' . $widget['name'] . '</h3>';
        $widgetUrl = UrlHelper::getArrayFromQueryString($url);
        $widgetUrl['moduleToWidgetize'] = $widget['parameters']['module'];
        $widgetUrl['actionToWidgetize'] = $widget['parameters']['action'];
        $parameters = $widget['parameters'];
        unset($parameters['module']);
        unset($parameters['action']);
        foreach ($parameters as $name => $value) {
            if (is_array($value)) {
                $value = current($value);
            }
            $widgetUrl[$name] = $value;
        }
        $widgetUrl = Url::getQueryStringFromParameters($widgetUrl);
        echo '<div id="widgetIframe"><iframe width="500" height="350"
			src="' . $widgetUrl . '" scrolling="no" frameborder="0" marginheight="0" marginwidth="0"></iframe></div>';
    }
开发者ID:FluentDevelopment,项目名称:piwik,代码行数:30,代码来源:iframeWidget_localhost.php

示例11: extractUtmDetailsFromUrl

 /**
  * Extracts the utm query parameters into array
  * @return array 
  */
 private function extractUtmDetailsFromUrl()
 {
     $query = $this->currentUrlParse['query'];
     $params = UrlHelper::getArrayFromQueryString($query);
     return array('utm_campaign' => isset($params['utm_campaign']) ? $params['utm_campaign'] : '', 'utm_term' => isset($params['utm_term']) ? $params['utm_term'] : '', 'utm_medium' => isset($params['utm_medium']) ? $params['utm_medium'] : '', 'utm_content' => isset($params['utm_content']) ? $params['utm_content'] : '', 'utm_source' => isset($params['utm_source']) ? $params['utm_source'] : '');
 }
开发者ID:adevait,项目名称:CampaignDetailed,代码行数:10,代码来源:Base.php


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