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


PHP Common::json_decode方法代码示例

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


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

示例1: loadJsonMetadata

 private function loadJsonMetadata($path)
 {
     if (!file_exists($path)) {
         return array();
     }
     $json = file_get_contents($path);
     if (!$json) {
         return array();
     }
     $info = Common::json_decode($json, $assoc = true);
     if (!is_array($info) || empty($info)) {
         throw new Exception("Invalid JSON file: {$path}");
     }
     return $info;
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:15,代码来源:MetadataLoader.php

示例2: getBacklinkStats

 /**
  * Returns backlink statistics including the count of backlinks and count of
  * referrer domains (domains with backlinks).
  *
  * This method issues an HTTP request and waits for it to return.
  *
  * @param string $siteDomain The domain of the website to get stats for.
  * @param int $timeout The number of seconds to wait before aborting
  *                     the HTTP request.
  * @return array An array containing the backlink count and referrer
  *               domain count:
  *               array(
  *                   'backlink_count' => X,
  *                   'referrer_domains_count' => Y
  *               )
  *               If either stat is false, either the API returned an
  *               error, or the IP was blocked for this request.
  */
 public function getBacklinkStats($siteDomain, $timeout = 300)
 {
     $apiUrl = $this->getApiUrl($method = 'GetBacklinkStats', $args = array('items' => '1', 'item0' => $siteDomain));
     $apiResponse = Http::sendHttpRequest($apiUrl, $timeout);
     $result = array('backlink_count' => false, 'referrer_domains_count' => false);
     $apiResponse = Common::json_decode($apiResponse, $assoc = true);
     if (!empty($apiResponse) && !empty($apiResponse['Data'])) {
         $siteSeoStats = reset($apiResponse['Data']);
         if (isset($siteSeoStats['ExtBackLinks']) && $siteSeoStats['ExtBackLinks'] !== -1) {
             $result['backlink_count'] = $siteSeoStats['ExtBackLinks'];
         }
         if (isset($siteSeoStats['RefDomains']) && $siteSeoStats['RefDomains'] !== -1) {
             $result['referrer_domains_count'] = $siteSeoStats['RefDomains'];
         }
     }
     return $result;
 }
开发者ID:kreynen,项目名称:elmsln,代码行数:35,代码来源:MajesticClient.php

示例3: getUserSettings

 private function getUserSettings($user)
 {
     $optionIndex = $user . MobileMessaging::USER_SETTINGS_POSTFIX_OPTION;
     $userSettings = Option::get($optionIndex);
     if (empty($userSettings)) {
         $userSettings = array();
     } else {
         $userSettings = Common::json_decode($userSettings, true);
     }
     return $userSettings;
 }
开发者ID:carriercomm,项目名称:piwik,代码行数:11,代码来源:API.php

示例4: getEcommerceItemsFromRequest

 /**
  * Returns Items read from the request string
  * @return array|bool
  */
 private function getEcommerceItemsFromRequest()
 {
     $items = Common::unsanitizeInputValue($this->request->getParam('ec_items'));
     if (empty($items)) {
         Common::printDebug("There are no Ecommerce items in the request");
         // we still record an Ecommerce order without any item in it
         return array();
     }
     $items = Common::json_decode($items, $assoc = true);
     if (!is_array($items)) {
         Common::printDebug("Error while json_decode the Ecommerce items = " . var_export($items, true));
         return false;
     }
     $cleanedItems = $this->getCleanedEcommerceItems($items);
     return $cleanedItems;
 }
开发者ID:huycao,项目名称:yodelivery,代码行数:20,代码来源:GoalManager.php

示例5: aggregateEcommerceCategories

 /**
  * @param string $key
  * @param string $value
  * @param $row
  * @return bool True if the $row metrics were already added to the ->metrics
  */
 protected function aggregateEcommerceCategories($key, $value, $row)
 {
     $ecommerceCategoriesAggregated = false;
     if ($key == '_pkc' && $value[0] == '[' && $value[1] == '"') {
         // In case categories were truncated, try closing the array
         if (substr($value, -2) != '"]') {
             $value .= '"]';
         }
         $decoded = @Common::json_decode($value);
         if (is_array($decoded)) {
             $count = 0;
             foreach ($decoded as $category) {
                 if (empty($category) || $count >= GoalManager::MAXIMUM_PRODUCT_CATEGORIES) {
                     continue;
                 }
                 $this->aggregateActionByKeyAndValue($key, $category, $row);
                 $ecommerceCategoriesAggregated = true;
                 $count++;
             }
         }
     }
     return $ecommerceCategoriesAggregated;
 }
开发者ID:TensorWrenchOSS,项目名称:piwik,代码行数:29,代码来源:Archiver.php

示例6: generateReport

 /**
  * Generates a report file.
  *
  * @param int $idReport ID of the report to generate.
  * @param string $date YYYY-MM-DD
  * @param bool|false|string $language If not passed, will use default language.
  * @param bool|false|int $outputType 1 = download report, 2 = save report to disk, 3 = output report in browser, 4 = return report content to caller, defaults to download
  * @param bool|false|string $period Defaults to 'day'. If not specified, will default to the report's period set when creating the report
  * @param bool|false|string $reportFormat 'pdf', 'html' or any other format provided via the ScheduledReports.getReportFormats hook
  * @param bool|false|array $parameters array of parameters
  * @return array|void
  */
 public function generateReport($idReport, $date, $language = false, $outputType = false, $period = false, $reportFormat = false, $parameters = false)
 {
     Piwik::checkUserIsNotAnonymous();
     // load specified language
     if (empty($language)) {
         $language = Translate::getLanguageDefault();
     }
     Translate::reloadLanguage($language);
     $reports = $this->getReports($idSite = false, $_period = false, $idReport);
     $report = reset($reports);
     $idSite = $report['idsite'];
     $login = $report['login'];
     $reportType = $report['type'];
     $this->checkUserHasViewPermission($login, $idSite);
     // override report period
     if (empty($period)) {
         $period = $report['period'];
     }
     // override report format
     if (!empty($reportFormat)) {
         self::validateReportFormat($reportType, $reportFormat);
         $report['format'] = $reportFormat;
     } else {
         $reportFormat = $report['format'];
     }
     // override and/or validate report parameters
     $report['parameters'] = Common::json_decode(self::validateReportParameters($reportType, empty($parameters) ? $report['parameters'] : $parameters), true);
     // available reports
     $availableReportMetadata = \Piwik\Plugins\API\API::getInstance()->getReportMetadata($idSite);
     // we need to lookup which reports metadata are registered in this report
     $reportMetadata = array();
     foreach ($availableReportMetadata as $metadata) {
         if (in_array($metadata['uniqueId'], $report['reports'])) {
             $reportMetadata[] = $metadata;
         }
     }
     // the report will be rendered with the first 23 rows and will aggregate other rows in a summary row
     // 23 rows table fits in one portrait page
     $initialFilterTruncate = Common::getRequestVar('filter_truncate', false);
     $_GET['filter_truncate'] = self::REPORT_TRUNCATE;
     $prettyDate = null;
     $processedReports = array();
     $segment = self::getSegment($report['idsegment']);
     foreach ($reportMetadata as $action) {
         $apiModule = $action['module'];
         $apiAction = $action['action'];
         $apiParameters = array();
         if (isset($action['parameters'])) {
             $apiParameters = $action['parameters'];
         }
         $mustRestoreGET = false;
         // all Websites dashboard should not be truncated in the report
         if ($apiModule == 'MultiSites') {
             $mustRestoreGET = $_GET;
             $_GET['enhanced'] = true;
             if ($apiAction == 'getAll') {
                 $_GET['filter_truncate'] = false;
                 // when a view/admin user created a report, workaround the fact that "Super User"
                 // is enforced in Scheduled tasks, and ensure Multisites.getAll only return the websites that this user can access
                 $userLogin = $report['login'];
                 if (!empty($userLogin) && !Piwik::hasTheUserSuperUserAccess($userLogin)) {
                     $_GET['_restrictSitesToLogin'] = $userLogin;
                 }
             }
         }
         $processedReport = \Piwik\Plugins\API\API::getInstance()->getProcessedReport($idSite, $period, $date, $apiModule, $apiAction, $segment != null ? urlencode($segment['definition']) : false, $apiParameters, $idGoal = false, $language);
         $processedReport['segment'] = $segment;
         // TODO add static method getPrettyDate($period, $date) in Period
         $prettyDate = $processedReport['prettyDate'];
         if ($mustRestoreGET) {
             $_GET = $mustRestoreGET;
         }
         $processedReports[] = $processedReport;
     }
     // restore filter truncate parameter value
     if ($initialFilterTruncate !== false) {
         $_GET['filter_truncate'] = $initialFilterTruncate;
     }
     /**
      * Triggered when generating the content of scheduled reports.
      *
      * This event can be used to modify the report data or report metadata of one or more reports
      * in a scheduled report, before the scheduled report is rendered and delivered.
      * 
      * TODO: list data available in $report or make it a new class that can be documented (same for
      *       all other events that use a $report)
      * 
      * @param array &$processedReports The list of processed reports in the scheduled
//.........这里部分代码省略.........
开发者ID:carriercomm,项目名称:piwik,代码行数:101,代码来源:API.php

示例7: decodeLayout

 public function decodeLayout($layout)
 {
     if ($this->isAlreadyDecodedLayout($layout)) {
         return $layout;
     }
     $layout = html_entity_decode($layout);
     $layout = str_replace("\\\"", "\"", $layout);
     $layout = str_replace("\n", "", $layout);
     return Common::json_decode($layout, $assoc = false);
 }
开发者ID:brienomatty,项目名称:elmsln,代码行数:10,代码来源:Dashboard.php


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