setColumn() public method

Set the value $value to the column called $name.
public setColumn ( string $name, mixed $value )
$name string name of the column to set.
$value mixed value of the column to set.
Beispiel #1
0
 /**
  * @param Row $row
  * @param DataTable $dataTable
  * @param string $labelPrefix
  * @param bool $parentLogo
  */
 private function flattenRow(Row $row, DataTable $dataTable, $labelPrefix = '', $parentLogo = false)
 {
     $label = $row->getColumn('label');
     if ($label !== false) {
         $label = trim($label);
         if (substr($label, 0, 1) == '/' && $this->recursiveLabelSeparator == '/') {
             $label = substr($label, 1);
         }
         $label = $labelPrefix . $label;
         $row->setColumn('label', $label);
     }
     $logo = $row->getMetadata('logo');
     if ($logo === false && $parentLogo !== false) {
         $logo = $parentLogo;
         $row->setMetadata('logo', $logo);
     }
     $subTable = $this->loadSubtable($dataTable, $row);
     $row->removeSubtable();
     if ($subTable === null) {
         if ($this->includeAggregateRows) {
             $row->setMetadata('is_aggregate', 0);
         }
         $dataTable->addRow($row);
     } else {
         if ($this->includeAggregateRows) {
             $row->setMetadata('is_aggregate', 1);
             $dataTable->addRow($row);
         }
         $prefix = $label . $this->recursiveLabelSeparator;
         foreach ($subTable->getRows() as $row) {
             $this->flattenRow($row, $dataTable, $prefix, $logo);
         }
     }
 }
Beispiel #2
0
 protected function enrichWithUniqueVisitorsMetric(Row $row)
 {
     // skip unique visitors metrics calculation if calculating for multiple sites is disabled
     if (!$this->getParams()->isSingleSite() && $this->skipUniqueVisitorsCalculationForMultipleSites) {
         return;
     }
     if ($row->getColumn('nb_uniq_visitors') === false && $row->getColumn('nb_users') === false) {
         return;
     }
     if (!SettingsPiwik::isUniqueVisitorsEnabled($this->getParams()->getPeriod()->getLabel())) {
         $row->deleteColumn('nb_uniq_visitors');
         $row->deleteColumn('nb_users');
         return;
     }
     $metrics = array(Metrics::INDEX_NB_USERS);
     if ($this->getParams()->isSingleSite()) {
         $uniqueVisitorsMetric = Metrics::INDEX_NB_UNIQ_VISITORS;
     } else {
         if (!SettingsPiwik::isSameFingerprintAcrossWebsites()) {
             throw new Exception("Processing unique visitors across websites is enabled for this instance,\n                            but to process this metric you must first set enable_fingerprinting_across_websites=1\n                            in the config file, under the [Tracker] section.");
         }
         $uniqueVisitorsMetric = Metrics::INDEX_NB_UNIQ_FINGERPRINTS;
     }
     $metrics[] = $uniqueVisitorsMetric;
     $uniques = $this->computeNbUniques($metrics);
     // see edge case as described in https://github.com/piwik/piwik/issues/9357 where uniq_visitors might be higher
     // than visits because we archive / process it after nb_visits. Between archiving nb_visits and nb_uniq_visitors
     // there could have been a new visit leading to a higher nb_unique_visitors than nb_visits which is not possible
     // by definition. In this case we simply use the visits metric instead of unique visitors metric.
     $visits = $row->getColumn('nb_visits');
     if ($visits !== false && $uniques[$uniqueVisitorsMetric] !== false) {
         $uniques[$uniqueVisitorsMetric] = min($uniques[$uniqueVisitorsMetric], $visits);
     }
     $row->setColumn('nb_uniq_visitors', $uniques[$uniqueVisitorsMetric]);
     $row->setColumn('nb_users', $uniques[Metrics::INDEX_NB_USERS]);
 }
 protected function enrichWithUniqueVisitorsMetric(Row $row)
 {
     if (!$this->getParams()->isSingleSite()) {
         // we only compute unique visitors for a single site
         return;
     }
     if ($row->getColumn('nb_uniq_visitors') !== false) {
         if (SettingsPiwik::isUniqueVisitorsEnabled($this->getParams()->getPeriod()->getLabel())) {
             $uniqueVisitors = (double) $this->computeNbUniqVisitors();
             $row->setColumn('nb_uniq_visitors', $uniqueVisitors);
         } else {
             $row->deleteColumn('nb_uniq_visitors');
         }
     }
 }
 /**
  * Replaces the given column within given row with the given value
  *
  * @param Row $row
  * @param string $columnToFilter
  * @param mixed $newValue
  */
 protected function setElementToReplace($row, $columnToFilter, $newValue)
 {
     $row->setColumn($columnToFilter, $newValue);
 }
 protected function enrichWithUniqueVisitorsMetric(Row $row)
 {
     // skip unique visitors metrics calculation if calculating for multiple sites is disabled
     if (!$this->getParams()->isSingleSite() && $this->skipUniqueVisitorsCalculationForMultipleSites) {
         return;
     }
     if ($row->getColumn('nb_uniq_visitors') === false && $row->getColumn('nb_users') === false) {
         return;
     }
     if (!SettingsPiwik::isUniqueVisitorsEnabled($this->getParams()->getPeriod()->getLabel())) {
         $row->deleteColumn('nb_uniq_visitors');
         $row->deleteColumn('nb_users');
         return;
     }
     $metrics = array(Metrics::INDEX_NB_USERS);
     if ($this->getParams()->isSingleSite()) {
         $uniqueVisitorsMetric = Metrics::INDEX_NB_UNIQ_VISITORS;
     } else {
         if (!SettingsPiwik::isSameFingerprintAcrossWebsites()) {
             throw new Exception("Processing unique visitors across websites is enabled for this instance,\n                            but to process this metric you must first set enable_fingerprinting_across_websites=1\n                            in the config file, under the [Tracker] section.");
         }
         $uniqueVisitorsMetric = Metrics::INDEX_NB_UNIQ_FINGERPRINTS;
     }
     $metrics[] = $uniqueVisitorsMetric;
     $uniques = $this->computeNbUniques($metrics);
     $row->setColumn('nb_uniq_visitors', $uniques[$uniqueVisitorsMetric]);
     $row->setColumn('nb_users', $uniques[Metrics::INDEX_NB_USERS]);
 }
