本文整理汇总了PHP中Piwik\DataTable::getRowFromId方法的典型用法代码示例。如果您正苦于以下问题:PHP DataTable::getRowFromId方法的具体用法?PHP DataTable::getRowFromId怎么用?PHP DataTable::getRowFromId使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Piwik\DataTable
的用法示例。
在下文中一共展示了DataTable::getRowFromId方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getClusterSummary
/**
* Another example method that returns a data table.
* @param int $idSite
* @param string $period
* @param string $date
* @param bool|string $segment
* @return DataTable
*/
public function getClusterSummary($idSite, $period, $date, $cluster_id, $cluster_type = 'bundle')
{
$table = new DataTable();
$params = array('idSite' => $idSite, 'period' => $period, 'date' => $date, 'segment' => 'customVariablePageName2==' . $cluster_type . 's;customVariablePageValue2=@' . $cluster_id);
$data = \Piwik\API\Request::processRequest('API.get', $params);
$tarray = $this->getTypes($params);
$data->getRowFromId(0)->addColumns($tarray);
$table->addRow($data->getRowFromId(0));
// Get country ISO2 code
$hr_url = 'https://www.humanitarianresponse.info/api/v1.0/' . $cluster_type . 's/' . $cluster_id;
if ($space_raw = @file_get_contents($hr_url)) {
$space = json_decode($space_raw);
$table->getRowFromId(0)->addColumn('label', $space->data[0]->label);
if (isset($space->data[0]->operation[0]->country)) {
$iso2 = $space->data[0]->operation[0]->country->pcode;
$cparams = $params;
$cparams['segment'] = $params['segment'] . ';countryCode==' . $iso2;
$cdata = \Piwik\API\Request::processRequest('API.get', $cparams);
$cdata->getRowFromId(0)->addColumn('label', $space->data[0]->label . ' - in country');
$ctarray = $this->getTypes($cparams);
$cdata->getRowFromId(0)->addColumns($ctarray);
$table->addRow($cdata->getRowFromId(0));
}
}
return $table;
}
示例2: sumTable
/**
* Sums a tables row with this one.
*
* @param DataTable $table
*/
private function sumTable($table)
{
$metadata = $table->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME);
$enableCopyMetadata = false;
foreach ($table->getRowsWithoutSummaryRow() as $row) {
$this->sumRow($row, $enableCopyMetadata, $metadata);
}
$summaryRow = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
if ($summaryRow) {
$this->sumRow($summaryRow, $enableCopyMetadata, $metadata);
}
}
示例3: filter
/**
* @param DataTable $table
*/
public function filter($table)
{
$idSubtable = $this->idSubtable ?: $table->getId();
$subTableRow = $this->firstLevelSearchEnginesTable->getRowFromIdSubDataTable($idSubtable);
if (!empty($subTableRow)) {
$searchEngineUrl = $subTableRow->getMetadata('url');
$table->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', 'Piwik\\Plugins\\Referrers\\getSearchEngineUrlFromKeywordAndUrl', array($searchEngineUrl)));
$table->queueFilter(function (DataTable $table) {
$row = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
if ($row) {
$row->deleteMetadata('url');
}
});
}
$table->queueFilter('Piwik\\Plugins\\Referrers\\DataTable\\Filter\\KeywordNotDefined');
}
示例4: filter
/**
* See {@link Limit}.
*
* @param DataTable $table
*/
public function filter($table)
{
$table->setMetadata(DataTable::TOTAL_ROWS_BEFORE_LIMIT_METADATA_NAME, $table->getRowsCount());
if ($this->keepSummaryRow) {
$summaryRow = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
}
// we delete from 0 to offset
if ($this->offset > 0) {
$table->deleteRowsOffset(0, $this->offset);
}
// at this point the array has offset less elements. We delete from limit to the end
if ($this->limit >= 0) {
$table->deleteRowsOffset($this->limit);
}
if ($this->keepSummaryRow && !empty($summaryRow)) {
$table->addSummaryRow($summaryRow);
}
}
示例5: filter
/**
* @param DataTable $table
*/
public function filter($table)
{
$idSubtable = $this->idSubtable ?: $table->getId();
$table->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', 'Piwik\\Plugins\\Referrers\\getSearchEngineUrlFromName'));
$table->queueFilter('MetadataCallbackAddMetadata', array('url', 'logo', 'Piwik\\Plugins\\Referrers\\getSearchEngineLogoFromUrl'));
// get the keyword and create the URL to the search result page
$rootRow = $this->firstLevelKeywordTable->getRowFromIdSubDataTable($idSubtable);
if ($rootRow) {
$keyword = $rootRow->getColumn('label');
$table->queueFilter('MetadataCallbackReplace', array('url', 'Piwik\\Plugins\\Referrers\\getSearchEngineUrlFromUrlAndKeyword', array($keyword)));
$table->queueFilter(function (DataTable $table) {
$row = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
if ($row) {
$row->deleteMetadata('url');
}
});
}
}
示例6: filter
/**
* See {@link ReplaceSummaryRowLabel}.
*
* @param DataTable $table
*/
public function filter($table)
{
$row = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
if ($row) {
$row->setColumn('label', $this->newLabel);
} else {
$row = $table->getRowFromLabel(DataTable::LABEL_SUMMARY_ROW);
if ($row) {
$row->setColumn('label', $this->newLabel);
}
}
// recurse
foreach ($table->getRowsWithoutSummaryRow() as $row) {
$subTable = $row->getSubtable();
if ($subTable) {
$this->filter($subTable);
}
}
}
示例7: filter
/**
* @param DataTable $table
*/
public function filter($table)
{
$idSubtable = $this->idSubtable ?: $table->getId();
$table->queueFilter('ColumnCallbackAddMetadata', array('label', 'url', function ($url) {
return SearchEngine::getInstance()->getUrlFromName($url);
}));
$table->queueFilter('MetadataCallbackAddMetadata', array('url', 'logo', function ($url) {
return SearchEngine::getInstance()->getLogoFromUrl($url);
}));
// get the keyword and create the URL to the search result page
$rootRow = $this->firstLevelKeywordTable->getRowFromIdSubDataTable($idSubtable);
if ($rootRow) {
$keyword = $rootRow->getColumn('label');
$table->queueFilter('MetadataCallbackReplace', array('url', function ($url, $keyword) {
return SearchEngine::getInstance()->getBackLinkFromUrlAndKeyword($url, $keyword);
}, array($keyword)));
$table->queueFilter(function (DataTable $table) {
$row = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
if ($row) {
$row->deleteMetadata('url');
}
});
}
}
示例8: mergeSubtables
/**
* Returns a new DataTable in which the rows of this table are replaced with the aggregatated rows of all its subtables.
*
* @param string|bool $labelColumn If supplied the label of the parent row will be added to
* a new column in each subtable row.
*
* If set to, `'label'` each subtable row's label will be prepended
* w/ the parent row's label. So `'child_label'` becomes
* `'parent_label - child_label'`.
* @param bool $useMetadataColumn If true and if `$labelColumn` is supplied, the parent row's
* label will be added as metadata and not a new column.
* @return \Piwik\DataTable
*/
public function mergeSubtables($labelColumn = false, $useMetadataColumn = false)
{
$result = new DataTable();
$result->setAllTableMetadata($this->getAllTableMetadata());
foreach ($this->getRowsWithoutSummaryRow() as $row) {
$subtable = $row->getSubtable();
if ($subtable !== false) {
$parentLabel = $row->getColumn('label');
// add a copy of each subtable row to the new datatable
foreach ($subtable->getRows() as $id => $subRow) {
$copy = clone $subRow;
// if the summary row, add it to the existing summary row (or add a new one)
if ($id == self::ID_SUMMARY_ROW) {
$existing = $result->getRowFromId(self::ID_SUMMARY_ROW);
if ($existing === false) {
$result->addSummaryRow($copy);
} else {
$existing->sumRow($copy, $copyMeta = true, $this->getMetadata(self::COLUMN_AGGREGATION_OPS_METADATA_NAME));
}
} else {
if ($labelColumn !== false) {
// if we're modifying the subtable's rows' label column, then we make
// sure to prepend the existing label w/ the parent row's label. otherwise
// we're just adding the parent row's label as a new column/metadata.
$newLabel = $parentLabel;
if ($labelColumn == 'label') {
$newLabel .= ' - ' . $copy->getColumn('label');
}
// modify the child row's label or add new column/metadata
if ($useMetadataColumn) {
$copy->setMetadata($labelColumn, $newLabel);
} else {
$copy->setColumn($labelColumn, $newLabel);
}
}
$result->addRow($copy);
}
}
}
}
return $result;
}
示例9: assertColumnsOfRowIdEquals
private function assertColumnsOfRowIdEquals($expectedColumns, $rowId)
{
$this->assertSame($expectedColumns, $this->table->getRowFromId($rowId)->getColumns());
}
示例10: processSummary
/**
* Helper function to display operation/cluster summary stats.
*
* @param $idSite
* @param $period
* @param $date
* @param $settings
*
* @return \Piwik\DataTable
*/
protected function processSummary($idSite, $period, $date, $settings, $addCountry = true)
{
$table = new DataTable();
$segment = $settings['name'] . '==' . $settings['context'] . ';' . $settings['value'] . '=@' . $settings['id'];
// Build an archive to retrieve the information from the records.
$archive = Archive::build($idSite, $period, $date, $segment);
/* @var \Piwik\DataTable $tdata */
$data = $archive->getDataTableFromNumeric(array('nb_visits', 'Actions_nb_downloads'));
// Add the downloads by type.
$downloads = $this->attachDownloadByType($idSite, $period, $date, $segment);
$data->getRowFromId(0)->addColumns($downloads);
$table->addRow($data->getRowFromId(0));
// Calculate the right label and load the content.
if (empty($settings['label'])) {
$base_url = 'https://www.humanitarianresponse.info/api/v1.0/';
if ($content_raw = @file_get_contents($base_url . $settings['type'] . '/' . $settings['id'])) {
$hrContent = json_decode($content_raw);
$settings['label'] = $hrContent->data[0]->label;
}
}
// Add the label to the row.
$table->getRowFromId(0)->addColumn('label', $settings['label']);
// Only add country stats on demand.
if ($addCountry && !empty($hrContent)) {
$dataByCountry = $this->attachStatsbyCountry($hrContent, $idSite, $period, $date, $segment);
if ($row = $dataByCountry->getRowFromId(0)) {
$table->addRow($row);
}
}
return $table;
}
示例11: addSummaryRow
/**
* @param DataTable $table
*/
private function addSummaryRow($table)
{
if ($table->getRowsCount() <= $this->truncateAfter + 1) {
return;
}
$table->filter('Sort', array($this->columnToSortByBeforeTruncating, 'desc', $naturalSort = true, $recursiveSort = false));
$rows = array_values($table->getRows());
$count = $table->getRowsCount();
$newRow = new Row(array(Row::COLUMNS => array('label' => DataTable::LABEL_SUMMARY_ROW)));
$aggregationOps = $table->getMetadata(DataTable::COLUMN_AGGREGATION_OPS_METADATA_NAME);
for ($i = $this->truncateAfter; $i < $count; $i++) {
if (!isset($rows[$i])) {
// case when the last row is a summary row, it is not indexed by $cout but by DataTable::ID_SUMMARY_ROW
$summaryRow = $table->getRowFromId(DataTable::ID_SUMMARY_ROW);
//FIXME: I'm not sure why it could return false, but it was reported in: http://forum.piwik.org/read.php?2,89324,page=1#msg-89442
if ($summaryRow) {
$newRow->sumRow($summaryRow, $enableCopyMetadata = false, $aggregationOps);
}
} else {
$newRow->sumRow($rows[$i], $enableCopyMetadata = false, $aggregationOps);
}
}
$table->filter('Limit', array(0, $this->truncateAfter));
$table->addSummaryRow($newRow);
unset($rows);
}