本文整理汇总了PHP中Piwik::getArrayFromApiParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik::getArrayFromApiParameter方法的具体用法?PHP Piwik::getArrayFromApiParameter怎么用?PHP Piwik::getArrayFromApiParameter使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik
的用法示例。
在下文中一共展示了Piwik::getArrayFromApiParameter方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get
/**
* Returns the list of metrics (pages, downloads, outlinks)
*
* @param int $idSite
* @param string $period
* @param string $date
* @param string $segment
*/
public function get($idSite, $period, $date, $segment = false, $columns = false)
{
Piwik::checkUserHasViewAccess($idSite);
$archive = Piwik_Archive::build($idSite, $period, $date, $segment);
$metrics = array('Actions_nb_pageviews' => 'nb_pageviews', 'Actions_nb_uniq_pageviews' => 'nb_uniq_pageviews', 'Actions_nb_downloads' => 'nb_downloads', 'Actions_nb_uniq_downloads' => 'nb_uniq_downloads', 'Actions_nb_outlinks' => 'nb_outlinks', 'Actions_nb_uniq_outlinks' => 'nb_uniq_outlinks');
// get requested columns
$columns = Piwik::getArrayFromApiParameter($columns);
if (!empty($columns)) {
// get the columns that are available and requested
$columns = array_intersect($columns, array_values($metrics));
$columns = array_values($columns);
// make sure indexes are right
$nameReplace = array();
foreach ($columns as $i => $column) {
$fullColumn = array_search($column, $metrics);
$columns[$i] = $fullColumn;
$nameReplace[$fullColumn] = $column;
}
} else {
// get all columns
$columns = array_keys($metrics);
$nameReplace =& $metrics;
}
$table = $archive->getDataTableFromNumeric($columns);
// replace labels (remove Actions_)
$table->filter('ReplaceColumnNames', array($nameReplace));
return $table;
}
示例2: getEvolutionGraph
public function getEvolutionGraph($fetch = false, $columns = false)
{
if (empty($columns)) {
$columns = Piwik_Common::getRequestVar('columns');
$columns = Piwik::getArrayFromApiParameter($columns);
}
$documentation = Piwik_Translate('VisitsSummary_VisitsSummaryDocumentation') . '<br />' . Piwik_Translate('General_BrokenDownReportDocumentation') . '<br /><br />' . '<b>' . Piwik_Translate('General_ColumnNbVisits') . ':</b> ' . Piwik_Translate('General_ColumnNbVisitsDocumentation') . '<br />' . '<b>' . Piwik_Translate('General_ColumnNbUniqVisitors') . ':</b> ' . Piwik_Translate('General_ColumnNbUniqVisitorsDocumentation') . '<br />' . '<b>' . Piwik_Translate('General_ColumnNbActions') . ':</b> ' . Piwik_Translate('General_ColumnNbActionsDocumentation') . '<br />' . '<b>' . Piwik_Translate('General_ColumnActionsPerVisit') . ':</b> ' . Piwik_Translate('General_ColumnActionsPerVisitDocumentation');
$selectableColumns = array('nb_visits', 'nb_uniq_visitors', 'avg_time_on_site', 'bounce_rate', 'nb_actions_per_visit', 'max_actions', 'nb_visits_converted', 'nb_pageviews', 'nb_uniq_pageviews', 'nb_downloads', 'nb_uniq_downloads', 'nb_outlinks', 'nb_uniq_outlinks');
$view = $this->getLastUnitGraphAcrossPlugins($this->pluginName, __FUNCTION__, $columns, $selectableColumns, $documentation);
return $this->renderView($view, $fetch);
}
示例3: getEvolutionGraph
public function getEvolutionGraph($fetch = false, $columns = false)
{
if (empty($columns)) {
$columns = Piwik_Common::getRequestVar('columns');
$columns = Piwik::getArrayFromApiParameter($columns);
}
$documentation = Piwik_Translate('VisitFrequency_ReturningVisitsDocumentation') . '<br />' . Piwik_Translate('General_BrokenDownReportDocumentation') . '<br />' . Piwik_Translate('VisitFrequency_ReturningVisitDocumentation');
// Note: if you edit this array, maybe edit the code below as well
$selectableColumns = array('nb_visits_returning', 'nb_actions_returning', 'nb_actions_per_visit_returning', 'bounce_rate_returning', 'avg_time_on_site_returning', 'nb_visits', 'nb_actions', 'nb_actions_per_visit', 'bounce_rate', 'avg_time_on_site');
$period = Piwik_Common::getRequestVar('period', false);
if ($period == 'day') {
// add number of unique (returning) visitors for period=day
$selectableColumns = array_merge(array($selectableColumns[0]), array('nb_uniq_visitors_returning'), array_slice($selectableColumns, 1, -4), array('nb_uniq_visitors'), array_slice($selectableColumns, -4));
}
$view = $this->getLastUnitGraphAcrossPlugins($this->pluginName, __FUNCTION__, $columns, $selectableColumns, $documentation);
return $this->renderView($view, $fetch);
}
示例4: get
public function get($idSite, $period, $date, $segment = false, $columns = false)
{
Piwik::checkUserHasViewAccess($idSite);
$archive = Piwik_Archive::build($idSite, $period, $date, $segment);
// array values are comma separated
$columns = Piwik::getArrayFromApiParameter($columns);
$countColumnsRequested = count($columns);
$bounceRateRequested = $actionsPerVisitRequested = $averageVisitDurationRequested = false;
if (!empty($columns)) {
if (($bounceRateRequested = array_search('bounce_rate', $columns)) !== false) {
$columns = array('nb_visits', 'bounce_count');
} elseif (($actionsPerVisitRequested = array_search('nb_actions_per_visit', $columns)) !== false) {
$columns = array('nb_actions', 'nb_visits');
} elseif (($averageVisitDurationRequested = array_search('avg_time_on_site', $columns)) !== false) {
$columns = array('sum_visit_length', 'nb_visits');
}
} else {
$bounceRateRequested = $actionsPerVisitRequested = $averageVisitDurationRequested = true;
$columns = array('nb_visits', 'nb_uniq_visitors', 'nb_actions', 'nb_visits_converted', 'bounce_count', 'sum_visit_length', 'max_actions');
if (!Piwik::isUniqueVisitorsEnabled($period)) {
unset($columns[array_search('nb_uniq_visitors', $columns)]);
}
// Force reindex from 0 to N otherwise the SQL bind will fail
$columns = array_values($columns);
}
$dataTable = $archive->getDataTableFromNumeric($columns);
// Process ratio metrics from base metrics, when requested
if ($bounceRateRequested !== false) {
$dataTable->filter('ColumnCallbackAddColumnPercentage', array('bounce_rate', 'bounce_count', 'nb_visits', 0));
}
if ($actionsPerVisitRequested !== false) {
$dataTable->filter('ColumnCallbackAddColumnQuotient', array('nb_actions_per_visit', 'nb_actions', 'nb_visits', 1));
}
if ($averageVisitDurationRequested !== false) {
$dataTable->filter('ColumnCallbackAddColumnQuotient', array('avg_time_on_site', 'sum_visit_length', 'nb_visits', 0));
}
// If only a computed metrics was requested, we delete other metrics
// that we selected only to process this one metric
if ($countColumnsRequested == 1 && ($bounceRateRequested || $actionsPerVisitRequested || $averageVisitDurationRequested)) {
$dataTable->deleteColumns($columns);
}
return $dataTable;
}
示例5: getEvolutionGraph
public function getEvolutionGraph($fetch = false, $typeReferer = false, $columns = false)
{
$view = $this->getLastUnitGraph($this->pluginName, __FUNCTION__, 'Referers.getRefererType');
// configure displayed columns
if (empty($columns)) {
$columns = Piwik_Common::getRequestVar('columns');
$columns = Piwik::getArrayFromApiParameter($columns);
}
$columns = !is_array($columns) ? array($columns) : $columns;
$view->setColumnsToDisplay($columns);
// configure selectable columns
if (Piwik_Common::getRequestVar('period', false) == 'day') {
$selectable = array('nb_visits', 'nb_uniq_visitors', 'nb_actions');
} else {
$selectable = array('nb_visits', 'nb_actions');
}
$view->setSelectableColumns($selectable);
// configure displayed rows
$visibleRows = Piwik_Common::getRequestVar('rows', false);
if ($visibleRows !== false) {
// this happens when the row picker has been used
$visibleRows = Piwik::getArrayFromApiParameter($visibleRows);
} else {
// use $typeReferer as default
if ($typeReferer === false) {
$typeReferer = Piwik_Common::getRequestVar('typeReferer', false);
}
$label = Piwik_getRefererTypeLabel($typeReferer);
$label = Piwik_Translate($label);
$visibleRows = array($label);
$view->setParametersToModify(array('rows' => $label));
}
$view->addRowPicker($visibleRows);
$view->setReportDocumentation(Piwik_Translate('Referers_EvolutionDocumentation') . '<br />' . Piwik_Translate('General_BrokenDownReportDocumentation') . '<br />' . Piwik_Translate('Referers_EvolutionDocumentationMoreInfo', '"' . Piwik_Translate('Referers_DetailsByRefererType') . '"'));
return $this->renderView($view, $fetch);
}
示例6: setMetricsVariablesView
/**
* Set metrics variables (displayed metrics, available metrics) used by template
* Handles the server-side of the metrics picker
*
* @param Piwik_View|Piwik_ViewDataTable $view
* @param string $defaultMetricDay name of the default metric for period=day
* @param string $defaultMetric name of the default metric for other periods
* @param array $metricsForDay metrics that are only available for period=day
* @param array $metricsForAllPeriods metrics that are available for all periods
* @param bool $labelDisplayed add 'label' to columns to display?
* @return void
*/
protected function setMetricsVariablesView(Piwik_ViewDataTable $view, $defaultMetricDay = 'nb_uniq_visitors', $defaultMetric = 'nb_visits', $metricsForDay = array('nb_uniq_visitors'), $metricsForAllPeriods = array('nb_visits', 'nb_actions'), $labelDisplayed = true)
{
// columns is set in the request if metrics picker has been used
$columns = Piwik_Common::getRequestVar('columns', false);
if ($columns !== false) {
$columns = Piwik::getArrayFromApiParameter($columns);
$firstColumn = $columns[0];
} else {
// default columns
$firstColumn = isset($view->period) && $view->period == 'day' ? $defaultMetricDay : $defaultMetric;
$columns = array($firstColumn);
}
// displayed columns
if ($labelDisplayed && !$view instanceof Piwik_ViewDataTable_GenerateGraphData) {
array_unshift($columns, 'label');
}
$view->setColumnsToDisplay($columns);
// Continue only for graphs
if (!$view instanceof Piwik_ViewDataTable_GenerateGraphData) {
return;
}
// do not sort if sorted column was initially "label" or eg. it would make "Visits by Server time" not pretty
if ($view->getSortedColumn() != 'label') {
$view->setSortedColumn($firstColumn);
}
// selectable columns
if (isset($view->period) && $view->period == 'day') {
$selectableColumns = array_merge($metricsForDay, $metricsForAllPeriods);
} else {
$selectableColumns = $metricsForAllPeriods;
}
$view->setSelectableColumns($selectableColumns);
}
示例7: get
/**
* Returns Goals data
*
* @param int $idSite
* @param string $period
* @param string $date
* @param bool $segment
* @param bool|int $idGoal
* @param array $columns Array of metrics to fetch: nb_conversions, conversion_rate, revenue
* @return Piwik_DataTable
*/
public function get($idSite, $period, $date, $segment = false, $idGoal = false, $columns = array())
{
Piwik::checkUserHasViewAccess($idSite);
$archive = Piwik_Archive::build($idSite, $period, $date, $segment);
$columns = Piwik::getArrayFromApiParameter($columns);
// Mapping string idGoal to internal ID
$idGoal = self::convertSpecialGoalIds($idGoal);
if (empty($columns)) {
$columns = Piwik_Goals::getGoalColumns($idGoal);
if ($idGoal == Piwik_Archive::LABEL_ECOMMERCE_ORDER) {
$columns[] = 'avg_order_revenue';
}
}
if (in_array('avg_order_revenue', $columns) && $idGoal == Piwik_Archive::LABEL_ECOMMERCE_ORDER) {
$columns[] = 'nb_conversions';
$columns[] = 'revenue';
$columns = array_values(array_unique($columns));
}
$columnsToSelect = array();
foreach ($columns as &$columnName) {
$columnsToSelect[] = Piwik_Goals::getRecordName($columnName, $idGoal);
}
$dataTable = $archive->getDataTableFromNumeric($columnsToSelect);
// Rewrite column names as we expect them
foreach ($columnsToSelect as $id => $oldName) {
$dataTable->renameColumn($oldName, $columns[$id]);
}
if ($idGoal == Piwik_Archive::LABEL_ECOMMERCE_ORDER) {
if ($dataTable instanceof Piwik_DataTable_Array) {
foreach ($dataTable->getArray() as $row) {
$this->enrichTable($row);
}
} else {
$this->enrichTable($dataTable);
}
}
return $dataTable;
}
示例8: getSitesIdFromTimezones
/**
* Returns all websites with a timezone matching one the specified timezones
*
* @param array $timezones
* @ignore
*/
public function getSitesIdFromTimezones($timezones)
{
Piwik::checkUserIsSuperUser();
$timezones = Piwik::getArrayFromApiParameter($timezones);
$timezones = array_unique($timezones);
$ids = Zend_Registry::get('db')->fetchAll('SELECT idsite
FROM ' . Piwik_Common::prefixTable('site') . '
WHERE timezone IN (' . Piwik_Common::getSqlStringFieldsArray($timezones) . ')
ORDER BY idsite ASC', $timezones);
$return = array();
foreach ($ids as $id) {
$return[] = $id['idsite'];
}
return $return;
}