本文整理汇总了PHP中Piwik_ViewDataTable::setSelectableColumns方法的典型用法代码示例。如果您正苦于以下问题:PHP Piwik_ViewDataTable::setSelectableColumns方法的具体用法?PHP Piwik_ViewDataTable::setSelectableColumns怎么用?PHP Piwik_ViewDataTable::setSelectableColumns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik_ViewDataTable
的用法示例。
在下文中一共展示了Piwik_ViewDataTable::setSelectableColumns方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: 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);
}