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


PHP Translate::getLanguageDefault方法代码示例

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


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

示例1: getLanguageCodeForCurrentUser

 /**
  * @return string Two letters language code, eg. "fr"
  */
 public static function getLanguageCodeForCurrentUser()
 {
     $languageCode = self::getLanguageFromPreferences();
     if (!API::getInstance()->isLanguageAvailable($languageCode)) {
         $languageCode = Common::extractLanguageCodeFromBrowserLanguage(Common::getBrowserLanguage(), API::getInstance()->getAvailableLanguages());
     }
     if (!API::getInstance()->isLanguageAvailable($languageCode)) {
         $languageCode = Translate::getLanguageDefault();
     }
     return $languageCode;
 }
开发者ID:CaptainSharf,项目名称:SSAD_Project,代码行数:14,代码来源:LanguagesManager.php

示例2: 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


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