本文整理汇总了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;
}
示例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
//.........这里部分代码省略.........