本文整理汇总了PHP中Piwik::isGdExtensionEnabled方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::isGdExtensionEnabled方法的具体用法?PHP Piwik::isGdExtensionEnabled怎么用?PHP Piwik::isGdExtensionEnabled使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik
的用法示例。
在下文中一共展示了Piwik::isGdExtensionEnabled方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: generateReport
/**
* Generates a report file.
*
* @param int $idReport ID of the report to generate. If idReport=0 it will generate a report containing all reports
* for the specified period & date
* @param string $date YYYY-MM-DD
* @param int|false $idSite
* @param string|false $language If not passed, will use default language.
* @param int|false $outputType 1 = download report, 2 = save report to disk, defaults to download
* @param string|false $period Defaults to 'day'. If not specified, will default to the report's period set when creating the report
* @param string $reportFormat pdf, html
* @param int|false $aggregateReportsFormat 1 = display only tables, 2 = display only graphs, 3 = display both
*/
public function generateReport($idReport, $date, $idSite = false, $language = false, $outputType = false, $period = false, $reportFormat = false, $aggregateReportsFormat = false)
{
Piwik::checkUserIsNotAnonymous();
// Load specified language
if (empty($language)) {
$language = Piwik_Translate::getInstance()->getLanguageDefault();
}
Piwik_Translate::getInstance()->reloadLanguage($language);
// Available reports
$reportMetadata = Piwik_API_API::getInstance()->getReportMetadata($idSite);
// Test template: include all reports
if ($idReport == 0) {
if (empty($period)) {
$period = 'day';
}
if (empty($reportFormat)) {
$reportFormat = Piwik_PDFReports::DEFAULT_FORMAT;
}
if (empty($aggregateReportsFormat)) {
$aggregateReportsFormat = Piwik_PDFReports::DEFAULT_AGGREGATE_REPORTS_FORMAT;
}
$reports = array();
foreach ($reportMetadata as $report) {
if ($report['category'] != 'API') {
$reports[] = $report;
}
}
$description = Piwik_Translate('PDFReports_DefaultContainingAllReports');
} else {
$pdfReports = $this->getReports($idSite, $_period = false, $idReport);
$pdfReport = reset($pdfReports);
$reportUniqueIds = explode(',', $pdfReport['reports']);
$description = $pdfReport['description'];
// If period wasn't specified, we shall default to the report's period
if (empty($period)) {
$period = 'day';
if ($pdfReport['period'] != 'never') {
$period = $pdfReport['period'];
}
}
// If format wasn't specified, defaults to the report's format
if (empty($reportFormat)) {
$reportFormat = $pdfReport['format'];
// Handle cases for reports created before the 'format' field
if (empty($reportFormat)) {
$reportFormat = Piwik_PDFReports::DEFAULT_FORMAT;
}
}
// If $aggregateReportsFormat wasn't specified, defaults to the report configuration
if (empty($aggregateReportsFormat)) {
$aggregateReportsFormat = $pdfReport['aggregate_reports_format'];
}
// We need to lookup which reports metadata are registered in this report
$reports = array();
foreach ($reportMetadata as $metadata) {
if (in_array($metadata['uniqueId'], $reportUniqueIds)) {
$reports[] = $metadata;
}
}
}
// prepare the report renderer
$reportRenderer = Piwik_ReportRenderer::factory($reportFormat);
$reportRenderer->setLocale($language);
$reportRenderer->setRenderImageInline($outputType == self::OUTPUT_DOWNLOAD ? true : false);
$description = str_replace(array("\r", "\n"), ' ', $description);
// The report will be rendered with the first 23 rows and will aggregate other rows in a summary row
$filterTruncateGET = Piwik_Common::getRequestVar('filter_truncate', false);
$_GET['filter_truncate'] = 23;
$websiteName = $prettyDate = false;
$processedReports = array();
foreach ($reports as $action) {
$apiModule = $action['module'];
$apiAction = $action['action'];
$apiParameters = array();
if (isset($action['parameters'])) {
$apiParameters = $action['parameters'];
}
$report = Piwik_API_API::getInstance()->getProcessedReport($idSite, $period, $date, $apiModule, $apiAction, $segment = false, $apiParameters, $idGoal = false, $language);
$websiteName = $report['website'];
$prettyDate = $report['prettyDate'];
$reportMetadata = $report['metadata'];
$isAggregateReport = !empty($reportMetadata['dimension']);
$report['displayTable'] = !$isAggregateReport || $aggregateReportsFormat == Piwik_PDFReports::AGGREGATE_REPORTS_FORMAT_TABLES || $aggregateReportsFormat == Piwik_PDFReports::AGGREGATE_REPORTS_FORMAT_TABLES_GRAPHS;
$report['displayGraph'] = (!$isAggregateReport || $aggregateReportsFormat == Piwik_PDFReports::AGGREGATE_REPORTS_FORMAT_GRAPHS || $aggregateReportsFormat == Piwik_PDFReports::AGGREGATE_REPORTS_FORMAT_TABLES_GRAPHS) && Piwik::isGdExtensionEnabled() && Piwik_PluginsManager::getInstance()->isPluginActivated('ImageGraph') && !empty($reportMetadata['imageGraphUrl']);
$processedReports[] = $report;
}
// Restore values
//.........这里部分代码省略.........
示例2: getSystemInformation
/**
* Get system information
*/
public static function getSystemInformation()
{
global $piwik_minimumPHPVersion;
$minimumMemoryLimit = Piwik_Config::getInstance()->General['minimum_memory_limit'];
$infos = array();
$infos['general_infos'] = array();
$infos['directories'] = Piwik::checkDirectoriesWritable();
$infos['can_auto_update'] = Piwik::canAutoUpdate();
if (Piwik_Common::isIIS()) {
Piwik::createWebConfigFiles();
} else {
Piwik::createHtAccessFiles();
}
Piwik::createWebRootFiles();
$infos['phpVersion_minimum'] = $piwik_minimumPHPVersion;
$infos['phpVersion'] = PHP_VERSION;
$infos['phpVersion_ok'] = version_compare($piwik_minimumPHPVersion, $infos['phpVersion']) === -1;
// critical errors
$extensions = @get_loaded_extensions();
$needed_extensions = array('zlib', 'SPL', 'iconv', 'Reflection');
$infos['needed_extensions'] = $needed_extensions;
$infos['missing_extensions'] = array();
foreach ($needed_extensions as $needed_extension) {
if (!in_array($needed_extension, $extensions)) {
$infos['missing_extensions'][] = $needed_extension;
}
}
$infos['pdo_ok'] = false;
if (in_array('PDO', $extensions)) {
$infos['pdo_ok'] = true;
}
$infos['adapters'] = Piwik_Db_Adapter::getAdapters();
$needed_functions = array('debug_backtrace', 'create_function', 'eval', 'gzcompress', 'gzuncompress', 'pack');
$infos['needed_functions'] = $needed_functions;
$infos['missing_functions'] = array();
foreach ($needed_functions as $needed_function) {
if (!self::functionExists($needed_function)) {
$infos['missing_functions'][] = $needed_function;
}
}
// warnings
$desired_extensions = array('json', 'libxml', 'dom', 'SimpleXML');
$infos['desired_extensions'] = $desired_extensions;
$infos['missing_desired_extensions'] = array();
foreach ($desired_extensions as $desired_extension) {
if (!in_array($desired_extension, $extensions)) {
$infos['missing_desired_extensions'][] = $desired_extension;
}
}
$desired_functions = array('set_time_limit', 'mail', 'parse_ini_file', 'glob');
$infos['desired_functions'] = $desired_functions;
$infos['missing_desired_functions'] = array();
foreach ($desired_functions as $desired_function) {
if (!self::functionExists($desired_function)) {
$infos['missing_desired_functions'][] = $desired_function;
}
}
$infos['openurl'] = Piwik_Http::getTransportMethod();
$infos['gd_ok'] = Piwik::isGdExtensionEnabled();
$infos['hasMbstring'] = false;
$infos['multibyte_ok'] = true;
if (function_exists('mb_internal_encoding')) {
$infos['hasMbstring'] = true;
if ((int) ini_get('mbstring.func_overload') != 0) {
$infos['multibyte_ok'] = false;
}
}
$serverSoftware = isset($_SERVER['SERVER_SOFTWARE']) ? $_SERVER['SERVER_SOFTWARE'] : '';
$infos['serverVersion'] = addslashes($serverSoftware);
$infos['serverOs'] = @php_uname();
$infos['serverTime'] = date('H:i:s');
$infos['registerGlobals_ok'] = ini_get('register_globals') == 0;
$infos['memoryMinimum'] = $minimumMemoryLimit;
$infos['memory_ok'] = true;
$infos['memoryCurrent'] = '';
$raised = Piwik::raiseMemoryLimitIfNecessary();
if (($memoryValue = Piwik::getMemoryLimitValue()) > 0) {
$infos['memoryCurrent'] = $memoryValue . 'M';
$infos['memory_ok'] = $memoryValue >= $minimumMemoryLimit;
}
$infos['isWindows'] = Piwik_Common::isWindows();
$integrityInfo = Piwik::getFileIntegrityInformation();
$infos['integrity'] = $integrityInfo[0];
$infos['integrityErrorMessages'] = array();
if (isset($integrityInfo[1])) {
if ($infos['integrity'] == false) {
$infos['integrityErrorMessages'][] = '<b>' . Piwik_Translate('General_FileIntegrityWarningExplanation') . '</b>';
}
$infos['integrityErrorMessages'] = array_merge($infos['integrityErrorMessages'], array_slice($integrityInfo, 1));
}
$infos['timezone'] = Piwik::isTimezoneSupportEnabled();
$infos['tracker_status'] = Piwik_Common::getRequestVar('trackerStatus', 0, 'int');
$infos['protocol'] = Piwik_ProxyHeaders::getProtocolInformation();
if (!Piwik::isHttps() && $infos['protocol'] !== null) {
$infos['general_infos']['secure_protocol'] = '1';
}
if (count($headers = Piwik_ProxyHeaders::getProxyClientHeaders()) > 0) {
//.........这里部分代码省略.........
示例3: get
public function get($idSite, $period, $date, $apiModule, $apiAction, $graphType = false, $outputType = Piwik_ImageGraph_API::GRAPH_OUTPUT_INLINE, $column = false, $showMetricTitle = true, $width = false, $height = false, $fontSize = Piwik_ImageGraph_API::DEFAULT_FONT_SIZE, $aliasedGraph = true, $colors = false)
{
Piwik::checkUserHasViewAccess($idSite);
// Health check - should we also test for GD2 only?
if (!Piwik::isGdExtensionEnabled()) {
throw new Exception('Error: To create graphs in Piwik, please enable GD php extension (with Freetype support) in php.ini, and restart your web server.');
}
$useUnicodeFont = array('am', 'ar', 'el', 'fa', 'fi', 'he', 'ja', 'ka', 'ko', 'te', 'th', 'zh-cn', 'zh-tw');
$languageLoaded = Piwik_Translate::getInstance()->getLanguageLoaded();
$font = self::getFontPath(self::DEFAULT_FONT);
if (in_array($languageLoaded, $useUnicodeFont)) {
$unicodeFontPath = self::getFontPath(self::UNICODE_FONT);
$font = file_exists($unicodeFontPath) ? $unicodeFontPath : $font;
}
// save original GET to reset after processing. Important for API-in-API-call
$savedGET = $_GET;
try {
//Fetch the metadata for given api-action
$metadata = Piwik_API_API::getInstance()->getMetadata($idSite, $apiModule, $apiAction, $apiParameters = array(), $languageLoaded, $period, $date);
if (!$metadata) {
throw new Exception('Invalid API Module and/or API Action');
}
$metadata = $metadata[0];
$reportHasDimension = !empty($metadata['dimension']);
$constantRowsCount = !empty($metadata['constantRowsCount']);
$isMultiplePeriod = Piwik_Archive::isMultiplePeriod($date, $period);
if ($reportHasDimension && $isMultiplePeriod || !$reportHasDimension && !$isMultiplePeriod) {
throw new Exception('The graph cannot be drawn for this combination of \'date\' and \'period\' parameters.');
}
if (empty($graphType)) {
if ($reportHasDimension) {
if ($constantRowsCount) {
$graphType = Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_VERTICAL_BAR;
} else {
$graphType = Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR;
}
} else {
$graphType = Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_LINE;
}
$reportUniqueId = $metadata['uniqueId'];
if (isset(self::$DEFAULT_GRAPH_TYPE_OVERRIDE[$reportUniqueId])) {
$graphType = self::$DEFAULT_GRAPH_TYPE_OVERRIDE[$reportUniqueId];
}
} else {
$availableGraphTypes = Piwik_ImageGraph_StaticGraph::getAvailableStaticGraphTypes();
if (!in_array($graphType, $availableGraphTypes)) {
throw new Exception(Piwik_TranslateException('General_ExceptionInvalidStaticGraphType', array($graphType, implode(', ', $availableGraphTypes))));
}
}
if (empty($width)) {
$width = self::$DEFAULT_PARAMETERS[$graphType][self::WIDTH_KEY];
}
if (empty($height)) {
$height = self::$DEFAULT_PARAMETERS[$graphType][self::HEIGHT_KEY];
}
if ($reportHasDimension) {
$abscissaColumn = 'label';
} else {
// if it's a dimension-less report, the abscissa column can only be the date-index
$abscissaColumn = 'date';
}
$reportColumns = array_merge(!empty($metadata['metrics']) ? $metadata['metrics'] : array(), !empty($metadata['processedMetrics']) ? $metadata['processedMetrics'] : array(), !empty($metadata['metricsGoal']) ? $metadata['metricsGoal'] : array(), !empty($metadata['processedMetricsGoal']) ? $metadata['processedMetricsGoal'] : array());
$ordinateColumn = $column;
if (empty($ordinateColumn)) {
$ordinateColumn = self::DEFAULT_ORDINATE_METRIC;
// if default ordinate metric not available for this report
if (empty($reportColumns[$ordinateColumn])) {
// take the first metric returned in the metadata
$ordinateColumn = key($metadata['metrics']);
}
}
// if we still don't have an ordinate column or the one provided by the API caller is invalid
if (empty($ordinateColumn) || empty($reportColumns[$ordinateColumn])) {
throw new Exception(Piwik_Translate('ImageGraph_ColumnOrdinateMissing', $ordinateColumn));
}
$ordinateLabel = $reportColumns[$ordinateColumn];
// sort and truncate filters
$defaultFilterTruncate = self::$DEFAULT_PARAMETERS[$graphType][self::TRUNCATE_KEY];
switch ($graphType) {
case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_3D_PIE:
case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_PIE:
$_GET['filter_sort_column'] = $ordinateColumn;
$this->setFilterTruncate($defaultFilterTruncate);
break;
case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_VERTICAL_BAR:
case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_LINE:
if ($reportHasDimension && !$constantRowsCount) {
$this->setFilterTruncate($defaultFilterTruncate);
}
break;
}
$processedReport = Piwik_API_API::getInstance()->getProcessedReport($idSite, $period, $date, $apiModule, $apiAction, $segment = false, $apiParameters = false, $idGoal = false, $languageLoaded);
// prepare abscissa and ordinate series
$abscissaSerie = array();
$ordinateSerie = array();
$ordinateLogos = array();
$reportData = $processedReport['reportData'];
$hasData = false;
$hasNonZeroValue = false;
if ($reportHasDimension) {
//.........这里部分代码省略.........
示例4: processReports
/**
* @param Piwik_Event_Notification $notification notification object
*/
function processReports($notification)
{
if (self::manageEvent($notification)) {
$processedReports =& $notification->getNotificationObject();
$notificationInfo = $notification->getNotificationInfo();
$report = $notificationInfo[Piwik_PDFReports_API::REPORT_KEY];
$displayFormat = $report['parameters'][self::DISPLAY_FORMAT_PARAMETER];
foreach ($processedReports as &$processedReport) {
$metadata = $processedReport['metadata'];
$isAggregateReport = !empty($metadata['dimension']);
$processedReport['displayTable'] = $displayFormat != self::DISPLAY_FORMAT_GRAPHS_ONLY;
$processedReport['displayGraph'] = ($isAggregateReport ? $displayFormat == self::DISPLAY_FORMAT_GRAPHS_ONLY || $displayFormat == self::DISPLAY_FORMAT_TABLES_AND_GRAPHS : $displayFormat != self::DISPLAY_FORMAT_TABLES_ONLY) && Piwik::isGdExtensionEnabled() && Piwik_PluginsManager::getInstance()->isPluginActivated('ImageGraph') && !empty($metadata['imageGraphUrl']);
// remove evolution metrics from MultiSites.getAll
if ($metadata['module'] == 'MultiSites') {
$columns = $processedReport['columns'];
foreach (Piwik_MultiSites_API::getApiMetrics($enhanced = true) as $metricSettings) {
unset($columns[$metricSettings[Piwik_MultiSites_API::METRIC_EVOLUTION_COL_NAME_KEY]]);
}
$processedReport['metadata'] = $metadata;
$processedReport['columns'] = $columns;
}
}
}
}
示例5: get
public function get($idSite, $period, $date, $apiModule, $apiAction, $graphType = false, $outputType = Piwik_ImageGraph_API::GRAPH_OUTPUT_INLINE, $columns = false, $labels = false, $showLegend = true, $width = false, $height = false, $fontSize = Piwik_ImageGraph_API::DEFAULT_FONT_SIZE, $legendFontSize = false, $aliasedGraph = true, $idGoal = false, $colors = false, $idSubtable = false, $legendAppendMetric = true)
{
Piwik::checkUserHasViewAccess($idSite);
// Health check - should we also test for GD2 only?
if (!Piwik::isGdExtensionEnabled()) {
throw new Exception('Error: To create graphs in Piwik, please enable GD php extension (with Freetype support) in php.ini, and restart your web server.');
}
$useUnicodeFont = array('am', 'ar', 'el', 'fa', 'fi', 'he', 'ja', 'ka', 'ko', 'te', 'th', 'zh-cn', 'zh-tw');
$languageLoaded = Piwik_Translate::getInstance()->getLanguageLoaded();
$font = self::getFontPath(self::DEFAULT_FONT);
if (in_array($languageLoaded, $useUnicodeFont)) {
$unicodeFontPath = self::getFontPath(self::UNICODE_FONT);
$font = file_exists($unicodeFontPath) ? $unicodeFontPath : $font;
}
// save original GET to reset after processing. Important for API-in-API-call
$savedGET = $_GET;
try {
$apiParameters = array();
if (!empty($idGoal)) {
$apiParameters = array('idGoal' => $idGoal);
}
// Fetch the metadata for given api-action
$metadata = Piwik_API_API::getInstance()->getMetadata($idSite, $apiModule, $apiAction, $apiParameters, $languageLoaded, $period, $date, $hideMetricsDoc = false, $showSubtableReports = true);
if (!$metadata) {
throw new Exception('Invalid API Module and/or API Action');
}
$metadata = $metadata[0];
$reportHasDimension = !empty($metadata['dimension']);
$constantRowsCount = !empty($metadata['constantRowsCount']);
$isMultiplePeriod = Piwik_Archive::isMultiplePeriod($date, $period);
if (!$reportHasDimension && !$isMultiplePeriod) {
throw new Exception('The graph cannot be drawn for this combination of \'date\' and \'period\' parameters.');
}
if (empty($legendFontSize)) {
$legendFontSize = $fontSize + self::DEFAULT_LEGEND_FONT_SIZE_OFFSET;
}
if (empty($graphType)) {
if ($isMultiplePeriod) {
$graphType = Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_LINE;
} else {
if ($constantRowsCount) {
$graphType = Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_VERTICAL_BAR;
} else {
$graphType = Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_HORIZONTAL_BAR;
}
}
$reportUniqueId = $metadata['uniqueId'];
if (isset(self::$DEFAULT_GRAPH_TYPE_OVERRIDE[$reportUniqueId][$isMultiplePeriod])) {
$graphType = self::$DEFAULT_GRAPH_TYPE_OVERRIDE[$reportUniqueId][$isMultiplePeriod];
}
} else {
$availableGraphTypes = Piwik_ImageGraph_StaticGraph::getAvailableStaticGraphTypes();
if (!in_array($graphType, $availableGraphTypes)) {
throw new Exception(Piwik_TranslateException('General_ExceptionInvalidStaticGraphType', array($graphType, implode(', ', $availableGraphTypes))));
}
}
$width = (int) $width;
$height = (int) $height;
if (empty($width)) {
$width = self::$DEFAULT_PARAMETERS[$graphType][self::WIDTH_KEY];
}
if (empty($height)) {
$height = self::$DEFAULT_PARAMETERS[$graphType][self::HEIGHT_KEY];
}
// Cap width and height to a safe amount
$width = min($width, self::MAX_WIDTH);
$height = min($height, self::MAX_HEIGHT);
$reportColumns = array_merge(!empty($metadata['metrics']) ? $metadata['metrics'] : array(), !empty($metadata['processedMetrics']) ? $metadata['processedMetrics'] : array(), !empty($metadata['metricsGoal']) ? $metadata['metricsGoal'] : array(), !empty($metadata['processedMetricsGoal']) ? $metadata['processedMetricsGoal'] : array());
$ordinateColumns = array();
if (empty($columns)) {
$ordinateColumns[] = empty($reportColumns[self::DEFAULT_ORDINATE_METRIC]) ? key($metadata['metrics']) : self::DEFAULT_ORDINATE_METRIC;
} else {
$ordinateColumns = explode(',', $columns);
foreach ($ordinateColumns as $column) {
if (empty($reportColumns[$column])) {
throw new Exception(Piwik_Translate('ImageGraph_ColumnOrdinateMissing', array($column, implode(',', array_keys($reportColumns)))));
}
}
}
$ordinateLabels = array();
foreach ($ordinateColumns as $column) {
$ordinateLabels[$column] = $reportColumns[$column];
}
// sort and truncate filters
$defaultFilterTruncate = self::$DEFAULT_PARAMETERS[$graphType][self::TRUNCATE_KEY];
switch ($graphType) {
case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_3D_PIE:
case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_PIE:
if (count($ordinateColumns) > 1) {
// pChart doesn't support multiple series on pie charts
throw new Exception("Pie charts do not currently support multiple series");
}
$_GET['filter_sort_column'] = reset($ordinateColumns);
$this->setFilterTruncate($defaultFilterTruncate);
break;
case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_VERTICAL_BAR:
case Piwik_ImageGraph_StaticGraph::GRAPH_TYPE_BASIC_LINE:
if (!$isMultiplePeriod && !$constantRowsCount) {
$this->setFilterTruncate($defaultFilterTruncate);
}
//.........这里部分代码省略.........