Beispiel #6
0
 private function assertColumnSavesValue($expectedValue, $columnName, $valueToSet)
 {
     $this->row->setColumn($columnName, $valueToSet);
     $this->assertSame($expectedValue, $this->row->getColumn($columnName));
 }
 protected function enrichWithUniqueVisitorsMetric(Row $row)
 {
     // skip unique visitors metrics calculation if calculating for multiple sites is disabled
     if (!$this->getParams()->isSingleSite() && $this->skipUniqueVisitorsCalculationForMultipleSites) {
         return;
     }
     if ($row->getColumn('nb_uniq_visitors') !== false || $row->getColumn('nb_users') !== false) {
         if (SettingsPiwik::isUniqueVisitorsEnabled($this->getParams()->getPeriod()->getLabel())) {
             $metrics = array(Metrics::INDEX_NB_UNIQ_VISITORS, Metrics::INDEX_NB_USERS);
             $uniques = $this->computeNbUniques($metrics);
             $row->setColumn('nb_uniq_visitors', $uniques[Metrics::INDEX_NB_UNIQ_VISITORS]);
             $row->setColumn('nb_users', $uniques[Metrics::INDEX_NB_USERS]);
         } else {
             $row->deleteColumn('nb_uniq_visitors');
             $row->deleteColumn('nb_users');
         }
     }
 }
Beispiel #8
0
 /**
  * @param Row $row
  * @param DataTable $dataTable
  * @param string $labelPrefix
  * @param bool $parentLogo
  */
 private function flattenRow(Row $row, $rowId, DataTable $dataTable, $labelPrefix = '', $parentLogo = false)
 {
     $label = $row->getColumn('label');
     if ($label !== false) {
         $label = trim($label);
         if ($this->recursiveLabelSeparator == '/') {
             if (substr($label, 0, 1) == '/') {
                 $label = substr($label, 1);
             } elseif ($rowId === DataTable::ID_SUMMARY_ROW && $labelPrefix && $label != DataTable::LABEL_SUMMARY_ROW) {
                 $label = ' - ' . $label;
             }
         }
         $label = $labelPrefix . $label;
         $row->setColumn('label', $label);
     }
     $logo = $row->getMetadata('logo');
     if ($logo === false && $parentLogo !== false) {
         $logo = $parentLogo;
         $row->setMetadata('logo', $logo);
     }
     /** @var DataTable $subTable */
     $subTable = $row->getSubtable();
     if ($subTable) {
         $subTable->applyQueuedFilters();
         $row->deleteMetadata('idsubdatatable_in_db');
     } else {
         $subTable = $this->loadSubtable($dataTable, $row);
     }
     $row->removeSubtable();
     if ($subTable === null) {
         if ($this->includeAggregateRows) {
             $row->setMetadata('is_aggregate', 0);
         }
         $dataTable->addRow($row);
     } else {
         if ($this->includeAggregateRows) {
             $row->setMetadata('is_aggregate', 1);
             $dataTable->addRow($row);
         }
         $prefix = $label . $this->recursiveLabelSeparator;
         $this->flattenDataTableInto($subTable, $dataTable, $prefix, $logo);
     }
 }